|
@@ -34,25 +34,23 @@ public class BaseUpdateServiceImpl implements IBaseUpdateService {
|
|
|
/**
|
|
|
* 功能描述: 批量修改, 默认需要更改的model,更改的字段类型和字段值都是一致的
|
|
|
*
|
|
|
- * @param context 用到其中的表名和所有的列(用来判断是否需要转义字符)
|
|
|
- * @param pkName 主键名
|
|
|
- * @param idList idList
|
|
|
- * @param commitData 需要更改的model, 已经转义好了,不需要到mapper层再去转义
|
|
|
- * @param columns 这是此表的所有字段属性名称,用来判断是否所有UPDATE_BY和UPDATE_TIME,和时间类型
|
|
|
+ * @param context 用到其中的表名和所有的列(用来判断是否需要转义字符)
|
|
|
+ * @param idList idList
|
|
|
* @return int
|
|
|
*/
|
|
|
@Override
|
|
|
- public int updateByIdList(TableContext context, String pkName, List<Long> idList, JSONObject commitData, List<GenTableColumn> columns) {
|
|
|
- requireNonNull(context.getTableName(), "表名为空");
|
|
|
- requireNonNull(pkName, "主键名称为空");;
|
|
|
+ public int updateByIdList(TableContext context, List<Long> idList) {
|
|
|
+ String tableName = requireNonNull(context.getTableName(), "表名为空");
|
|
|
+ String pkName = requireNonNull(context.getPkName(), "主键名称为空");;
|
|
|
requireNonNull(idList, "需要修改的idList为空");
|
|
|
- requireNonNull(commitData, "需要更改的参数为空");
|
|
|
-
|
|
|
+ JSONObject commitData = requireNonNull(context.getCommitData(), "需要更改的参数为空");
|
|
|
+ List<GenTableColumn> columns = context.getColumns();
|
|
|
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
|
|
|
+
|
|
|
commitData = ObjectUtils.ifNullSetEmpty(escapeByQueryType(columns, commitData));
|
|
|
ColumnUtils.packUpdateByAndTime(columns, commitData, currentTime);
|
|
|
|
|
|
- return mapper.updateByIdList(context.getTableName(), pkName, idList, commitData);
|
|
|
+ return mapper.updateByIdList(tableName, pkName, idList, commitData);
|
|
|
}
|
|
|
|
|
|
private JSONObject escapeByQueryType(List<GenTableColumn> columns, JSONObject commitData) {
|