Przeglądaj źródła

********labsl VS meiku***********************************
添加管线类型接口

zhangweixin 4 lat temu
rodzic
commit
71b199bb8d

+ 75 - 0
meiku/src/main/kotlin/com/persagy/meiku/controller/PipelineController.kt

@@ -0,0 +1,75 @@
+package com.persagy.meiku.controller
+
+import com.persagy.meiku.models.entities.PipelineCategory
+import com.persagy.meiku.services.PipelineCategoryService
+import com.persagy.service.models.requests.SCreateRequest
+import com.persagy.service.models.requests.SQueryRequest
+import com.persagy.service.models.requests.SUpdateRequest
+import com.persagy.service.models.responses.SBaseResponse
+import com.persagy.service.models.responses.SCreateResponse
+import com.persagy.service.models.responses.SQueryResponse
+import io.swagger.v3.oas.annotations.Operation
+import io.swagger.v3.oas.annotations.tags.Tag
+import org.springframework.web.bind.annotation.PostMapping
+import org.springframework.web.bind.annotation.RequestBody
+import org.springframework.web.bind.annotation.RequestMapping
+import org.springframework.web.bind.annotation.RestController
+
+/**
+ * 管线接口
+ * @author wx  <zhangweixin@sagacloud.com>
+ * @date  2020/11/5 10:12
+ */
+@Tag(name = "005、管线类型")
+@RestController
+@RequestMapping("/pipeline")
+class PipelineController {
+
+    /**
+     * 管线
+     *
+     * @param request   待创建管线
+     * @return  创建完成管线
+     */
+    @Operation(summary="创建管线", description ="id 为 32 位 uuid")
+    @PostMapping("/create")
+    fun create(@RequestBody request: SCreateRequest<PipelineCategory>): SCreateResponse<PipelineCategory> {
+        return PipelineCategoryService.createList(request)
+    } // Function create()
+
+    /**
+     * 根据id删除管线
+     *
+     * @param idList  id数组
+     * @return 删除的结果信息
+     */
+    @Operation(summary = "根据id删除管线", description = "")
+    @PostMapping(value = ["/delete"])
+    fun delete(@RequestBody idList: ArrayList<PipelineCategory>): SBaseResponse {
+        return PipelineCategoryService.deleteByKeysList(idList)
+    } // Function delete()
+
+    /**
+     * 更新管线
+     *
+     * @param  request   更新的内容对象
+     * @return 更新的结果
+     */
+    @Operation(summary = "更新管线", description = "")
+    @PostMapping(value = ["/update"])
+    fun update(@RequestBody request: SUpdateRequest<PipelineCategory>): SBaseResponse {
+        return PipelineCategoryService.updateList(request)
+    } // Function update()
+
+    /**
+     * 查询管线
+     *
+     * @return 查询结果
+     */
+    @Operation(summary = "查询管线", description = "")
+    @PostMapping(value = ["/query"])
+    fun query(): SQueryResponse<PipelineCategory> {
+        return PipelineCategoryService.categoryQuery()
+    } // Function query()
+
+}

+ 43 - 0
meiku/src/main/kotlin/com/persagy/meiku/models/entities/PipelineCategory.kt

@@ -0,0 +1,43 @@
+package com.persagy.meiku.models.entities
+
+import com.persagy.service.models.SBaseEntity
+import io.swagger.v3.oas.annotations.media.Schema
+import java.io.Serializable
+import javax.persistence.Column
+import javax.persistence.Id
+import javax.persistence.Table
+
+/**
+ * 管线类型
+ *
+ * @author wx  <zhangweixin@sagacloud.com>
+ * @date  2020/11/5 10:12
+ */
+@Schema(description = "管线类型")
+@Table(name = "labsl_meiku.pipeline_category")
+class PipelineCategory: SBaseEntity(), Serializable {
+
+    /** 类型 id */
+    @Schema(description = "类型 id")
+    @Id
+    @Column(name = "id")
+    var id: String? = null
+
+    /** 名称 */
+    @Schema(description = "名称")
+    @Column(name = "name")
+    var name: String? = null
+
+    /** 名称 */
+    @Schema(description = "名称")
+    @Column(name = "parent_id")
+    var parentId: String? = null
+
+    /** 颜色 */
+    @Schema(description = "颜色")
+    @Column(name = "color")
+    var color: String? = null
+
+    @Schema(description = "子节点列表")
+    var categoryList: ArrayList<PipelineCategory>? = null
+}

+ 47 - 0
meiku/src/main/kotlin/com/persagy/meiku/services/PipelineCategoryService.kt

@@ -0,0 +1,47 @@
+package com.persagy.meiku.services
+
+import com.persagy.database.SFilter
+import com.persagy.meiku.models.entities.MeiKuAnchor
+import com.persagy.meiku.models.entities.PipelineCategory
+import com.persagy.mybatis.SMybatisDao
+import com.persagy.service.SObjectService
+import com.persagy.service.models.enums.SResponseType
+import com.persagy.service.models.responses.SQueryResponse
+import java.util.*
+
+/**
+ * 管线服务
+ *
+ * @author wx  <zhangweixin@sagacloud.com>
+ * @date  2020/11/5 10:17
+ */
+object PipelineCategoryService: SObjectService<PipelineCategory>(SMybatisDao(PipelineCategory::class.java)) {
+
+    /**
+     * 查询管线类型
+     */
+    fun categoryQuery(): SQueryResponse<PipelineCategory>  {
+        return try {
+            val sQueryResponse = SQueryResponse<PipelineCategory>()
+            val pipelineCategoryList = select(SFilter.isNull("parentId")).exec()
+            for (pipelineCategory in pipelineCategoryList){
+                pipelineCategory.categoryList = select(SFilter.eq("parentId",pipelineCategory.id!!)).exec()
+            }
+            sQueryResponse.content = pipelineCategoryList
+            sQueryResponse.total = pipelineCategoryList.size.toLong()
+            sQueryResponse.result = SResponseType.success
+            sQueryResponse
+        } catch (e: Exception) {
+            e.printStackTrace()
+            SQueryResponse(SResponseType.failure,e.message!!)
+        }
+    }
+
+    override fun onCreateBefore(entity: PipelineCategory): Boolean {
+        if (entity.id.isNullOrEmpty()){
+            entity.id = UUID.randomUUID().toString().replace("-", "")
+        }
+        return super.onCreateBefore(entity)
+    }
+
+}