Kaynağa Gözat

Refactor: code style

liweihao 5 yıl önce
ebeveyn
işleme
d6476167ed

+ 17 - 17
src/main/java/com/example/kdan_data_center/datacenter/file/FileService.kt

@@ -1,6 +1,6 @@
 package com.example.kdan_data_center.datacenter.file
 
-import com.example.kdan_data_center.datacenter.file.body.SyncBody
+import com.example.kdan_data_center.datacenter.file.body.SyncFileBody
 import com.example.kdan_data_center.datacenter.file.body.UploadMissionBody
 import com.example.kdan_data_center.datacenter.file.data.*
 import io.reactivex.Observable
@@ -42,7 +42,7 @@ interface FileService {
             @Field("object_id") objectId: Int,
             @Field("project_name") projectName: String?,
             @Field("parent_id") parentId: Int?
-    )
+    ): Observable<FileInfoData>
 
     @HTTP(method = "DELETE", path = ".", hasBody = true)
     @FormUrlEncoded
@@ -65,14 +65,14 @@ interface FileService {
             @Header("Authorization") accessToken: String,
             @Field("object_type") objectType: String?,
             @Field("object_id") objectId: Int
-    )
+    ): Observable<MutiFileInfoData>
 
     @HTTP(method = "DELETE", path = "hard_destroy", hasBody = true)
     fun hardDeleteFile(
             @Header("Authorization") accessToken: String,
             @Field("object_type") objectType: String?,
-            @Field("object_id_list") objectIdList: Array<Int>
-    )
+            @Field("object_id_list[]") objectIdList: IntArray
+    ): Observable<MutiFileInfoData>
 
     @HTTP(method = "DELETE", path = "clean", hasBody = true)
     fun cleanDeleteFile(
@@ -102,16 +102,16 @@ interface FileService {
             @Field("object_type") objectType: String?,
             @Field("object_id") objectId: Int,
             @Field("parent_id") parentId: Int
-    )
+    ): Observable<MutiFileInfoData>
 
     @POST("copy")
     @FormUrlEncoded
     fun copyFile(
             @Header("Authorization") accessToken: String,
             @Field("object_type") objectType: String?,
-            @Field("object_id_list") objectIdList: Array<Int>,
+            @Field("object_id_list[]") objectIdList: IntArray,
             @Field("parent_id") parentId: Int
-    )
+    ): Observable<MutiFileInfoData>
 
     @PUT("move")
     @FormUrlEncoded
@@ -120,23 +120,23 @@ interface FileService {
             @Field("object_type") objectType: String?,
             @Field("object_id") objectId: Int,
             @Field("parent_id") parentId: Int
-    )
+    ): Observable<MutiFileInfoData>
 
     @PUT("move")
     @FormUrlEncoded
     fun moveFile(
             @Header("Authorization") accessToken: String,
             @Field("object_type") objectType: String?,
-            @Field("object_id_list") objectIdList: Array<Int>,
+            @Field("object_id_list[]") objectIdList: IntArray,
             @Field("parent_id") parentId: Int
-    )
+    ): Observable<MutiFileInfoData>
 
     @GET("download_url")
-    fun getDownloadUrl(
+    fun getFileDownloadUrl(
             @Header("Authorization") accessToken: String,
             @Query("object_id") objectId: Int,
             @Query("object_type") objectType: String?
-    ): Observable<DownloadUrlData>
+    ): Observable<FileDownloadUrlData>
 
     @GET("data_source_url")
     fun getDataSourceUrl(
@@ -161,12 +161,12 @@ interface FileService {
     @GET("preview_info")
     fun getFilePreviewInfo(
             @Query("token") previewToken: String
-    )
+    ): Observable<FilePreviewInfoData>
 
     @PUT("sync_architecture")
-    fun sync(
+    fun syncFile(
             @Header("Authorization") accessToken: String,
             @Header("Content-Type") contentType: String,
-            @Body syncBody: SyncBody
-    ): Observable<SyncData>
+            @Body syncFileBody: SyncFileBody
+    ): Observable<SyncFileData>
 }

+ 0 - 21
src/main/java/com/example/kdan_data_center/datacenter/file/body/SyncBody.kt

@@ -1,21 +0,0 @@
-package com.example.kdan_data_center.datacenter.file.body
-
-import com.google.gson.annotations.SerializedName
-
-
-data class SyncBody(
-        @SerializedName("last_sync_time") val lastSyncTime: String,
-        @SerializedName("architecture_infos") val architectureInfos: List<ArchitectureInfo>
-) {
-
-    data class ArchitectureInfo(
-            @SerializedName("project_id") val projectId: String,
-            @SerializedName("bucket_name") val bucketName: String,
-            @SerializedName("updated_at") val updatedAt: String
-    ){
-        @SerializedName("prev_parent_id") val prevParentId: Int? = null
-        @SerializedName("cur_parent_id") val curParentId: Int? = null
-        @SerializedName("prev_name") val prevName: String? = null
-        @SerializedName("cur_name") val curName: String? = null
-    }
-}

+ 39 - 0
src/main/java/com/example/kdan_data_center/datacenter/file/body/SyncFileBody.kt

@@ -0,0 +1,39 @@
+package com.example.kdan_data_center.datacenter.file.body
+
+import com.google.gson.annotations.SerializedName
+
+
+data class SyncFileBody(
+        @SerializedName("last_sync_time") val lastSyncTime: String,
+        @SerializedName("architecture_infos") val architectureInfos: List<ArchitectureInfo>
+) {
+
+    open class ArchitectureInfo(
+            @SerializedName("project_id") val projectId: String,
+            @SerializedName("bucket_name") val bucketName: String,
+            @SerializedName("updated_at") val updatedAt: String
+    )
+
+    class ArchitectureInfoMoveExist(
+            projectId: String,
+            bucketName: String,
+            updatedAt: String,
+            @SerializedName("prev_parent_id") val prevParentId: Int?,
+            @SerializedName("cur_parent_id") val curParentId: Int?
+    ) : ArchitectureInfo(projectId, bucketName, updatedAt)
+
+    class ArchitectureInfoMoveNew(
+            projectId: String,
+            bucketName: String,
+            updatedAt: String,
+            @SerializedName("cur_path") val curPath: String?
+    ) : ArchitectureInfo(projectId, bucketName, updatedAt)
+
+    class ArchitectureInfoRename(
+            projectId: String,
+            bucketName: String,
+            updatedAt: String,
+            @SerializedName("prev_name") val prevName: String?,
+            @SerializedName("cur_name") val curName: String?
+    ) : ArchitectureInfo(projectId, bucketName, updatedAt)
+}

+ 1 - 1
src/main/java/com/example/kdan_data_center/datacenter/file/data/DownloadUrlData.kt

@@ -3,7 +3,7 @@ package com.example.kdan_data_center.datacenter.file.data
 import com.google.gson.annotations.SerializedName
 
 
-data class DownloadUrlData(
+data class FileDownloadUrlData(
         @SerializedName("message") val message: String,
         @SerializedName("data") val data: String
 )

+ 113 - 0
src/main/java/com/example/kdan_data_center/datacenter/file/data/FilePreviewInfoData.kt

@@ -0,0 +1,113 @@
+package com.example.kdan_data_center.datacenter.file.data
+
+import com.google.gson.annotations.SerializedName
+
+
+data class FilePreviewInfoData(
+        @SerializedName("message") val message: String,
+        @SerializedName("data") val data: Data
+) {
+
+    data class Data(
+            @SerializedName("credential") val credential: Credential,
+            @SerializedName("bucket") val bucket: String,
+            @SerializedName("s3_location") val s3Location: String,
+            @SerializedName("file_info") val fileInfo: FileInfo,
+            @SerializedName("download_url") val downloadUrl: String,
+            @SerializedName("share_link_setting") val shareLinkSetting: ShareLinkSetting
+    ) {
+
+        data class FileInfo(
+                @SerializedName("object_type") val objectType: String,
+                @SerializedName("id") val id: Int,
+                @SerializedName("user_id") val userId: Int,
+                @SerializedName("app_id") val appId: Int,
+                @SerializedName("project_id") val projectId: String,
+                @SerializedName("url") val url: String?,
+                @SerializedName("size") val size: Int,
+                @SerializedName("created_at") val createdAt: String,
+                @SerializedName("updated_at") val updatedAt: String,
+                @SerializedName("project_name") val projectName: String,
+                @SerializedName("project_created_at") val projectCreatedAt: String?,
+                @SerializedName("version") val version: Int?,
+                @SerializedName("cover_name") val coverName: String?,
+                @SerializedName("app_foreign_id") val appForeignId: Int,
+                @SerializedName("category") val category: String?,
+                @SerializedName("bucket_id") val bucketId: Int,
+                @SerializedName("short_url") val shortUrl: String?,
+                @SerializedName("url_created_at") val urlCreatedAt: String?,
+                @SerializedName("has_zipfile") val hasZipfile: Boolean,
+                @SerializedName("is_deleted") val isDeleted: Boolean,
+                @SerializedName("project_type") val projectType: String?,
+                @SerializedName("other_infos") val otherInfos:  HashMap<String,String>,
+                @SerializedName("is_download_file_ready") val isDownloadFileReady: Boolean,
+                @SerializedName("thumbnail_url") val thumbnailUrl:  HashMap<String,String>,
+                @SerializedName("auth") val auth: String?,
+                @SerializedName("tag_sample") val tagSample: List<String>?,
+                @SerializedName("password_protected") val passwordProtected: Boolean?,
+                @SerializedName("is_converted_file") val isConvertedFile: Boolean,
+                @SerializedName("sort_priority") val sortPriority: Int,
+                @SerializedName("user_id_backup") val userIdBackup: Int?,
+                @SerializedName("platform") val platform: String?,
+                @SerializedName("current_app_version") val currentAppVersion: Int,
+                @SerializedName("data_format_version") val dataFormatVersion: Int,
+                @SerializedName("unit_token") val unitToken: String,
+                @SerializedName("folder_id") val folderId: Int,
+                @SerializedName("app_bundle_id") val appBundleId: String,
+                @SerializedName("current_version") val currentVersion: String?,
+                @SerializedName("mainfile_key") val mainfileKey: String,
+                @SerializedName("user_updated_at") val userUpdatedAt: String,
+                @SerializedName("status") val status: String,
+                @SerializedName("active_status") val activeStatus: String,
+                @SerializedName("uploader_id") val uploaderId: Int?,
+                @SerializedName("bucket_name") val bucketName: String,
+                @SerializedName("compress_url") val compressUrl: HashMap<String,String>,
+                @SerializedName("owner_id") val ownerId: Int,
+                @SerializedName("uploader") val uploader: Uploader
+        ) {
+
+            data class Uploader(
+                    @SerializedName("id") val id: Int,
+                    @SerializedName("uid") val uid: Int,
+                    @SerializedName("account") val account: String,
+                    @SerializedName("folder_name_hash") val folderNameHash: String,
+                    @SerializedName("email") val email: String,
+                    @SerializedName("full_storage") val fullStorage: Long,
+                    @SerializedName("used_storage") val usedStorage: Long,
+                    @SerializedName("name") val name: String,
+                    @SerializedName("icon_url") val iconUrl: IconUrl
+            ) {
+
+                data class IconUrl(
+                        @SerializedName("100") val x100: String,
+                        @SerializedName("280") val x280: String
+                )
+            }
+        }
+
+        data class Credential(
+                @SerializedName("credentials") val credentials: Credentials,
+                @SerializedName("federated_user") val federatedUser: FederatedUser,
+                @SerializedName("packed_policy_size") val packedPolicySize: Int
+        ) {
+
+            data class Credentials(
+                    @SerializedName("access_key_id") val accessKeyId: String,
+                    @SerializedName("secret_access_key") val secretAccessKey: String,
+                    @SerializedName("session_token") val sessionToken: String,
+                    @SerializedName("expiration") val expiration: String
+            )
+
+            data class FederatedUser(
+                    @SerializedName("federated_user_id") val federatedUserId: String,
+                    @SerializedName("arn") val arn: String
+            )
+        }
+
+        data class ShareLinkSetting(
+                @SerializedName("available") val available: String,
+                @SerializedName("need_password") val needPassword: String,
+                @SerializedName("expired_time") val expiredTime: String
+        )
+    }
+}

+ 1 - 1
src/main/java/com/example/kdan_data_center/datacenter/file/data/SyncData.kt

@@ -3,7 +3,7 @@ package com.example.kdan_data_center.datacenter.file.data
 import com.google.gson.annotations.SerializedName
 
 
-data class SyncData(
+data class SyncFileData(
         @SerializedName("message") val message: String,
         @SerializedName("data") val data: Data
 ) {

+ 6 - 4
src/main/java/com/example/kdan_data_center/datacenter/folder/body/CreateFolderByNameBody.kt

@@ -1,13 +1,15 @@
 package com.example.kdan_data_center.datacenter.folder.body
 
+import com.google.gson.annotations.SerializedName
+
 
 data class CreateFolderByNameBody(
-        val folder_name: String
+        @SerializedName("folder_name") val folderName: String
 ) {
-    var parent_id: Int? = null
-    var other_infos: OtherInfos? = null
+    @SerializedName("parent_id") var parentId: Int? = null
+    @SerializedName("other_infos") var otherInfos: OtherInfos? = null
 
     data class OtherInfos(
-            val color: String
+            @SerializedName("color") val color: String
     )
 }

+ 5 - 4
src/main/java/com/example/kdan_data_center/datacenter/folder/body/CreateFolderByPathBody.kt

@@ -1,13 +1,14 @@
 package com.example.kdan_data_center.datacenter.folder.body
 
+import com.google.gson.annotations.SerializedName
+
 
 data class CreateFolderByPathBody(
-        val full_path: String
+        @SerializedName("full_path") val fullPath: String
 ) {
-
-    val other_infos: OtherInfos? = null
+    @SerializedName("other_infos") var otherInfos: OtherInfos? = null
 
     data class OtherInfos(
-            val color: String
+            @SerializedName("color") val color: String
     )
 }

+ 16 - 14
src/main/java/com/example/kdan_data_center/datacenter/folder/body/SyncFolderBody.kt

@@ -1,38 +1,40 @@
 package com.example.kdan_data_center.datacenter.folder.body
 
+import com.google.gson.annotations.SerializedName
+
 
 data class SyncFolderBody(
-        val last_sync_time: String,
-        val architecture_infos: List<ArchitectureInfo>
+        @SerializedName("last_sync_time") val lastSyncTime: String,
+        @SerializedName("architecture_infos") val architectureInfos: List<ArchitectureInfo>
 ) {
 
     open class ArchitectureInfo(
-            val updated_at: String,
-            val depth: Int
+            @SerializedName("updated_at") val updated_at: String,
+            @SerializedName("depth") val depth: Int
     )
 
     class ArchitectureInfoNewFolder(
             updated_at: String,
             depth: Int,
-            val cur_name: String,
-            val cur_parent_id: Int?,
-            val cur_path: String?
+            @SerializedName("cur_name") val curName: String,
+            @SerializedName("cur_parent_id") val curParentId: Int?,
+            @SerializedName("cur_path") val curPath: String?
     ) : ArchitectureInfo(updated_at, depth)
 
     class ArchitectureInfoMoveFolder(
             updated_at: String,
             depth: Int,
-            val folder_id: Int,
-            val prev_parent_id: Int,
-            val cur_parent_id: Int?,
-            val cur_path: String?
+            @SerializedName("folder_id") val folderId: Int,
+            @SerializedName("prev_parent_id") val prevParentId: Int,
+            @SerializedName("cur_parent_id") val curParentId: Int?,
+            @SerializedName("cur_path") val curPath: String?
     ) : ArchitectureInfo(updated_at, depth)
 
     class ArchitectureInfoRenameFolder(
             updated_at: String,
             depth: Int,
-            val folder_id: Int,
-            val prev_name: String,
-            val cur_name: String
+            @SerializedName("folder_id") val folderId: Int,
+            @SerializedName("prev_name") val prevName: String,
+            @SerializedName("cur_name") val curName: String
     ) : ArchitectureInfo(updated_at, depth)
 }

+ 10 - 5
src/main/java/com/example/kdan_data_center/datacenter/folder/body/UpdateFolderBody.kt

@@ -1,14 +1,19 @@
 package com.example.kdan_data_center.datacenter.folder.body
 
+import com.google.gson.annotations.SerializedName
+
 
 data class UpdateFolderBody(
-        val folder_id: Int
+        @SerializedName("folder_id") val folderId: Int
 ) {
-    var parent_id: Int? = null
-    var folder_name: String? = null
-    var other_infos: OtherInfos? = null
+    @SerializedName("parent_id")
+    var parentId: Int? = null
+    @SerializedName("folder_name")
+    var folderName: String? = null
+    @SerializedName("other_infos")
+    var otherInfos: OtherInfos? = null
 
     data class OtherInfos(
-            val color: String
+            @SerializedName("color") val color: String
     )
 }