Bladeren bron

New: sync folder body and data to api

liweihao 5 jaren geleden
bovenliggende
commit
0b6c59f697

+ 4 - 8
src/main/java/com/example/kdan_data_center/datacenter/folder/FolderService.kt

@@ -1,10 +1,7 @@
 package com.example.kdan_data_center.datacenter.folder
 
 import com.example.kdan_data_center.datacenter.folder.body.*
-import com.example.kdan_data_center.datacenter.folder.data.CreateFolderData
-import com.example.kdan_data_center.datacenter.folder.data.DeleteFolderData
-import com.example.kdan_data_center.datacenter.folder.data.FolderInfoData
-import com.example.kdan_data_center.datacenter.folder.data.UpdateFolderData
+import com.example.kdan_data_center.datacenter.folder.data.*
 import io.reactivex.Observable
 import retrofit2.http.*
 
@@ -118,10 +115,9 @@ interface FolderService {
     ): Observable<FolderInfoData>
 
     @PUT("sync_architecture")
-    fun sync(
+    fun syncFolder(
             @Header("Authorization") accessToken: String,
             @Header("Content-Type") contentType: String,
-            @Body syncBody: SyncBody
-    )
-
+            @Body syncFolderBody: SyncFolderBody
+    ): Observable<SyncFolderData>
 }

+ 38 - 0
src/main/java/com/example/kdan_data_center/datacenter/folder/body/SyncFolderBody.kt

@@ -0,0 +1,38 @@
+package com.example.kdan_data_center.datacenter.folder.body
+
+
+data class SyncFolderBody(
+        val last_sync_time: String,
+        val architecture_infos: List<ArchitectureInfo>
+) {
+
+    open class ArchitectureInfo(
+            val updated_at: String,
+            val depth: Int
+    )
+
+    class ArchitectureInfoNewFolder(
+            updated_at: String,
+            depth: Int,
+            val cur_name: String,
+            val cur_parent_id: Int?,
+            val cur_path: 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?
+    ) : ArchitectureInfo(updated_at, depth)
+
+    class ArchitectureInfoRenameFolder(
+            updated_at: String,
+            depth: Int,
+            val folder_id: Int,
+            val prev_name: String,
+            val cur_name: String
+    ) : ArchitectureInfo(updated_at, depth)
+}

+ 14 - 0
src/main/java/com/example/kdan_data_center/datacenter/folder/data/SyncFolderData.kt

@@ -0,0 +1,14 @@
+package com.example.kdan_data_center.datacenter.folder.data
+
+import com.google.gson.annotations.SerializedName
+
+
+data class SyncFolderData(
+        @SerializedName("message") val message: String,
+        @SerializedName("data") val data: Data
+) {
+
+    data class Data(
+            @SerializedName("need_sync") val needSync: Boolean
+    )
+}