Browse Source

开发 gis 支持

zhangweixin 3 years ago
parent
commit
fb1d05a092

+ 3 - 2
gradle.properties

@@ -25,8 +25,9 @@
 #
 
 PERSAGY_URL = http://www.persagy.com
-PERSAGY_KOTLIN_VERSION = 1.4.120
-PERSAGY_SERVICE_VERSION = 1.4.162
+PERSAGY_KOTLIN_VERSION = 1.5.3
+PERSAGY_SERVICE_VERSION = 1.5.1
+#PERSAGY_SERVICE_VERSION = 1.4.164
 
 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/

+ 81 - 24
persagy-service-base/src/main/kotlin/com/persagy/service/SBaseService.kt

@@ -87,8 +87,8 @@ open class SBaseService<ENTITY: Any> {
      * @param entity      插入数据库的实体
      * @return 插入是否成功
      */
-    open fun insert(entity: ENTITY): Boolean {
-        return baseDao.insert(entity)
+    open fun insert(entity: ENTITY, builder: SInsetBuilder<ENTITY>? = null): Boolean {
+        return baseDao.insert(entity, builder)
     }
 
     /**
@@ -97,8 +97,8 @@ open class SBaseService<ENTITY: Any> {
      * @param entity      插入数据库的实体
      * @return 插入是否成功
      */
-    open fun replace(entity: ENTITY): Boolean {
-        return baseDao.replace(entity)
+    open fun replace(entity: ENTITY, builder: SReplaceBuilder<ENTITY>? = null): Boolean {
+        return baseDao.replace(entity, builder)
     }
 
     /**
@@ -107,8 +107,18 @@ open class SBaseService<ENTITY: Any> {
      * @param entity      被删除的实体
      * @return 删除是否成功
      */
-    open fun delete(entity: ENTITY): Boolean {
-        return baseDao.delete(entity)
+    open fun delete(entity: ENTITY, builder: SDeleteBuilder<ENTITY>? = null): Boolean {
+        return baseDao.delete(entity, builder)
+    }
+
+    /**
+     * 根据条件删除
+     *
+     * @param args        删除条件
+     * @return 删除是否成功
+     */
+    open fun delete(builder: SDeleteBuilder<ENTITY>? = null, vararg args: Pair<String, Any>): Boolean {
+        return baseDao.delete(builder,*args)
     }
 
     /**
@@ -118,7 +128,17 @@ open class SBaseService<ENTITY: Any> {
      * @return 删除是否成功
      */
     open fun delete(vararg args: Pair<String, Any>): Boolean {
-        return baseDao.delete(*args)
+        return baseDao.delete(null, *args)
+    }
+
+    /**
+     * 根据条件删除
+     *
+     * @param args        删除条件
+     * @return 删除是否成功
+     */
+    open fun delete(builder: SDeleteBuilder<ENTITY>? = null, vararg args: SFilter): Boolean {
+        return baseDao.delete(builder,*args)
     }
 
     /**
@@ -128,36 +148,41 @@ open class SBaseService<ENTITY: Any> {
      * @return 删除是否成功
      */
     open fun delete(vararg args: SFilter): Boolean {
-        return baseDao.delete(*args)
+        return baseDao.delete(null,*args)
     }
 
     /**
      * 根据条件删除
      *
      * @param args        删除条件
+     * @param builder     更新条件构件器
+     *
      * @return 删除是否成功
      */
-    open fun delete(args: List<SFilter>): Boolean {
-        return baseDao.delete(args)
+    open fun delete(args: List<SFilter>, builder: SDeleteBuilder<ENTITY>? = null): Boolean {
+        return baseDao.delete(args, builder)
     }
 
     /**
      * 根据条件删除
      *
      * @param query        删除条件
+     * @param builder     更新条件构件器
+     *
      * @return 删除是否成功
      */
-    open fun delete(query: String): Boolean {
-        return baseDao.delete(query)
+    open fun delete(query: String, builder: SDeleteBuilder<ENTITY>? = null): Boolean {
+        return baseDao.delete(query, builder)
     }
 
     /**
      * 删除所有记录
+     * @param builder     更新条件构件器
      *
      * @return 删除是否成功
      */
-    open fun deleteAll(): Boolean {
-        return baseDao.deleteAll()
+    open fun deleteAll(builder: SDeleteBuilder<ENTITY>? = null): Boolean {
+        return baseDao.deleteAll(builder)
     }
 
     /**
@@ -165,10 +190,12 @@ open class SBaseService<ENTITY: Any> {
      *
      * @param entity      更新实体
      * @param projection  将被更新的字段列表(以逗号分隔),为空表示更新所有非空字段
+     * @param builder     更新条件构件器
+     *
      * @return 更新是否成功
      */
-    open fun update(entity: ENTITY, projection: ArrayList<String>? = null): Boolean {
-        return baseDao.update(entity, projection)
+    open fun update(entity: ENTITY, projection: ArrayList<String>? = null, builder: SUpdateBuilder<ENTITY>? = null): Boolean {
+        return baseDao.update(entity, projection, builder)
     }
 
     /**
@@ -176,21 +203,50 @@ open class SBaseService<ENTITY: Any> {
      *
      * @param projection  将被更新的字段列表(以逗号分隔),为空表示更新所有非空字段
      * @param args        更新条件
+     * @param builder     更新条件构件器
+     *
+     * @return 更新是否成功
+     */
+    open fun update(entity: ENTITY, projection: ArrayList<String>?, builder: SUpdateBuilder<ENTITY>? = null, vararg args: Pair<String, Any>): Boolean {
+        return baseDao.update(entity, projection, builder, *args)
+    } // Fun update()
+
+
+    /**
+     * 根据条件更新
+     *
+     * @param projection  将被更新的字段列表(以逗号分隔),为空表示更新所有非空字段
+     * @param args        更新条件
+     * @param builder     更新条件构件器
+     *
      * @return 更新是否成功
      */
     open fun update(entity: ENTITY, projection: ArrayList<String>?, vararg args: Pair<String, Any>): Boolean {
-        return baseDao.update(entity, projection, *args)
+        return baseDao.update(entity, projection, null, *args)
     } // Fun update()
 
     /**
      * 根据条件更新
      *
      * @param projection  将被更新的字段列表(以逗号分隔),为空表示更新所有非空字段
+     * @param builder     更新条件构件器
+     * @param args        更新条件
+     * @return 更新是否成功
+     */
+    open fun update(entity: ENTITY, projection: ArrayList<String>?, builder: SUpdateBuilder<ENTITY>? = null, vararg args: SFilter): Boolean {
+        return baseDao.update(entity, projection, builder, *args )
+    }
+
+    /**
+     * 根据条件更新
+     *
+     * @param projection  将被更新的字段列表(以逗号分隔),为空表示更新所有非空字段
+     * @param builder     更新条件构件器
      * @param args        更新条件
      * @return 更新是否成功
      */
     open fun update(entity: ENTITY, projection: ArrayList<String>?, vararg args: SFilter): Boolean {
-        return baseDao.update(entity, projection, *args)
+        return baseDao.update(entity, projection, null, *args )
     }
 
     /**
@@ -200,19 +256,20 @@ open class SBaseService<ENTITY: Any> {
      * @param args        更新条件
      * @return 更新是否成功
      */
-    open fun update(entity: ENTITY, projection: ArrayList<String>?, args: List<SFilter>): Boolean {
-        return baseDao.update(entity, projection, args)
+    open fun update(entity: ENTITY, projection: ArrayList<String>?, args: List<SFilter>, builder: SUpdateBuilder<ENTITY>? = null): Boolean {
+        return baseDao.update(entity, projection, args, builder)
     }
 
     /**
      * 根据条件更新
      *
      * @param projection  将被更新的字段列表(以逗号分隔),为空表示更新所有非空字段
+     * @param builder     更新条件构件器
      * @param query       更新条件
      * @return 更新是否成功
      */
-    open fun update(entity: ENTITY, projection: ArrayList<String>?, query: String): Boolean {
-        return baseDao.update(entity, projection, query)
+    open fun update(entity: ENTITY, projection: ArrayList<String>?, query: String, builder: SUpdateBuilder<ENTITY>? = null): Boolean {
+        return baseDao.update(entity, projection, query, builder)
     }
 
     /**
@@ -623,8 +680,8 @@ open class SBaseService<ENTITY: Any> {
         for (entity in entityMap) {
             val keyField = entity.value.javaClass.keyFieldList()[0]
             val keyValue = entity.value.keyValue(keyField.name)!!
-            println("keyField=${keyField.toJson()}")
-            println("keyValue=${keyValue.toJson()}")
+//            println("keyField=${keyField.toJson()}")
+//            println("keyValue=${keyValue.toJson()}")
             idList.add(keyValue)
         }
         return idList

+ 5 - 3
persagy-service-base/src/main/kotlin/com/persagy/service/SObjectService.kt

@@ -80,8 +80,10 @@ open class SObjectService<ENTITY: Any>
                 }
             } else {
                 for (entity in request.content) {
-                    onCreateBefore(entity)
-                    insert(entity)
+                    val onCreateBefore = onCreateBefore(entity)
+                    if (onCreateBefore){
+                        insert(entity)
+                    }
                 }
             }
             onCreateSuccess(request.content)
@@ -166,7 +168,7 @@ open class SObjectService<ENTITY: Any>
                 }
 
                 onUpdateBefore(entity)
-                if (!update(entity, request.projection, filterList)) {
+                if (!update(entity, request.nullItems, filterList)) {
                     onUpdateFailure(entityList)
                     return SBaseResponse(SResponseType.failure, "更新失败!")
                 }

+ 1 - 1
persagy-service-base/src/main/kotlin/com/persagy/service/SPageContext.kt

@@ -132,7 +132,7 @@ object SPageContext {
         val session = getSession()
         session?.setAttribute(name, `object`)
         return
-    })
+    }
 
     /**
      * 移除保存在客户端会话中的指定属性

+ 1 - 1
persagy-service-models/src/main/kotlin/com/persagy/service/models/requests/SUpdateRequest.kt

@@ -48,5 +48,5 @@ open class SUpdateRequest<ENTITY: Any> {
 
     /** 字段影射,空为查询所有字段 */
     @Schema(description = "字段影射,空为更新所有字段")
-    var projection: ArrayList<String>? = null
+    var nullItems: ArrayList<String>? = null
 }