Ver código fonte

********labsl VS meiku***********************************
修改数据结构

zhangweixin 4 anos atrás
pai
commit
9853406fb9

+ 126 - 0
gradle.properties

@@ -0,0 +1,126 @@
+#
+# *********************************************************************************************************************
+#
+#                     :*$@@%$*:                         ;:                ;;    ;;
+#                   :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+#                  :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+#                  =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+#                  =@*                                  %!              @ $= % %@=   =%@!      %=
+#             *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+#           %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+#         ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+#         $@*   ;@@@%=!:                *@*
+#         =@$    ;;;!=%@@@@=!           =@!
+#          %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  \u5317\u4EAC\u4E0A\u683C\u4E91\u6280\u672F\u6709\u9650\u516C\u53F8
+#           ;%@@$=$@@%*       *@@@$=%@@%;
+#              ::;::             ::;::                                              All rights reserved.
+#
+# *********************************************************************************************************************
+#
+
+PERSAGY_URL = http://www.persagy.cn
+PERSAGY_KOTLIN_VERSION = 1.4.115
+PERSAGY_SERVICE_VERSION = 1.4.155
+
+MAVEN_REPO_PUBLIC_URL = http://dev.dp.sagacloud.cn:8082/repository/maven-public/
+MAVEN_REPO_RELEASE_URL = http://dev.dp.sagacloud.cn:8082/repository/maven-releases/
+MAVEN_REPO_SNAPSHOT_URL = http://dev.dp.sagacloud.cn:8082/repository/maven-snapshots/
+NEXUS_USERNAME = saga
+NEXUS_PASSWORD = saga
+
+LICENSE_NAME = The Apache Software License, Version 2.0
+LICENSE_URL = http://www.apache.org/licenses/LICENSE-2.0.txt
+
+DEVELOPER_ID = Andy.Sybotan
+DEVELOPER_NAME = Andy
+
+JVM_TARGET = 1.8
+JDK_VERSION = 8
+
+# https://mvnrepository.com/artifact/org.postgresql/postgresql
+POSTGRESQL_VERSION=42.2.5
+## https://mvnrepository.com/artifact/com.aliyun.oss/aliyun-sdk-oss
+#ALIYUN_OSS_VERSION=3.3.0
+# https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
+COMMONS_LANG_VERSION=3.8
+# https://mvnrepository.com/artifact/org.jetbrains.dokka/dokka-gradle-plugin
+DOKKA_VERSION=0.9.16
+# https://mvnrepository.com/artifact/com.alibaba/druid
+DRUID_VERSION=1.1.10
+# https://mvnrepository.com/artifact/com.android.tools.build/gradle
+GRADLE_VERSION=3.3.2
+# https://mvnrepository.com/artifact/org.jline/jline
+JLINE_VERSION=3.9.0
+# https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
+JUNIT_VERSION=4.3.1
+
+# https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter
+MYBATIS_VERSION=1.3.2
+# https://mvnrepository.com/artifact/mysql/mysql-connector-java
+MYSQL_VERSION=8.0.12
+# https://mvnrepository.com/artifact/javax.persistence/persistence-api
+PERSISTENCE_VERSION=1.0.2
+# https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml
+POI_VERSION=4.0.1
+# https://mvnrepository.com/artifact/org.slf4j/slf4j-api
+SLF4J_VERSION=1.7.25
+## https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web
+#SPRING_BOOT_VERSION=2.1.3.RELEASE
+## https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-eureka-server
+#SPRING_CLOUD_VERSION=1.4.6.RELEASE
+## https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-config
+#SPRING_CLOUD_CONFIG_VERSION=2.0.2.RELEASE
+# https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui
+SWAGGER_VERSION=2.9.2
+# https://mvnrepository.com/artifact/org.hibernate.validator/hibernate-validator
+VALIDATOR_VERSION=6.0.13.Final
+## https://mvnrepository.com/artifact/com.google.zxing/core
+#ZXING_VERSION=3.3.0
+## https://repo.spring.io/milestone
+#SPRING_CLOUD_DEPENDENCIES=Finchley.RELEASE
+## https://mvnrepository.com/artifact/org.testng/testng
+#TESTNG_VERSION=6.14.3
+## https://mvnrepository.com/artifact/com.google.protobuf/protobuf-lite
+#PROTOBUF_VERSION = 3.7.0
+##/ https://mvnrepository.com/artifact/com.google.protobuf/protobuf-gradle-plugin
+#PROTOBUF_GRADLE_VERSION = 0.8.8
+## https://mvnrepository.com/artifact/io.netty/netty-all
+#NETTY_VERSION = 4.1.33.Final
+# https://mvnrepository.com/artifact/com.google.zxing/core
+ZXING_VERSION = 3.3.1
+# https://mvnrepository.com/artifact/com.aliyun.oss/aliyun-sdk-oss
+ALIYUN_OSS_VERSION=3.8.0
+# https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib-jdk8
+KOTLIN_VERSION = 1.3.61
+# https://mvnrepository.com/artifact/io.netty/netty-all
+NETTY_VERSION = 4.1.44.Final
+# https://mvnrepository.com/artifact/com.google.protobuf/protobuf-lite
+PROTOBUF_VERSION = 3.11.1
+# https://mvnrepository.com/artifact/com.google.protobuf/protobuf-gradle-plugin
+PROTOBUF_GRADLE_VERSION = 0.8.10
+# https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web
+SPRING_BOOT_VERSION = 2.3.4.RELEASE
+# https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-eureka-server
+SPRING_CLOUD_VERSION = 1.4.7.RELEASE
+# https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-config
+SPRING_CLOUD_CONFIG_VERSION = 2.2.0.RELEASE
+# https://repo.spring.io/milestone
+SPRING_CLOUD_DEPENDENCIES = Hoxton.RELEASE
+# https://mvnrepository.com/artifact/org.springframework.kafka/spring-kafka
+SPRING_KAFKA_VERSION = 2.4.0.RELEASE
+
+# https://mvnrepository.com/artifact/com.alibaba/druid-spring-boot-starter
+SPRING_DRUID_VERSION = 1.1.21
+#  https://mvnrepository.com/artifact/com.github.xiaoymin/swagger-bootstrap-ui
+SWAGGER_BOOTSTRAP_VERSION = 1.9.6
+# https://mvnrepository.com/artifact/org.testng/testng
+TESTNG_VERSION = 7.1.0
+
+LOMBOK_VERSION = 1.16.16
+
+# https://mvnrepository.com/artifact/org.springdoc/springdoc-openapi-ui
+SPRING_DOC_VERSION = 1.4.8
+
+#SPRING_DOC_VERSION = 3.0.0
+
+kotlin.code.style=official

+ 21 - 1
labsl/src/main/kotlin/com/persagy/labsl/WebMvcConfg.kt

@@ -20,14 +20,19 @@
 
 package com.persagy.labsl
 
+import com.alibaba.fastjson.PropertyNamingStrategy
 import com.persagy.service.interceptors.SPageInterceptor
+import com.persagy.service.json.SJsonHttpMessageConverter
 import org.slf4j.LoggerFactory
 import org.springframework.context.annotation.Configuration
+import org.springframework.http.converter.HttpMessageConverter
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
 
 @Configuration
-open class WebMvcConfg: WebMvcConfigurerAdapter() {
+open class WebMvcConfg: WebMvcConfigurer {
     companion object {
         // 日志
         private val logger = LoggerFactory.getLogger(WebMvcConfg::class.java)
@@ -43,4 +48,19 @@ open class WebMvcConfg: WebMvcConfigurerAdapter() {
         super.addInterceptors(registry)
 
     } // Function addInterceptors()
+
+    /**
+     * 配置 json 转换使用 FastJson
+     *
+     * @param   converterList       转换器列表
+     */
+    override fun configureMessageConverters(converterList: MutableList<HttpMessageConverter<*>>) {
+        // 先把JackSon的消息转换器删除.
+        converterList.removeIf { item -> item is MappingJackson2HttpMessageConverter }
+
+        val converter = SJsonHttpMessageConverter()
+        // 设置 Json 序列化,属性首字母小写
+        converter.propertyNamingStrategy = PropertyNamingStrategy.CamelCase
+        converterList.add(converter)
+    }
 } // Class WebMvcConf()

+ 3 - 2
labsl/src/main/kotlin/com/persagy/labsl/models/entities/Node.kt

@@ -92,8 +92,9 @@ open class Node : SBaseEntity(), Serializable {
     @Schema(description = "锚点列表")
     var anchorList: ArrayList<Anchor>? = null
 
-    @Schema(description = "图例节点与对象的关系")
-    var attachObjectIds: ArrayList<AttachObjectIds>? = null
+    @Schema(description = "对象 id 列表 ")
+    @Column(name = "attach_object_ids")
+    var attachObjectIds: ArrayList<String>? = null
 
     /** 图状态(1一般,2待审核,3审核完成,0发布) */
     @Schema(description = "图状态(1一般,2待审核,3审核完成,4回收站 ,0发布)")

+ 6 - 2
labsl/src/main/kotlin/com/persagy/labsl/models/entities/pub/NodePub.kt

@@ -93,8 +93,12 @@ class NodePub : SBaseEntity(), Serializable {
     @Schema(description = "锚点列表")
     var anchorList: ArrayList<AnchorPub>? = null
 
-    @Schema(description = "图例节点与对象的关系")
-    var attachObjectIds: ArrayList<AttachObjectIdsPub>? = null
+    @Schema(description = "对象 id 列表 ")
+    @Column(name = "attach_object_ids")
+    var attachObjectIds: ArrayList<String>? = null
+
+//    @Schema(description = "图例节点与对象的关系")
+//    var attachObjectIds: ArrayList<AttachObjectIdsPub>? = null
 
     /** 图状态(1一般,2待审核,3审核完成,0发布) */
     @Schema(description = "图状态(1一般,2待审核,3审核完成,0发布)")

+ 65 - 63
labsl/src/main/kotlin/com/persagy/labsl/services/GraphService.kt

@@ -139,14 +139,15 @@ object GraphService : SObjectService<Graph>(SMybatisDao(Graph::class.java)) {
                             }
                         }
                     }
-                    val attachObjectIdsList = nodes.attachObjectIds
-                    if (!attachObjectIdsList.isNullOrEmpty()){
-                        for (attachObjectIds in attachObjectIdsList){
-                            attachObjectIds.graphId = graph.graphId
-                            attachObjectIds.id = graph.id
-                            AttachObjectIdsServices.insert(attachObjectIds)
-                        }
-                    }
+//                    val attachObjectIdsList = nodes.attachObjectIds
+//                    if (!attachObjectIdsList.isNullOrEmpty()){
+//                        for (attachObjectIds in attachObjectIdsList){
+//                            attachObjectIds.graphId = graph.graphId
+//                            attachObjectIds.id = graph.id
+//                            attachObjectIds.nodeId = nodes.nodeId
+//                            AttachObjectIdsServices.insert(attachObjectIds)
+//                        }
+//                    }
                 }
             }
             val markersList = graph.elements!!.markers
@@ -323,27 +324,27 @@ object GraphService : SObjectService<Graph>(SMybatisDao(Graph::class.java)) {
                     }
                 }
 
-                val attachObjectIdsBuilder = attachObjectIdsPubService.select(
-    //                SFilter.eq("projectId", projectId!!),
-                    SFilter.eq("graphId", graph.graphId!!),
-                    SFilter.eq("id", graphPub.id!!),
-                    SFilter.eq("state", 1)
-                )
-                val attachObjectIdsList = attachObjectIdsBuilder.table("labsl.attach_object_ids").exec()
-                if (attachObjectIdsList.size>0){
-                    for (attachObjectIds in attachObjectIdsList){
-                        attachObjectIds.id = graph.id
-                        attachObjectIds.graphId = graph.graphId
-                        attachObjectIds.state = 0
-                        val insert1 = attachObjectIdsPubService.insert(attachObjectIds)
-                        if (!insert1){
-                            // 回滚
-                            backTransaction()
-                            sCreateResponse.result = SResponseType.failure
-                            return  sCreateResponse
-                        }
-                    }
-                }
+//                val attachObjectIdsBuilder = attachObjectIdsPubService.select(
+//    //                SFilter.eq("projectId", projectId!!),
+//                    SFilter.eq("graphId", graph.graphId!!),
+//                    SFilter.eq("id", graphPub.id!!),
+//                    SFilter.eq("state", 1)
+//                )
+//                val attachObjectIdsList = attachObjectIdsBuilder.table("labsl.attach_object_ids").exec()
+//                if (attachObjectIdsList.size>0){
+//                    for (attachObjectIds in attachObjectIdsList){
+//                        attachObjectIds.id = graph.id
+//                        attachObjectIds.graphId = graph.graphId
+//                        attachObjectIds.state = 0
+//                        val insert1 = attachObjectIdsPubService.insert(attachObjectIds)
+//                        if (!insert1){
+//                            // 回滚
+//                            backTransaction()
+//                            sCreateResponse.result = SResponseType.failure
+//                            return  sCreateResponse
+//                        }
+//                    }
+//                }
 
                 /** 清除草稿箱图 */
                 delOldData(graph1)
@@ -397,9 +398,9 @@ object GraphService : SObjectService<Graph>(SMybatisDao(Graph::class.java)) {
                 AnchorService.delete(
                     SFilter.eq("id", graph.id!!),
                     SFilter.eq("graphId", graph.graphId!!))
-                AttachObjectIdsServices.delete(
-                    SFilter.eq("id", graph.id!!),
-                    SFilter.eq("graphId", graph.graphId!!))
+//                AttachObjectIdsServices.delete(
+//                    SFilter.eq("id", graph.id!!),
+//                    SFilter.eq("graphId", graph.graphId!!))
             }
         }
     } // Fun delOldData()
@@ -438,9 +439,9 @@ object GraphService : SObjectService<Graph>(SMybatisDao(Graph::class.java)) {
                 AnchorService.delete(
                     SFilter.eq("state", 1),
                     SFilter.eq("graphId", graph.graphId!!))
-                AttachObjectIdsServices.delete(
-                    SFilter.eq("state", 1),
-                    SFilter.eq("graphId", graph.graphId!!))
+//                AttachObjectIdsServices.delete(
+//                    SFilter.eq("state", 1),
+//                    SFilter.eq("graphId", graph.graphId!!))
             }
         }
     } // Fun delOldData()
@@ -583,18 +584,18 @@ object GraphService : SObjectService<Graph>(SMybatisDao(Graph::class.java)) {
                                 AnchorService.insert(anchor)
                             }
                         }
-                        val attachObjectIdsBuilder = AttachObjectIdsServices.select(
-                            SFilter.eq("id", graph.id!!),
-                            SFilter.eq("graphId", graph.graphId!!)
-                        )
-                        val attachObjectIdsList = attachObjectIdsBuilder.table("labsl.attach_object_ids_pub").exec()
-                        if (attachObjectIdsList.size>0){
-                            for (attachObjectIds in attachObjectIdsList){
-                                attachObjectIds.id = graphPub.id
-                                attachObjectIds.state = 4
-                                AttachObjectIdsServices.insert(attachObjectIds)
-                            }
-                        }
+//                        val attachObjectIdsBuilder = AttachObjectIdsServices.select(
+//                            SFilter.eq("id", graph.id!!),
+//                            SFilter.eq("graphId", graph.graphId!!)
+//                        )
+//                        val attachObjectIdsList = attachObjectIdsBuilder.table("labsl.attach_object_ids_pub").exec()
+//                        if (attachObjectIdsList.size>0){
+//                            for (attachObjectIds in attachObjectIdsList){
+//                                attachObjectIds.id = graphPub.id
+//                                attachObjectIds.state = 4
+//                                AttachObjectIdsServices.insert(attachObjectIds)
+//                            }
+//                        }
                     }
 
                     val markersBuilder = MarkersService.select(
@@ -657,14 +658,14 @@ object GraphService : SObjectService<Graph>(SMybatisDao(Graph::class.java)) {
             if (nodeList.size>0){
                 for (node in nodeList){
                     try {
-                        val attachObjectIdsList = AttachObjectIdsServices.select(
-                            SFilter.eq("id", graph.id!!),
-                            SFilter.eq("graphId", graph.graphId!!),
-                            SFilter.eq("nodeId", node.nodeId!!)
-                        ).exec()
-                        if (attachObjectIdsList.size>0){
-                            node.attachObjectIds = attachObjectIdsList
-                        }
+//                        val attachObjectIdsList = AttachObjectIdsServices.select(
+//                            SFilter.eq("id", graph.id!!),
+//                            SFilter.eq("graphId", graph.graphId!!),
+//                            SFilter.eq("nodeId", node.nodeId!!)
+//                        ).exec()
+//                        if (attachObjectIdsList.size>0){
+//                            node.attachObjectIds = attachObjectIdsList
+//                        }
                         val anchorList = AnchorService.select(
                             SFilter.eq("id", graph.id!!),
                             SFilter.eq("graphId", graph.graphId!!),
@@ -697,6 +698,7 @@ object GraphService : SObjectService<Graph>(SMybatisDao(Graph::class.java)) {
             sQueryResponse.result = SResponseType.success
             sQueryResponse.content = graph
         }else{
+            sQueryResponse.message = "图不存在"
             sQueryResponse.result = SResponseType.failure
         }
         return sQueryResponse
@@ -727,14 +729,14 @@ object GraphService : SObjectService<Graph>(SMybatisDao(Graph::class.java)) {
             if (nodeList.size>0){
                 for (node in nodeList){
                     try {
-                        val attachObjectIdsList = attachObjectIdsPubService.select(
-                            SFilter.eq("id", graph.id!!),
-                            SFilter.eq("graphId", graph.graphId!!),
-                            SFilter.eq("nodeId", node.nodeId!!)
-                        ).exec()
-                        if (attachObjectIdsList.size>0){
-                            node.attachObjectIds = attachObjectIdsList
-                        }
+//                        val attachObjectIdsList = attachObjectIdsPubService.select(
+//                            SFilter.eq("id", graph.id!!),
+//                            SFilter.eq("graphId", graph.graphId!!),
+//                            SFilter.eq("nodeId", node.nodeId!!)
+//                        ).exec()
+//                        if (attachObjectIdsList.size>0){
+//                            node.attachObjectIds = attachObjectIdsList
+//                        }
                         val anchorList = anchorPubService.select(
                             SFilter.eq("id", graph.id!!),
                             SFilter.eq("graphId", graph.graphId!!),

+ 0 - 17
labsl/src/test/kotlin/com/persagy/server/test/base/CaseBase.kt

@@ -1,17 +0,0 @@
-package com.persagy.server.test.base
-
-import com.persagy.server.labsl.LaBSLApp
-import lombok.extern.slf4j.Slf4j
-import org.springframework.boot.test.context.SpringBootTest
-import org.springframework.test.context.testng.AbstractTestNGSpringContextTests
-import org.springframework.test.context.web.WebAppConfiguration
-
-/**
- *
- */
-@SpringBootTest(classes = [LaBSLApp::class])
-@WebAppConfiguration
-@Slf4j
-open class CaseBase : AbstractTestNGSpringContextTests() {
-
-} // Class CaseBase

+ 0 - 28
labsl/src/test/kotlin/com/persagy/server/test/services/GraphServiceTest.kt

@@ -1,28 +0,0 @@
-package com.persagy.server.test.services
-
-import com.persagy.server.test.base.CaseBase
-import org.testng.annotations.Test
-
-/**
- * 图、测试
- *
- * @author wx
- */
-//@RunWith(SpringRunner::class) //
-//@SpringBootTest(classes = [LaBSLApp::class])  // 加载spring  boot 配置
-//@Slf4j
-open class GraphServiceTest : CaseBase() {
-
-
-        @Test
-        fun graphCreate(){
-            System.out.println("测试中***********************************")
-            logger.info("test from logger...");
-
-
-        } // Fun
-
-
-
-
-} // Class GraphServiceTest

+ 22 - 1
meiku/src/main/kotlin/com/persagy/meiku/WebMvcConfg.kt

@@ -21,17 +21,23 @@
 package com.persagy.meiku
 
 //import com.persagy.service.interceptors.SPageInterceptor
+import com.alibaba.fastjson.PropertyNamingStrategy
+import com.persagy.service.json.SJsonHttpMessageConverter
 import org.slf4j.LoggerFactory
 import org.springframework.context.annotation.Configuration
+import org.springframework.http.converter.HttpMessageConverter
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
 
 @Configuration
-open class WebMvcConfg: WebMvcConfigurerAdapter() {
+open class WebMvcConfg: WebMvcConfigurer {
     companion object {
         // 日志
         private val logger = LoggerFactory.getLogger(WebMvcConfg::class.java)
     } // Companion object
+
     /**
      * 配置拦截器
      *
@@ -43,4 +49,19 @@ open class WebMvcConfg: WebMvcConfigurerAdapter() {
         super.addInterceptors(registry)
 
     } // Function addInterceptors()
+
+    /**
+     * 配置 json 转换使用 FastJson
+     *
+     * @param   converterList       转换器列表
+     */
+    override fun configureMessageConverters(converterList: MutableList<HttpMessageConverter<*>>) {
+        // 先把JackSon的消息转换器删除.
+        converterList.removeIf { item -> item is MappingJackson2HttpMessageConverter }
+
+        val converter = SJsonHttpMessageConverter()
+        // 设置 Json 序列化,属性首字母小写
+        converter.propertyNamingStrategy = PropertyNamingStrategy.CamelCase
+        converterList.add(converter)
+    }
 } // Class WebMvcConf()

+ 135 - 0
meiku/src/main/kotlin/com/persagy/meiku/controller/PictureController.kt

@@ -0,0 +1,135 @@
+package com.persagy.meiku.controller
+
+import com.persagy.base.extensions.toJson
+import com.persagy.database.SFilter
+import com.persagy.meiku.models.pic.Picture
+import com.persagy.meiku.services.pic.PictureService
+import com.persagy.service.models.enums.SResponseType
+import com.persagy.service.models.responses.SBaseResponse
+import com.persagy.service.models.responses.SCreateResponse
+import io.swagger.v3.oas.annotations.Operation
+import io.swagger.v3.oas.annotations.tags.Tag
+import lombok.extern.slf4j.Slf4j
+import org.slf4j.LoggerFactory
+import org.springframework.http.MediaType
+import org.springframework.http.ResponseEntity
+import org.springframework.web.bind.annotation.*
+import org.springframework.web.multipart.MultipartFile
+import java.io.IOException
+import java.util.*
+import javax.servlet.ServletOutputStream
+import javax.servlet.http.HttpServletResponse
+
+/**
+ * 图片接口
+ *
+ * @author wx
+ */
+@Tag(name = "006、图片接口")
+@RestController
+@RequestMapping("/picture")
+@Slf4j
+class PictureController {
+
+    companion object {
+        /** 日志 */
+        private val logger = LoggerFactory.getLogger(PictureController::class.java)
+    } // Companion object
+
+    /**
+     * 上传图片
+     *
+     * @param   file         图片文件
+     * @param   uid          图片id
+     * @return              创建结果信息
+     */
+   @Operation(summary = "上传图片", description = "")
+    @PostMapping(value = ["/upload"])
+    fun create(@RequestParam(value = "file", required = true) file: MultipartFile, @RequestParam(required = false) id: String?): SCreateResponse<String> {
+        var response = SCreateResponse<String>()
+        try {
+            val picture = Picture()
+            if(id.isNullOrEmpty()){
+                picture.id = UUID.randomUUID().toString().replace("-","")
+            }else{
+                PictureService.delete(SFilter.eq("id",id!!))
+                picture.id = id
+            }
+            picture.pic = file.bytes
+            logger.debug("name:"+file.name)
+            logger.debug("长度:"+file.size)
+            PictureService.insert(picture)
+            response.result = SResponseType.success
+            response.entityList = arrayListOf(picture.id!!)
+        } catch (e: Exception) {
+            response.result = SResponseType.failure
+            response.message = e.message.toString()
+            e.printStackTrace()
+        }
+        return response
+    } // Function create()
+
+    /**
+     * 根据id删除图片
+     *
+     * @param   idList      id数组
+     * @return              删除的结果信息
+     */
+    @Operation(summary = "根据id删除图片信息", description = "")
+    @PostMapping(value = ["/delete"])
+    fun delete(@RequestBody idList: ArrayList<Picture>): SBaseResponse {
+        return PictureService.deleteByKeysList(idList)
+    } // Function delete()
+
+    /**
+     * 查询图片信息
+     *
+     * @param   id             查询条件id
+     * @return                 查询结果
+     */
+    @Operation(summary = "查询图片信息", description = "")
+    @GetMapping(value = ["/query/{id}"])
+    fun query(@RequestParam id: String,response: HttpServletResponse) {
+//        val picture = PictureService.select(SFilter.eq("id", id)).entity()
+        val picture = PictureService.customSql.loadPic(id)
+        if(picture!=null){
+            response.contentType = "image/svg+xml;charset=UTF-8"
+            response.addHeader("Accept-Ranges","bytes")
+            // 将图像输出到Servlet输出流中
+            val sos: ServletOutputStream
+            try {
+                response.setContentLength(picture.pic!!.size);
+                sos = response.outputStream
+                sos.write(picture.pic!!)
+                sos.close()
+                response.flushBuffer()
+            } catch (e: IOException) {
+                e.printStackTrace()
+            }
+        }else{
+            throw RuntimeException("图片不存在")
+        }
+        logger.debug(picture?.toJson())
+
+    } // Function query()
+
+    /**
+     * 查询图片信息
+     *
+     * @param   request        查询条件
+     * @return                 查询结果
+     */
+    @Operation(summary = "查询图片信息", description = "")
+    @GetMapping(value = ["/query01/{id}"])
+    fun querys(@PathVariable("id") id: String): ResponseEntity<ByteArray> {
+        val picture = PictureService.customSql.loadPic(id)
+        if(picture!=null){
+            val buffer: ByteArray = Base64.getMimeDecoder().decode(picture.pic!!)
+            return ResponseEntity.ok().contentType(MediaType.IMAGE_PNG).body(buffer)
+        }else{
+            throw RuntimeException("图片不存在")
+        }
+
+    } // Function query()
+
+} //

+ 32 - 0
meiku/src/main/kotlin/com/persagy/meiku/models/pic/Picture.kt

@@ -0,0 +1,32 @@
+package com.persagy.meiku.models.pic
+
+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
+ */
+@Schema(description = "图片实体")
+@Table(name = "labsl_meiku.picture")
+open class Picture : SBaseEntity(), Serializable {
+
+    private val serialVersionUID = 1L
+    /** id */
+    @Schema(description = "id")
+    @Id
+    @Column(name = "id")
+    var id: String? = null
+
+    /** 图片 */
+    @Schema(description = "图片")
+    @Column(name = "pic")
+    var pic: ByteArray? = null
+
+
+}

+ 20 - 0
meiku/src/main/kotlin/com/persagy/meiku/services/mapper/CustomSql.kt

@@ -0,0 +1,20 @@
+package com.persagy.meiku.services.mapper
+
+import com.persagy.meiku.models.pic.Picture
+import org.apache.ibatis.annotations.Mapper
+import org.apache.ibatis.annotations.Param
+import org.apache.ibatis.annotations.Select
+import org.springframework.stereotype.Repository
+
+/**
+ *
+ * @author wx  <zhangweixin@sagacloud.com>
+ * @date  2020/11/2 17:36
+ */
+@Mapper
+@Repository
+interface CustomSql {
+
+    @Select("SELECT * FROM labsl_meiku.picture WHERE id = #{id}")
+    fun loadPic(@Param("id") id: String): Picture?
+}

+ 31 - 0
meiku/src/main/kotlin/com/persagy/meiku/services/pic/PictureService.kt

@@ -0,0 +1,31 @@
+package com.persagy.meiku.services.pic
+
+import com.persagy.meiku.models.pic.Picture
+import com.persagy.meiku.services.mapper.CustomSql
+import com.persagy.mybatis.SMybatisDao
+import com.persagy.service.SObjectService
+import com.persagy.service.utils.SSpringContextUtil
+import java.util.*
+
+/**
+ *
+ * @author  wx
+ * @date  2020/9/9 16:28
+ */
+object PictureService :  SObjectService<Picture>(SMybatisDao(Picture::class.java)) {
+
+    /** MQ消息对象 */
+    val customSql by lazy {
+        SSpringContextUtil.getBean(CustomSql::class.java) as CustomSql
+    }
+
+    override fun onCreateBefore(entity: Picture): Boolean {
+        entity.id = UUID.randomUUID().toString().replace("-","")
+        return super.onCreateBefore(entity)
+    } // Fun
+
+
+
+
+
+} // Object PictureService