|
@@ -101,42 +101,50 @@ abstract class SAbstractDao<ENTITY: Any>(entityClazz: Class<ENTITY>) {
|
|
|
* 在数据库中插入实体
|
|
|
*
|
|
|
* @param entity 插入数据库的实体
|
|
|
+ * @param builder 更新条件构件器
|
|
|
* @return 插入是否成功
|
|
|
*/
|
|
|
- abstract fun insert(entity: ENTITY): Boolean
|
|
|
+ abstract fun insert(entity: ENTITY, builder: SInsetBuilder<ENTITY>? = null): Boolean
|
|
|
|
|
|
/**
|
|
|
* 在数据库中插入/更新实体
|
|
|
*
|
|
|
* @param entity 插入/更新数据库的实体
|
|
|
+ * @param builder 更新条件构件器
|
|
|
+ *
|
|
|
* @return 插入是否成功
|
|
|
*/
|
|
|
- abstract fun replace(entity: ENTITY): Boolean
|
|
|
+ abstract fun replace(entity: ENTITY, builder: SReplaceBuilder<ENTITY>? = null): Boolean
|
|
|
|
|
|
/**
|
|
|
* 根据条件删除
|
|
|
*
|
|
|
* @param args 删除条件
|
|
|
+ * @param builder 更新条件构件器
|
|
|
+ *
|
|
|
* @return 删除是否成功
|
|
|
*/
|
|
|
- abstract fun delete(args: List<SFilter>): Boolean
|
|
|
+ abstract fun delete(args: List<SFilter>, builder: SDeleteBuilder<ENTITY>? = null): Boolean
|
|
|
|
|
|
/**
|
|
|
* 删除所有记录
|
|
|
*
|
|
|
+ * @param builder 更新条件构件器
|
|
|
+ *
|
|
|
* @return 删除是否成功
|
|
|
*/
|
|
|
- abstract fun deleteAll(): Boolean
|
|
|
+ abstract fun deleteAll(builder: SDeleteBuilder<ENTITY>? = null): Boolean
|
|
|
|
|
|
/**
|
|
|
* 根据条件更新
|
|
|
*
|
|
|
* @param entity 更新的值
|
|
|
- * @param projection 将被更新的字段列表(以逗号分隔),为空表示更新所有非空字段
|
|
|
+ * @param nullItems 将被更新的字段列表(以逗号分隔),为空表示更新所有非空字段
|
|
|
* @param args 更新条件
|
|
|
+ * @param builder 更新条件构件器
|
|
|
* @return 更新是否成功
|
|
|
*/
|
|
|
- abstract fun update(entity: ENTITY, projection: ArrayList<String>? = null, args: List<SFilter>? = null): Boolean
|
|
|
+ abstract fun update(entity: ENTITY, nullItems: ArrayList<String>? = null, args: List<SFilter>? = null, builder: SUpdateBuilder<ENTITY>? = null): Boolean
|
|
|
|
|
|
/**
|
|
|
* 根据条件查询记录
|
|
@@ -192,8 +200,8 @@ abstract class SAbstractDao<ENTITY: Any>(entityClazz: Class<ENTITY>) {
|
|
|
* @param entity 被删除的实体
|
|
|
* @return 删除是否成功
|
|
|
*/
|
|
|
- open fun delete(entity: ENTITY): Boolean {
|
|
|
- return delete(entity.filterListByKeys())
|
|
|
+ open fun delete(entity: ENTITY, builder: SDeleteBuilder<ENTITY>? = null): Boolean {
|
|
|
+ return delete(entity.filterListByKeys(), builder)
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -202,13 +210,13 @@ abstract class SAbstractDao<ENTITY: Any>(entityClazz: Class<ENTITY>) {
|
|
|
* @param args 删除条件
|
|
|
* @return 删除是否成功
|
|
|
*/
|
|
|
- open fun delete(vararg args: Pair<String, Any>): Boolean {
|
|
|
+ open fun delete(builder: SDeleteBuilder<ENTITY>? = null, vararg args: Pair<String, Any>): Boolean {
|
|
|
val filterList = ArrayList<SFilter>()
|
|
|
for (arg in args) { // 同时取列表元素与下标
|
|
|
filterList.add(SFilter.eq(arg.first, arg.second))
|
|
|
}
|
|
|
|
|
|
- return delete(filterList)
|
|
|
+ return delete(filterList, builder)
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -217,8 +225,8 @@ abstract class SAbstractDao<ENTITY: Any>(entityClazz: Class<ENTITY>) {
|
|
|
* @param args 删除条件
|
|
|
* @return 删除是否成功
|
|
|
*/
|
|
|
- open fun delete(vararg args: SFilter): Boolean {
|
|
|
- return delete(args.toList())
|
|
|
+ open fun delete(builder: SDeleteBuilder<ENTITY>? = null, vararg args: SFilter): Boolean {
|
|
|
+ return delete(args.toList(), builder)
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -227,9 +235,9 @@ abstract class SAbstractDao<ENTITY: Any>(entityClazz: Class<ENTITY>) {
|
|
|
* @param query 删除条件
|
|
|
* @return 删除是否成功
|
|
|
*/
|
|
|
- open fun delete(query: String): Boolean {
|
|
|
+ open fun delete(query: String, builder: SDeleteBuilder<ENTITY>? = null): Boolean {
|
|
|
val parser = SSyntaxParser(ByteArrayInputStream(query.toByteArray()))
|
|
|
- return delete(parser.parserFilters())
|
|
|
+ return delete(parser.parserFilters(), builder)
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -239,8 +247,8 @@ abstract class SAbstractDao<ENTITY: Any>(entityClazz: Class<ENTITY>) {
|
|
|
* @param projection 将被更新的字段列表(以逗号分隔),为空表示更新所有非空字段
|
|
|
* @return 更新是否成功
|
|
|
*/
|
|
|
- open fun update(entity: ENTITY, projection: ArrayList<String>? = null): Boolean {
|
|
|
- return update(entity, projection, entity.filterListByKeys())
|
|
|
+ open fun update(entity: ENTITY, projection: ArrayList<String>? = null, builder: SUpdateBuilder<ENTITY>? = null): Boolean {
|
|
|
+ return update(entity, projection, entity.filterListByKeys(), builder)
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -251,13 +259,13 @@ abstract class SAbstractDao<ENTITY: Any>(entityClazz: Class<ENTITY>) {
|
|
|
* @param args 更新条件
|
|
|
* @return 更新是否成功
|
|
|
*/
|
|
|
- open fun update(entity: ENTITY, projection: ArrayList<String>? = null, vararg args: Pair<String, Any>): Boolean {
|
|
|
+ open fun update(entity: ENTITY, projection: ArrayList<String>? = null, builder: SUpdateBuilder<ENTITY>? = null, vararg args: Pair<String, Any>): Boolean {
|
|
|
val filterList = ArrayList<SFilter>()
|
|
|
for (arg in args) {
|
|
|
filterList.add(SFilter.eq(arg.first, arg.second))
|
|
|
}
|
|
|
|
|
|
- return update(entity, projection, filterList)
|
|
|
+ return update(entity, projection, filterList, builder)
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -268,8 +276,8 @@ abstract class SAbstractDao<ENTITY: Any>(entityClazz: Class<ENTITY>) {
|
|
|
* @param args 更新条件
|
|
|
* @return 更新是否成功
|
|
|
*/
|
|
|
- open fun update(entity: ENTITY, projection: ArrayList<String>? = null, vararg args: SFilter): Boolean {
|
|
|
- return update(entity, projection, args.toList())
|
|
|
+ open fun update(entity: ENTITY, projection: ArrayList<String>? = null, builder: SUpdateBuilder<ENTITY>? = null, vararg args: SFilter ): Boolean {
|
|
|
+ return update(entity, projection, args.toList(), builder)
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -280,9 +288,9 @@ abstract class SAbstractDao<ENTITY: Any>(entityClazz: Class<ENTITY>) {
|
|
|
* @param query 更新条件
|
|
|
* @return 更新是否成功
|
|
|
*/
|
|
|
- open fun update(entity: ENTITY, projection: ArrayList<String>? = null, query: String): Boolean {
|
|
|
+ open fun update(entity: ENTITY, projection: ArrayList<String>? = null, query: String, builder: SUpdateBuilder<ENTITY>? = null): Boolean {
|
|
|
val parser = SSyntaxParser(ByteArrayInputStream(query.toByteArray()))
|
|
|
- return update(entity, projection, parser.parserFilters())
|
|
|
+ return update(entity, projection, parser.parserFilters(), builder)
|
|
|
}
|
|
|
|
|
|
/**
|