update 优化 规范化mapper命名

This commit is contained in:
疯狂的狮子Li
2026-05-15 12:25:57 +08:00
parent 7a5d6b4723
commit 0d8a5f9224
27 changed files with 313 additions and 310 deletions
@@ -52,7 +52,7 @@ import java.util.zip.ZipOutputStream;
@Service
public class GenTableServiceImpl implements IGenTableService {
private final GenTableMapper baseMapper;
private final GenTableMapper tableMapper;
private final GenTableColumnMapper genTableColumnMapper;
private static final String[] TABLE_IGNORE = new String[]{"sj_", "flow_", "gen_"};
@@ -93,7 +93,7 @@ public class GenTableServiceImpl implements IGenTableService {
*/
@Override
public PageResult<GenTable> selectPageGenTableList(GenTable genTable, PageQuery pageQuery) {
Page<GenTable> page = baseMapper.selectPage(pageQuery.build(), this.buildGenTableQueryWrapper(genTable));
Page<GenTable> page = tableMapper.selectPage(pageQuery.build(), this.buildGenTableQueryWrapper(genTable));
return PageResult.build(page.getRecords(), page.getTotal());
}
@@ -134,7 +134,7 @@ public class GenTableServiceImpl implements IGenTableService {
if (CollUtil.isEmpty(tablesMap)) {
return PageResult.build();
}
List<String> tableNames = baseMapper.selectTableNameList(genTable.getDataName());
List<String> tableNames = tableMapper.selectTableNameList(genTable.getDataName());
String[] tableArrays;
if (CollUtil.isNotEmpty(tableNames)) {
tableArrays = tableNames.toArray(new String[0]);
@@ -230,7 +230,7 @@ public class GenTableServiceImpl implements IGenTableService {
normalizeColumnOptions(genTable.getColumns());
String options = JsonUtils.toJsonString(genTable.getParams());
genTable.setOptions(options);
int row = baseMapper.updateById(genTable);
int row = tableMapper.updateById(genTable);
if (row > 0) {
genTableColumnMapper.updateBatchById(genTable.getColumns());
}
@@ -245,7 +245,7 @@ public class GenTableServiceImpl implements IGenTableService {
@Override
public void deleteGenTableByIds(Long[] tableIds) {
List<Long> ids = Arrays.asList(tableIds);
baseMapper.deleteByIds(ids);
tableMapper.deleteByIds(ids);
genTableColumnMapper.lambda()
.in(GenTableColumn::getTableId, ids)
.deleteCount();
@@ -265,7 +265,7 @@ public class GenTableServiceImpl implements IGenTableService {
String tableName = table.getTableName();
GenUtils.initTable(table);
table.setDataName(dataName);
int row = baseMapper.insert(table);
int row = tableMapper.insert(table);
if (row > 0) {
// 保存列信息
List<GenTableColumn> genTableColumns = SpringUtils.getAopProxy(this).selectDbTableColumnsByName(tableName, dataName);
@@ -534,7 +534,7 @@ public class GenTableServiceImpl implements IGenTableService {
* @return 包含字段集合的业务表实体
*/
private GenTable getGenTable(Long tableId) {
GenTable table = baseMapper.selectById(tableId);
GenTable table = tableMapper.selectById(tableId);
if (ObjectUtil.isNull(table)) {
throw new ServiceException("业务表不存在");
}
@@ -41,7 +41,7 @@ import java.util.Collection;
@Service
public class ${ClassName}ServiceImpl implements I${ClassName}Service {
private final ${ClassName}Mapper baseMapper;
private final ${ClassName}Mapper ${className}Mapper;
#set($TreeParentCap = "")
#if("" != $treeParentCode)
@@ -64,7 +64,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
*/
@Override
public ${ClassName}Vo queryById(${pkColumn.javaType} ${pkColumn.javaField}) {
return baseMapper.selectVoById(${pkColumn.javaField});
return ${className}Mapper.selectVoById(${pkColumn.javaField});
}
#if($table.crud)
@@ -78,7 +78,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
@Override
public PageResult<${ClassName}Vo> queryPageList(${ClassName}Bo bo, PageQuery pageQuery) {
LambdaQueryWrapper<${ClassName}> lqw = buildQueryWrapper(bo);
Page<${ClassName}Vo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
Page<${ClassName}Vo> result = ${className}Mapper.selectVoPage(pageQuery.build(), lqw);
return PageResult.build(result.getRecords(), result.getTotal());
}
#end
@@ -92,7 +92,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
@Override
public List<${ClassName}Vo> queryList(${ClassName}Bo bo) {
LambdaQueryWrapper<${ClassName}> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
return ${className}Mapper.selectVoList(lqw);
}
#if($enableUnique)
@@ -120,7 +120,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
lqw.eq(${ClassName}::get${column.capJavaField}, bo.get${column.capJavaField}());
#end
lqw.ne(bo.get${pkColumn.capJavaField}() != null, ${ClassName}::get${pkColumn.capJavaField}, bo.get${pkColumn.capJavaField}());
return !baseMapper.exists(lqw);
return !${className}Mapper.exists(lqw);
}
#end
@@ -200,7 +200,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
fillTreeMetaBeforeSave(add, false);
#end
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
boolean flag = ${className}Mapper.insert(add) > 0;
if (flag) {
bo.set${pkColumn.capJavaField}(add.get${pkColumn.capJavaField}());
}
@@ -220,7 +220,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
fillTreeMetaBeforeSave(update, true);
#end
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
return ${className}Mapper.updateById(update) > 0;
}
#if($enableStatus)
@@ -233,7 +233,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
*/
@Override
public Boolean updateStatus(${pkColumn.javaType} ${pkColumn.javaField}, ${statusColumn.javaType} status) {
return baseMapper.lambda()
return ${className}Mapper.lambda()
.set(${ClassName}::get${statusColumn.capJavaField}, status)
.eq(${ClassName}::get${pkColumn.capJavaField}, ${pkColumn.javaField})
.update();
@@ -250,7 +250,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
*/
@Override
public Boolean updateSort(${pkColumn.javaType} ${pkColumn.javaField}, ${sortColumn.javaType} sortValue) {
return baseMapper.lambda()
return ${className}Mapper.lambda()
.set(${ClassName}::get${sortColumn.capJavaField}, sortValue)
.eq(${ClassName}::get${pkColumn.capJavaField}, ${pkColumn.javaField})
.update();
@@ -276,7 +276,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
#if("" != $treeAncestorsField)
${ClassName} parent = null;
if (!ObjectUtil.equal(entity.get${TreeParentCap}(), ${treeRootValueJavaLiteral})) {
parent = baseMapper.selectById(entity.get${TreeParentCap}());
parent = ${className}Mapper.selectById(entity.get${TreeParentCap}());
if (ObjectUtil.isNull(parent)) {
throw new ServiceException("${functionName}父节点不存在");
}
@@ -287,7 +287,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
}
String newAncestors = resolveAncestors(entity.get${TreeParentCap}(), parent);
if (updateMode && entity.get${pkColumn.capJavaField}() != null) {
${ClassName} oldEntity = baseMapper.selectById(entity.get${pkColumn.capJavaField}());
${ClassName} oldEntity = ${className}Mapper.selectById(entity.get${pkColumn.capJavaField}());
if (ObjectUtil.isNull(oldEntity)) {
throw new ServiceException("${functionName}不存在,无法修改");
}
@@ -316,7 +316,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
}
private void updateChildrenAncestors(${pkColumn.javaType} currentId, String newAncestors, String oldAncestors) {
List<${ClassName}> children = baseMapper.lambda()
List<${ClassName}> children = ${className}Mapper.lambda()
.select(${ClassName}::get${pkColumn.capJavaField}, ${ClassName}::get${TreeAncestorsCap})
.findInSet(currentId, ${ClassName}::get${TreeAncestorsCap})
.list();
@@ -332,7 +332,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
updateList.add(update);
}
if (!updateList.isEmpty()) {
baseMapper.updateBatchById(updateList);
${className}Mapper.updateBatchById(updateList);
}
}
@@ -359,6 +359,6 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
if (isValid) {
// 可在此扩展删除前业务校验
}
return baseMapper.deleteByIds(ids) > 0;
return ${className}Mapper.deleteByIds(ids) > 0;
}
}