|
@@ -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
|