Sfoglia il codice sorgente

整理Api输出的类,分离更直观

bjb 3 mesi fa
parent
commit
2e052c3e37

+ 0 - 1
app/src/main/java/com/iscs/bozzys/api/ApiModel.kt

@@ -1 +0,0 @@
-package com.iscs.bozzys.api

+ 11 - 11
app/src/main/java/com/iscs/bozzys/api/ApiRequest.kt

@@ -109,7 +109,7 @@ object ApiRequest {
      * @param username  用户名
      * @param pwd       密码
      */
-    suspend fun login(username: String, pwd: String): Result<Response<LoginRsp>> {
+    suspend fun login(username: String, pwd: String): Result<Response<ResponseLogin>> {
         val params = JsonObject()
         params.addProperty("username", username)
         params.addProperty("password", pwd)
@@ -128,14 +128,14 @@ object ApiRequest {
      *
      * @param refreshToken
      */
-    suspend fun refreshToken(refreshToken: String): Result<Response<LoginRsp>> {
+    suspend fun refreshToken(refreshToken: String): Result<Response<ResponseLogin>> {
         return requestApi { api.refreshToken(refreshToken) }
     }
 
     /**
      * 获取用户权限信息
      */
-    suspend fun getUserPermission(): Result<Response<PermissionRsp>> {
+    suspend fun getUserPermission(): Result<Response<ResponsePermission>> {
         return requestApi { api.getUserPermission() }
     }
 
@@ -144,7 +144,7 @@ object ApiRequest {
      *
      * @param params
      */
-    suspend fun getJobs(params: MutableMap<String, Any>): Result<Response<Page<Job>>> {
+    suspend fun getJobs(params: MutableMap<String, Any>): Result<Response<ResponsePage<Job>>> {
         return requestApi { api.getJobs(params) }
     }
 
@@ -153,7 +153,7 @@ object ApiRequest {
      *
      * @param params
      */
-    suspend fun getTasks(params: MutableMap<String, Any>): Result<Response<Page<Task>>> {
+    suspend fun getTasks(params: MutableMap<String, Any>): Result<Response<ResponsePage<Task>>> {
         return requestApi { api.getTasks(params) }
     }
 
@@ -187,7 +187,7 @@ object ApiRequest {
      *
      * @param params 请求数据
      */
-    suspend fun getDictData(params: MutableMap<String, Any>): Result<Response<Page<Dict>>> {
+    suspend fun getDictData(params: MutableMap<String, Any>): Result<Response<ResponsePage<Dict>>> {
         return requestApi { api.getDictData(params) }
     }
 
@@ -196,7 +196,7 @@ object ApiRequest {
      *
      * @param params
      */
-    suspend fun getSopList(params: MutableMap<String, Any>): Result<Response<Page<Sop>>> {
+    suspend fun getSopList(params: MutableMap<String, Any>): Result<Response<ResponsePage<Sop>>> {
         return requestApi { api.getSopList(params) }
     }
 
@@ -257,21 +257,21 @@ object ApiRequest {
     /**
      * 获取管理表单列表
      */
-    suspend fun getBpmFormList(params: MutableMap<String, Any>): Result<Response<Page<TaskFormInfo>>> {
+    suspend fun getBpmFormList(params: MutableMap<String, Any>): Result<Response<ResponsePage<TaskFormInfo>>> {
         return requestApi { api.getBpmFormList(params) }
     }
 
     /**
      * 获取点位列表
      */
-    suspend fun getIsolationPointList(params: MutableMap<String, Any>): Result<Response<Page<IsolationPoint>>> {
+    suspend fun getIsolationPointList(params: MutableMap<String, Any>): Result<Response<ResponsePage<IsolationPoint>>> {
         return requestApi { api.getIsolationPointList(params) }
     }
 
     /**
      * 获取所有消息
      */
-    suspend fun getMessages(params: MutableMap<String, Any>): Result<Response<Page<Message>>> {
+    suspend fun getMessages(params: MutableMap<String, Any>): Result<Response<ResponsePage<Message>>> {
         return requestApi { api.getMessages(params) }
     }
 
@@ -326,7 +326,7 @@ object ApiRequest {
      *
      * @param params
      */
-    suspend fun getUserCharacteristicList(params: MutableMap<String, Any>): Result<Response<Page<UserCharacteristic>>> {
+    suspend fun getUserCharacteristicList(params: MutableMap<String, Any>): Result<Response<ResponsePage<UserCharacteristic>>> {
         return requestApi { api.getUserCharacteristicList(params) }
     }
 

+ 11 - 11
app/src/main/java/com/iscs/bozzys/api/ApiService.kt

@@ -26,7 +26,7 @@ interface ApiService {
     suspend fun login(
         @Body body: JsonObject,
         @HeaderMap headers: Map<String, String> = ApiRequest.getUserHeaders()
-    ): Response<LoginRsp>
+    ): Response<ResponseLogin>
 
     /**
      * 退出登录
@@ -43,7 +43,7 @@ interface ApiService {
     suspend fun refreshToken(
         @Query("refreshToken") refreshToken: String,
         @HeaderMap headers: Map<String, String> = ApiRequest.getUserHeaders()
-    ): Response<LoginRsp>
+    ): Response<ResponseLogin>
 
     /**
      * 获取用户权限信息
@@ -52,7 +52,7 @@ interface ApiService {
     @GET("/admin-api/system/auth/get-permission-info")
     suspend fun getUserPermission(
         @HeaderMap headers: Map<String, String> = ApiRequest.getUserHeaders()
-    ): Response<PermissionRsp>
+    ): Response<ResponsePermission>
 
     /**
      * 获取作业列表数据
@@ -65,7 +65,7 @@ interface ApiService {
     suspend fun getJobs(
         @QueryMap params: MutableMap<String, Any>,
         @HeaderMap headers: Map<String, String> = ApiRequest.getUserHeaders()
-    ): Response<Page<Job>>
+    ): Response<ResponsePage<Job>>
 
     /**
      * 获取任务列表数据
@@ -77,7 +77,7 @@ interface ApiService {
     suspend fun getTasks(
         @QueryMap params: MutableMap<String, Any>,
         @HeaderMap headers: Map<String, String> = ApiRequest.getUserHeaders()
-    ): Response<Page<Task>>
+    ): Response<ResponsePage<Task>>
 
     /**
      * 查询任务数统计
@@ -114,7 +114,7 @@ interface ApiService {
     suspend fun getDictData(
         @QueryMap params: MutableMap<String, Any>,
         @HeaderMap headers: Map<String, String> = ApiRequest.getUserHeaders()
-    ): Response<Page<Dict>>
+    ): Response<ResponsePage<Dict>>
 
     /**
      * 获取SOP模板列表
@@ -124,7 +124,7 @@ interface ApiService {
     suspend fun getSopList(
         @QueryMap params: MutableMap<String, Any>,
         @HeaderMap headers: Map<String, String> = ApiRequest.getUserHeaders()
-    ): Response<Page<Sop>>
+    ): Response<ResponsePage<Sop>>
 
     /**
      * 创建作业
@@ -204,7 +204,7 @@ interface ApiService {
     suspend fun getBpmFormList(
         @QueryMap params: MutableMap<String, Any>,
         @HeaderMap headers: Map<String, String> = ApiRequest.getUserHeaders()
-    ): Response<Page<TaskFormInfo>>
+    ): Response<ResponsePage<TaskFormInfo>>
 
     /**
      * 获取点位列表
@@ -214,7 +214,7 @@ interface ApiService {
     suspend fun getIsolationPointList(
         @QueryMap params: MutableMap<String, Any>,
         @HeaderMap headers: Map<String, String> = ApiRequest.getUserHeaders()
-    ): Response<Page<IsolationPoint>>
+    ): Response<ResponsePage<IsolationPoint>>
 
     /**
      * 获取通知消息
@@ -224,7 +224,7 @@ interface ApiService {
     suspend fun getMessages(
         @QueryMap params: MutableMap<String, Any>,
         @HeaderMap headers: Map<String, String> = ApiRequest.getUserHeaders()
-    ): Response<Page<Message>>
+    ): Response<ResponsePage<Message>>
 
     /**
      * 获取未读通知消息
@@ -288,6 +288,6 @@ interface ApiService {
     suspend fun getUserCharacteristicList(
         @QueryMap params: MutableMap<String, Any>,
         @HeaderMap headers: Map<String, String> = ApiRequest.getUserHeaders()
-    ): Response<Page<UserCharacteristic>>
+    ): Response<ResponsePage<UserCharacteristic>>
 
 }

+ 15 - 0
app/src/main/java/com/iscs/bozzys/api/Dict.kt

@@ -0,0 +1,15 @@
+package com.iscs.bozzys.api
+
+import kotlinx.serialization.Serializable
+
+/**
+ * 字典结构
+ */
+@Serializable
+data class Dict(
+    val id: Int,
+    val sort: Int,
+    val label: String,
+    val value: String,
+    val status: Int
+)

+ 13 - 0
app/src/main/java/com/iscs/bozzys/api/IsolationPoint.kt

@@ -0,0 +1,13 @@
+package com.iscs.bozzys.api
+
+import kotlinx.serialization.Serializable
+
+/**
+ * 隔离点位
+ */
+@Serializable
+data class IsolationPoint(
+    val id: Int,
+    val pointName: String,
+    val pointNfc: String
+)

+ 108 - 0
app/src/main/java/com/iscs/bozzys/api/Job.kt

@@ -0,0 +1,108 @@
+package com.iscs.bozzys.api
+
+import androidx.compose.runtime.snapshots.SnapshotStateMap
+import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.graphics.Color
+import com.iscs.bozzys.ui.pages.edit.step.compose.Anchor
+import com.iscs.bozzys.ui.pages.edit.step.compose.Connection
+import com.iscs.bozzys.ui.pages.edit.step.compose.NodeUI
+import kotlinx.serialization.Serializable
+import kotlinx.serialization.json.Json
+
+/**
+ * 作业基类信息
+ */
+@Serializable
+data class Job(
+    val id: Int = -1,                        // 作业Id
+    val orderNo: String = "",                // 作业编号
+    val name: String = "",                   // 作业名称
+    val type: String = "",                   // 作业类型
+    val typeName: String = "",               // 作业类型名称,服务端不返回,本地使用
+    val urgencyLevel: String = "",           // 紧急等级
+    val designId: Int = -1,                  // sopId
+    val designName: String = "",             // 设计模板
+    val designContent: String? = null,       // sopInfo
+    val description: String = "",            // 描述
+    val initiatorId: Int = -1,               // 创建者id
+    val initiatorName: String = "",          // 创建者名称
+    val initiatorTime: Long = -1L,           // 创建者创建时间
+    val status: String = "",                 // 作业状态
+    val createTime: Long = -1L,              // 创建时间
+    val currentNodeId: String? = null,
+    val currentNodeName: String? = null,
+    val completionTime: Long? = null,
+    val cancellationTime: Long? = null,
+    val cancellationReason: String? = null,
+    val workflowWorkNodeDOList: List<Node>? = null
+) : java.io.Serializable {
+    /**
+     * 将接口返回的node转换为可显示的Node
+     */
+    fun toUINodeMap(): SnapshotStateMap<String, NodeUI> {
+        val json = Json { ignoreUnknownKeys = true }
+        val map = SnapshotStateMap<String, NodeUI>()
+        workflowWorkNodeDOList?.forEach {
+            val pos = json.decodeFromString<NodePositon>(it.position)
+            map[it.id.toString()] = NodeUI(it.id.toString(), Offset(pos.x, pos.y), node = it)
+        }
+        return map
+    }
+
+    fun String.toAnchor(): Anchor {
+        return when (this) {
+            "left-source" -> Anchor.LEFT
+            "right-source" -> Anchor.RIGHT
+            "top-source" -> Anchor.TOP
+            "bottom-source" -> Anchor.BOTTOM
+            "left-target" -> Anchor.LEFT
+            "right-target" -> Anchor.RIGHT
+            "top-target" -> Anchor.TOP
+            "bottom-target" -> Anchor.BOTTOM
+            else -> if (this.contains("source")) Anchor.LEFT else Anchor.RIGHT
+        }
+    }
+
+    /**
+     * 将api连线数据转化为UI层连线数据
+     */
+    fun toUIConnectList(): List<Connection> {
+        val connections = ArrayList<Connection>()
+        val json = Json { ignoreUnknownKeys = true }
+        val nodeInfo: NodeInfo = json.decodeFromString(designContent?.ifEmpty { "{}" } ?: "{}")
+        nodeInfo.edges.forEach {
+            val fromUuid = it.target
+            val toUuid = it.source
+            val fromId = workflowWorkNodeDOList?.find { node -> node.uuid == fromUuid }?.id ?: 0
+            val fromAnchor = it.targetHandle.toAnchor()
+            val toId = workflowWorkNodeDOList?.find { node -> node.uuid == toUuid }?.id ?: 0
+            val toAnchor = it.sourceHandle.toAnchor()
+            connections.add(Connection(fromId.toString(), toId.toString(), fromAnchor, toAnchor))
+        }
+        return connections
+    }
+
+    /**
+     * 获取等级名称和背景色
+     */
+    fun getLevelNameAndColor(): Pair<String, Color> {
+        return when (urgencyLevel) {
+            "1" -> "紧急" to Color(0xFFFF9800)
+            "2" -> "非常紧急" to Color(0xFFFF4500)
+            else -> "正常" to Color(0xFF1E90FF)
+        }
+    }
+
+    /**
+     * 获取任务状态名称
+     */
+    fun getJobStatusName(): String {
+        return when (status) {
+            "unreleased" -> "待发布"
+            "approved" -> "已审核"
+            "running" -> "进行中"
+            "completed" -> "已完成"
+            else -> status
+        }
+    }
+}

+ 27 - 0
app/src/main/java/com/iscs/bozzys/api/Message.kt

@@ -0,0 +1,27 @@
+package com.iscs.bozzys.api
+
+import kotlinx.serialization.Serializable
+
+/**
+ * 通知消息
+ *
+ * @param id                    消息id
+ * @param userId                用户id
+ * @param userType              用户类型
+ * @param readStatus            是否已读
+ * @param createTime            创建时间
+ * @param title                 通知标题
+ * @param templateContent       通知内容信息
+ * @param uiIsTitle             该字段为UI使用,非接口返回
+ */
+@Serializable
+data class Message(
+    val id: Int = 0,
+    val userId: Int = 0,
+    val userType: Int = 0,
+    val readStatus: Boolean = false,
+    val createTime: Long = -1L,
+    val title: String? = null,
+    val templateContent: String = "",
+    val uiIsTitle: Boolean = false,
+)

+ 2 - 279
app/src/main/java/com/iscs/bozzys/api/ApiBean.kt → app/src/main/java/com/iscs/bozzys/api/Node.kt

@@ -1,122 +1,15 @@
 package com.iscs.bozzys.api
 
 import android.util.Log
-import androidx.compose.runtime.snapshots.SnapshotStateMap
-import androidx.compose.ui.geometry.Offset
-import androidx.compose.ui.graphics.Color
 import com.iscs.bozzys.R
-import com.iscs.bozzys.ui.pages.edit.step.compose.Anchor
-import com.iscs.bozzys.ui.pages.edit.step.compose.Connection
 import com.iscs.bozzys.ui.pages.edit.step.compose.NodeUI
 import com.iscs.bozzys.utils.StringToListSerializer
 import kotlinx.serialization.Serializable
 import kotlinx.serialization.encodeToString
 import kotlinx.serialization.json.Json
 
-
-/**
- * 请求基础响应对象
- *
- * @param code
- * @param msg
- * @param data
- */
-open class Response<T>(var code: Int = 500, var msg: String = "", var data: T? = null)
-
-/**
- * 账号登录接口响应数据
- *
- * @param userId        用户id
- * @param username      用户名
- * @param nickname      用户昵称
- * @param accessToken   使用token
- * @param refreshToken  刷新token
- */
-class LoginRsp(
-    val userId: Int,
-    val username: String,
-    val nickname: String,
-    val accessToken: String,
-    val refreshToken: String
-)
-
-/**
- * 获取分页数据
- *
- * @param total 数据总数
- * @param list  当前获取到的数据
- */
-class Page<T>(val total: Int, val list: List<T>)
-
-/**
- * 获取用户角色
- *
- * @param user  用户信息
- * @param roles 角色信息
- */
-class PermissionRsp(val user: User, val roles: List<String>,val roleList: List<Role>)
-
-/**
- * 任务统计
- */
-data class TaskStatistics(val inProgressCount: Int, val completedCount: Int)
-
-
-/**
- * 点位基类
- */
-@Serializable
-data class IsolationPoint(val id: Int, val pointName: String, val pointNfc: String)
-
-/**
- * 用户
- */
-@Serializable
-data class User(
-    val id: Int = 0,
-    val userId: Int? = null,
-    val username: String = "",
-    val nickname: String = "",
-    val cardNfc: String? = null,
-    val remark: String = "",
-    val deptId: Int = 0,
-    val deptName: String? = null,
-    val postIds: List<Int> = listOf(),
-    val email: String? = null,
-    val mobile: String? = null,
-    val sex: Int = 1,
-    val avatar: String = "",
-    val status: Int = 0,
-    val loginIp: String = "",
-    val loginDate: Long = 0L,
-    val createTime: Long = 0L,
-    val workstationIds: List<Int>? = null,
-    val type: String? = "",
-) : java.io.Serializable
-
-/**
- * 流程模板
- */
-@Serializable
-data class Sop(
-    val id: Int,
-    val name: String,
-    val content: String,
-    val nodeCount: Int,
-    val status: Int,
-    val description: String,
-    val createTime: Long,
-    val updateTime: Long
-)
-
-/**
- * 字典结构
- */
-@Serializable
-data class Dict(val id: Int, val sort: Int, val label: String, val value: String, val status: Int)
-
 /**
- * 任务信息
+ * 流程节点
  */
 @Serializable
 data class Node(
@@ -542,177 +435,6 @@ data class Node(
 
 }
 
-/**
- * 任务表单信息
- */
-@Serializable
-data class TaskFormInfo(
-    val id: Int = 0,
-    val name: String? = null,
-    val conf: String? = null,
-    val fields: List<String>? = null,
-    val status: Int? = null,
-    val remark: String? = null,
-    val createTime: Long? = null
-)
-
-/**
- * 作业基类信息
- */
-@Serializable
-data class Job(
-    val id: Int = -1,                        // 作业Id
-    val orderNo: String = "",                // 作业编号
-    val name: String = "",                   // 作业名称
-    val type: String = "",                   // 作业类型
-    val typeName: String = "",               // 作业类型名称,服务端不返回,本地使用
-    val urgencyLevel: String = "",           // 紧急等级
-    val designId: Int = -1,                  // sopId
-    val designName: String = "",             // 设计模板
-    val designContent: String? = null,       // sopInfo
-    val description: String = "",            // 描述
-    val initiatorId: Int = -1,               // 创建者id
-    val initiatorName: String = "",          // 创建者名称
-    val initiatorTime: Long = -1L,           // 创建者创建时间
-    val status: String = "",                 // 作业状态
-    val createTime: Long = -1L,              // 创建时间
-    val currentNodeId: String? = null,
-    val currentNodeName: String? = null,
-    val completionTime: Long? = null,
-    val cancellationTime: Long? = null,
-    val cancellationReason: String? = null,
-    val workflowWorkNodeDOList: List<Node>? = null
-) : java.io.Serializable {
-    /**
-     * 将接口返回的node转换为可显示的Node
-     */
-    fun toUINodeMap(): SnapshotStateMap<String, NodeUI> {
-        val json = Json { ignoreUnknownKeys = true }
-        val map = SnapshotStateMap<String, NodeUI>()
-        workflowWorkNodeDOList?.forEach {
-            val pos = json.decodeFromString<NodePositon>(it.position)
-            map[it.id.toString()] = NodeUI(it.id.toString(), Offset(pos.x, pos.y), node = it)
-        }
-        return map
-    }
-
-    fun String.toAnchor(): Anchor {
-        return when (this) {
-            "left-source" -> Anchor.LEFT
-            "right-source" -> Anchor.RIGHT
-            "top-source" -> Anchor.TOP
-            "bottom-source" -> Anchor.BOTTOM
-            "left-target" -> Anchor.LEFT
-            "right-target" -> Anchor.RIGHT
-            "top-target" -> Anchor.TOP
-            "bottom-target" -> Anchor.BOTTOM
-            else -> if (this.contains("source")) Anchor.LEFT else Anchor.RIGHT
-        }
-    }
-
-    /**
-     * 将api连线数据转化为UI层连线数据
-     */
-    fun toUIConnectList(): List<Connection> {
-        val connections = ArrayList<Connection>()
-        val json = Json { ignoreUnknownKeys = true }
-        val nodeInfo: NodeInfo = json.decodeFromString(designContent?.ifEmpty { "{}" } ?: "{}")
-        nodeInfo.edges.forEach {
-            val fromUuid = it.target
-            val toUuid = it.source
-            val fromId = workflowWorkNodeDOList?.find { node -> node.uuid == fromUuid }?.id ?: 0
-            val fromAnchor = it.targetHandle.toAnchor()
-            val toId = workflowWorkNodeDOList?.find { node -> node.uuid == toUuid }?.id ?: 0
-            val toAnchor = it.sourceHandle.toAnchor()
-            connections.add(Connection(fromId.toString(), toId.toString(), fromAnchor, toAnchor))
-        }
-        return connections
-    }
-
-    /**
-     * 获取等级名称和背景色
-     */
-    fun getLevelNameAndColor(): Pair<String, Color> {
-        return when (urgencyLevel) {
-            "1" -> "紧急" to Color(0xFFFF9800)
-            "2" -> "非常紧急" to Color(0xFFFF4500)
-            else -> "正常" to Color(0xFF1E90FF)
-        }
-    }
-
-    /**
-     * 获取任务状态名称
-     */
-    fun getJobStatusName(): String {
-        return when (status) {
-            "unreleased" -> "待发布"
-            "approved" -> "已审核"
-            "running" -> "进行中"
-            "completed" -> "已完成"
-            else -> status
-        }
-    }
-}
-
-/**
- * Task任务
- */
-@Serializable
-data class Task(
-    val workId: Int,
-    val nodeId: Int,
-    val orderNo: String,
-    val name: String,
-    val urgencyLevel: String,
-    val completionTime: Long?,
-    val cancellationTime: Long?,
-    val cancellationReason: String?,
-    val initiatorName: String?,     // 发起人
-    val workerUserName: String?,    // 当前执行人
-    val workTime: Long?,
-    val currentNodeId: String?,
-    val currentNodeName: String?,
-    val approvalStatus: String
-) : java.io.Serializable {
-    /**
-     * 获取等级名称和背景色
-     */
-    fun getLevelNameAndColor(): Pair<String, Color> {
-        return when (urgencyLevel) {
-            "1" -> "紧急" to Color(0xFFFF9800)
-            "2" -> "非常紧急" to Color(0xFFFF4500)
-            else -> "正常" to Color(0xFF1E90FF)
-        }
-    }
-
-    /**
-     * 获取任务状态名称
-     */
-    fun getTaskStatusName(): String {
-        return when (approvalStatus) {
-            "approved" -> "已完成"
-            "running" -> "进行中"
-            "pending" -> "待处理"
-            else -> approvalStatus
-        }
-    }
-}
-
-/**
- * 消息结构体
- */
-@Serializable
-data class Message(
-    val id: Int = 0,
-    val userId: Int = 0,
-    val userType: Int = 0,
-    val readStatus: Boolean = false,
-    val createTime: Long = -1L,
-    val title: String? = null,
-    val templateContent: String = "",
-    val isTitle: Boolean = false,
-)
-
 /**
  * 表单需要的组件
  *
@@ -746,6 +468,7 @@ data class FormField(
     val children: List<FormField> = listOf()
 )
 
+
 /**
  * 表单Option字段
  *

+ 10 - 0
app/src/main/java/com/iscs/bozzys/api/Response.kt

@@ -0,0 +1,10 @@
+package com.iscs.bozzys.api
+
+/**
+ * 请求基础响应对象
+ *
+ * @param code
+ * @param msg
+ * @param data
+ */
+class Response<T>(var code: Int = 500, var msg: String = "", var data: T? = null)

+ 18 - 0
app/src/main/java/com/iscs/bozzys/api/ResponseLogin.kt

@@ -0,0 +1,18 @@
+package com.iscs.bozzys.api
+
+/**
+ * 账号登录接口响应数据
+ *
+ * @param userId        用户id
+ * @param username      用户名
+ * @param nickname      用户昵称
+ * @param accessToken   使用token
+ * @param refreshToken  刷新token
+ */
+class ResponseLogin(
+    val userId: Int,
+    val username: String,
+    val nickname: String,
+    val accessToken: String,
+    val refreshToken: String
+)

+ 9 - 0
app/src/main/java/com/iscs/bozzys/api/ResponsePage.kt

@@ -0,0 +1,9 @@
+package com.iscs.bozzys.api
+
+/**
+ * 获取分页数据
+ *
+ * @param total 数据总数
+ * @param list  当前获取到的数据
+ */
+class ResponsePage<T>(val total: Int, val list: List<T>)

+ 10 - 0
app/src/main/java/com/iscs/bozzys/api/ResponsePermission.kt

@@ -0,0 +1,10 @@
+package com.iscs.bozzys.api
+
+/**
+ * 获取用户角色
+ *
+ * @param user      用户信息
+ * @param roles     角色信息
+ * @param roleList  角色列表
+ */
+class ResponsePermission(val user: User, val roles: List<String>, val roleList: List<Role>)

+ 21 - 0
app/src/main/java/com/iscs/bozzys/api/Sop.kt

@@ -0,0 +1,21 @@
+package com.iscs.bozzys.api
+
+import kotlinx.serialization.Serializable
+
+/**
+ * 流程模板
+ *
+ * @param id
+ * @param name
+ */
+@Serializable
+data class Sop(
+    val id: Int,
+    val name: String,
+    val content: String,
+    val nodeCount: Int,
+    val status: Int,
+    val description: String,
+    val createTime: Long,
+    val updateTime: Long
+)

+ 74 - 0
app/src/main/java/com/iscs/bozzys/api/Task.kt

@@ -0,0 +1,74 @@
+package com.iscs.bozzys.api
+
+import androidx.compose.ui.graphics.Color
+import kotlinx.serialization.Serializable
+
+/**
+ * 任务统计
+ *
+ * @param inProgressCount   进行中
+ * @param completedCount    本月已完成
+ */
+data class TaskStatistics(
+    val inProgressCount: Int,
+    val completedCount: Int
+)
+
+/**
+ * 任务表单信息
+ */
+@Serializable
+data class TaskFormInfo(
+    val id: Int = 0,
+    val name: String? = null,
+    val conf: String? = null,
+    val fields: List<String>? = null,
+    val status: Int? = null,
+    val remark: String? = null,
+    val createTime: Long? = null
+)
+
+/**
+ * Task任务
+ */
+@Serializable
+data class Task(
+    val workId: Int,
+    val nodeId: Int,
+    val orderNo: String,
+    val name: String,
+    val urgencyLevel: String,
+    val completionTime: Long?,
+    val cancellationTime: Long?,
+    val cancellationReason: String?,
+    val initiatorName: String?,     // 发起人
+    val workerUserName: String?,    // 当前执行人
+    val workTime: Long?,
+    val currentNodeId: String?,
+    val currentNodeName: String?,
+    val approvalStatus: String
+) : java.io.Serializable {
+
+    /**
+     * 获取等级名称和背景色
+     */
+    fun getLevelNameAndColor(): Pair<String, Color> {
+        return when (urgencyLevel) {
+            "1" -> "紧急" to Color(0xFFFF9800)
+            "2" -> "非常紧急" to Color(0xFFFF4500)
+            else -> "正常" to Color(0xFF1E90FF)
+        }
+    }
+
+    /**
+     * 获取任务状态名称
+     */
+    fun getTaskStatusName(): String {
+        return when (approvalStatus) {
+            "approved" -> "已完成"
+            "running" -> "进行中"
+            "pending" -> "待处理"
+            else -> approvalStatus
+        }
+    }
+}

+ 29 - 0
app/src/main/java/com/iscs/bozzys/api/User.kt

@@ -0,0 +1,29 @@
+package com.iscs.bozzys.api
+
+import kotlinx.serialization.Serializable
+
+/**
+ * 用户信息
+ */
+@Serializable
+data class User(
+    val id: Int = 0,
+    val userId: Int? = null,
+    val username: String = "",
+    val nickname: String = "",
+    val cardNfc: String? = null,
+    val remark: String = "",
+    val deptId: Int = 0,
+    val deptName: String? = null,
+    val postIds: List<Int> = listOf(),
+    val email: String? = null,
+    val mobile: String? = null,
+    val sex: Int = 1,
+    val avatar: String = "",
+    val status: Int = 0,
+    val loginIp: String = "",
+    val loginDate: Long = 0L,
+    val createTime: Long = 0L,
+    val workstationIds: List<Int>? = null,
+    val type: String? = "",
+) : java.io.Serializable

+ 1 - 1
app/src/main/java/com/iscs/bozzys/ui/pages/message/PageMessage.kt

@@ -199,7 +199,7 @@ private fun MessageList(vm: VMMessage) {
                 modifier = Modifier.fillMaxSize()
             ) {
                 items(state.messages) { item ->
-                    if (item.isTitle) {
+                    if (item.uiIsTitle) {
                         MessageListItemTitle(item)
                     } else {
                         MessageListItemContent(vm, item)

+ 3 - 3
app/src/main/java/com/iscs/bozzys/ui/pages/vm/VMHome.kt

@@ -9,7 +9,7 @@ import com.iscs.bozzys.api.ApiRequest.getResponse
 import com.iscs.bozzys.api.ApiRequest.isCodeOk
 import com.iscs.bozzys.api.Job
 import com.iscs.bozzys.api.Message
-import com.iscs.bozzys.api.Page
+import com.iscs.bozzys.api.ResponsePage
 import com.iscs.bozzys.api.Task
 import com.iscs.bozzys.api.User
 import com.iscs.bozzys.event.RefreshEvent
@@ -239,7 +239,7 @@ class VMHome : VMBase() {
                 }.onFailure {
                     delay(1000)
                     _state.value = _state.value.copy(jobPage = _state.value.jobPage.copy(isRefresh = false))
-                    toast.emit(it.getResponse<Page<Job>>().msg)
+                    toast.emit(it.getResponse<ResponsePage<Job>>().msg)
                 }
         }
     }
@@ -271,7 +271,7 @@ class VMHome : VMBase() {
                 delay(1000)
                 _state.value =
                     _state.value.copy(taskPage = _state.value.taskPage.copy(isRefresh = false))
-                toast.emit(it.getResponse<Page<Task>>().msg)
+                toast.emit(it.getResponse<ResponsePage<Task>>().msg)
             }
         }
     }

+ 3 - 3
app/src/main/java/com/iscs/bozzys/ui/pages/vm/VMMessage.kt

@@ -41,14 +41,14 @@ class VMMessage : VMBase() {
                 val dataCount = it.data?.total ?: 0
                 it.data?.list?.forEach { msg ->
                     // 查找是否有和日期相同的标题,如果没有则插入
-                    val findTitle = newList.find { m -> m.createTime.getShowDate() == msg.createTime.getShowDate() && m.isTitle }
-                    if (findTitle == null) newList += Message(isTitle = true, title = msg.createTime.getShowDate(), createTime = msg.createTime)
+                    val findTitle = newList.find { m -> m.createTime.getShowDate() == msg.createTime.getShowDate() && m.uiIsTitle }
+                    if (findTitle == null) newList += Message(uiIsTitle = true, title = msg.createTime.getShowDate(), createTime = msg.createTime)
                     newList += msg
                 }
                 _state.value = _state.value.copy(messages = newList)
                 delay(500)
                 // 查找消息个数是否和后台返回的消息个数一致
-                val noMore = newList.count { m -> !m.isTitle } == dataCount
+                val noMore = newList.count { m -> !m.uiIsTitle } == dataCount
                 _state.value = _state.value.copy(page = _state.value.page.copy(isRefresh = false, noMore = noMore))
             }
         }