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
@@ -38,7 +38,7 @@ import java.util.*;
public class FlwCategoryServiceImpl implements IFlwCategoryService, CategoryService {
private final DefService defService;
private final FlwCategoryMapper baseMapper;
private final FlwCategoryMapper categoryMapper;
/**
* 查询流程分类
@@ -48,7 +48,7 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService, CategoryServ
*/
@Override
public FlowCategoryVo queryById(Long categoryId) {
return baseMapper.selectVoById(categoryId);
return categoryMapper.selectVoById(categoryId);
}
/**
@@ -63,7 +63,7 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService, CategoryServ
if (ObjectUtil.isNull(categoryId)) {
return null;
}
FlowCategory category = baseMapper.lambda()
FlowCategory category = categoryMapper.lambda()
.select(FlowCategory::getCategoryName)
.eq(FlowCategory::getCategoryId, categoryId)
.one();
@@ -81,7 +81,7 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService, CategoryServ
if (CollUtil.isEmpty(categoryIds)) {
return Collections.emptyMap();
}
List<FlowCategory> list = baseMapper.lambda()
List<FlowCategory> list = categoryMapper.lambda()
.select(FlowCategory::getCategoryId, FlowCategory::getCategoryName)
.in(FlowCategory::getCategoryId, categoryIds)
.list();
@@ -97,7 +97,7 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService, CategoryServ
@Override
public List<FlowCategoryVo> queryList(FlowCategoryBo bo) {
LambdaQueryWrapper<FlowCategory> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
return categoryMapper.selectVoList(lqw);
}
/**
@@ -147,7 +147,7 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService, CategoryServ
*/
@Override
public boolean checkCategoryNameUnique(FlowCategoryBo category) {
boolean exist = baseMapper.lambda()
boolean exist = categoryMapper.lambda()
.eq(FlowCategory::getCategoryName, category.getCategoryName())
.eq(FlowCategory::getParentId, category.getParentId())
.neIfPresent(FlowCategory::getCategoryId, category.getCategoryId())
@@ -176,7 +176,7 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService, CategoryServ
*/
@Override
public boolean hasChildByCategoryId(Long categoryId) {
return baseMapper.lambda().eq(FlowCategory::getParentId, categoryId).exists();
return categoryMapper.lambda().eq(FlowCategory::getParentId, categoryId).exists();
}
/**
@@ -206,13 +206,13 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService, CategoryServ
*/
@Override
public int insertByBo(FlowCategoryBo bo) {
FlowCategory info = baseMapper.selectById(bo.getParentId());
FlowCategory info = categoryMapper.selectById(bo.getParentId());
if (ObjectUtil.isNull(info)) {
throw new ServiceException("父级流程分类不存在!");
}
FlowCategory category = MapstructUtils.convert(bo, FlowCategory.class);
category.setAncestors(info.getAncestors() + StringUtils.SEPARATOR + category.getParentId());
return baseMapper.insert(category);
return categoryMapper.insert(category);
}
/**
@@ -226,7 +226,7 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService, CategoryServ
@Transactional(rollbackFor = Exception.class)
public int updateByBo(FlowCategoryBo bo) {
FlowCategory category = MapstructUtils.convert(bo, FlowCategory.class);
FlowCategory oldCategory = baseMapper.selectById(category.getCategoryId());
FlowCategory oldCategory = categoryMapper.selectById(category.getCategoryId());
if (ObjectUtil.isNull(oldCategory)) {
throw new ServiceException("流程分类不存在,无法修改");
}
@@ -234,7 +234,7 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService, CategoryServ
throw new ServiceException("不允许修改顶级分类的父级节点");
}
if (!oldCategory.getParentId().equals(category.getParentId())) {
FlowCategory newParentCategory = baseMapper.selectById(category.getParentId());
FlowCategory newParentCategory = categoryMapper.selectById(category.getParentId());
if (ObjectUtil.isNotNull(newParentCategory)) {
String newAncestors = newParentCategory.getAncestors() + StringUtils.SEPARATOR + newParentCategory.getCategoryId();
String oldAncestors = oldCategory.getAncestors();
@@ -246,7 +246,7 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService, CategoryServ
} else {
category.setAncestors(oldCategory.getAncestors());
}
return baseMapper.updateById(category);
return categoryMapper.updateById(category);
}
/**
@@ -257,7 +257,7 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService, CategoryServ
* @param oldAncestors 旧的父ID集合
*/
private void updateCategoryChildren(Long categoryId, String newAncestors, String oldAncestors) {
List<FlowCategory> children = baseMapper.lambda()
List<FlowCategory> children = categoryMapper.lambda()
.findInSet(categoryId, FlowCategory::getAncestors)
.list();
List<FlowCategory> list = new ArrayList<>();
@@ -268,7 +268,7 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService, CategoryServ
list.add(category);
}
if (CollUtil.isNotEmpty(list)) {
baseMapper.updateBatchById(list);
categoryMapper.updateBatchById(list);
}
}
@@ -281,6 +281,6 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService, CategoryServ
@CacheEvict(cacheNames = FlowConstant.FLOW_CATEGORY_NAME, key = "#categoryId")
@Override
public int deleteWithValidById(Long categoryId) {
return baseMapper.deleteById(categoryId);
return categoryMapper.deleteById(categoryId);
}
}
@@ -40,7 +40,7 @@ import java.util.Map;
@Service
public class FlwSpelServiceImpl implements IFlwSpelService {
private final FlwSpelMapper baseMapper;
private final FlwSpelMapper spelMapper;
/**
* 查询流程spel表达式定义
@@ -50,7 +50,7 @@ public class FlwSpelServiceImpl implements IFlwSpelService {
*/
@Override
public FlowSpelVo queryById(Long id){
return baseMapper.selectVoById(id);
return spelMapper.selectVoById(id);
}
/**
@@ -63,7 +63,7 @@ public class FlwSpelServiceImpl implements IFlwSpelService {
@Override
public PageResult<FlowSpelVo> queryPageList(FlowSpelBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<FlowSpel> lqw = buildQueryWrapper(bo);
Page<FlowSpelVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
Page<FlowSpelVo> result = spelMapper.selectVoPage(pageQuery.build(), lqw);
return PageResult.build(result.getRecords(), result.getTotal());
}
@@ -76,7 +76,7 @@ public class FlwSpelServiceImpl implements IFlwSpelService {
@Override
public List<FlowSpelVo> queryList(FlowSpelBo bo) {
LambdaQueryWrapper<FlowSpel> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
return spelMapper.selectVoList(lqw);
}
/**
@@ -107,7 +107,7 @@ public class FlwSpelServiceImpl implements IFlwSpelService {
public Boolean insertByBo(FlowSpelBo bo) {
FlowSpel add = MapstructUtils.convert(bo, FlowSpel.class);
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
boolean flag = spelMapper.insert(add) > 0;
if (flag) {
bo.setId(add.getId());
}
@@ -124,7 +124,7 @@ public class FlwSpelServiceImpl implements IFlwSpelService {
public Boolean updateByBo(FlowSpelBo bo) {
FlowSpel update = MapstructUtils.convert(bo, FlowSpel.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
return spelMapper.updateById(update) > 0;
}
/**
@@ -134,7 +134,7 @@ public class FlwSpelServiceImpl implements IFlwSpelService {
*/
private void validEntityBeforeSave(FlowSpel entity){
if (StringUtils.isNotBlank(entity.getViewSpel())) {
boolean exists = baseMapper.lambda()
boolean exists = spelMapper.lambda()
.eq(FlowSpel::getViewSpel, entity.getViewSpel())
.neIfPresent(FlowSpel::getId, entity.getId())
.exists();
@@ -156,7 +156,7 @@ public class FlwSpelServiceImpl implements IFlwSpelService {
if (isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteByIds(ids) > 0;
return spelMapper.deleteByIds(ids) > 0;
}
/**
@@ -193,7 +193,7 @@ public class FlwSpelServiceImpl implements IFlwSpelService {
if (CollUtil.isEmpty(viewSpels)) {
return Collections.emptyMap();
}
List<FlowSpel> list = baseMapper.lambda()
List<FlowSpel> list = spelMapper.lambda()
.select(FlowSpel::getViewSpel, FlowSpel::getRemark)
.in(FlowSpel::getViewSpel, viewSpels)
.list();
@@ -50,7 +50,7 @@ import java.util.Map;
@Slf4j
public class TestLeaveServiceImpl implements ITestLeaveService {
private final TestLeaveMapper baseMapper;
private final TestLeaveMapper leaveMapper;
private final WorkflowService workflowService;
/**
@@ -74,7 +74,7 @@ public class TestLeaveServiceImpl implements ITestLeaveService {
*/
@Override
public TestLeaveVo queryById(Long id) {
return baseMapper.selectVoById(id);
return leaveMapper.selectVoById(id);
}
/**
@@ -87,7 +87,7 @@ public class TestLeaveServiceImpl implements ITestLeaveService {
@Override
public PageResult<TestLeaveVo> queryPageList(TestLeaveBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<TestLeave> lqw = buildQueryWrapper(bo);
Page<TestLeaveVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
Page<TestLeaveVo> result = leaveMapper.selectVoPage(pageQuery.build(), lqw);
return PageResult.build(result.getRecords(), result.getTotal());
}
@@ -100,7 +100,7 @@ public class TestLeaveServiceImpl implements ITestLeaveService {
@Override
public List<TestLeaveVo> queryList(TestLeaveBo bo) {
LambdaQueryWrapper<TestLeave> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
return leaveMapper.selectVoList(lqw);
}
/**
@@ -134,7 +134,7 @@ public class TestLeaveServiceImpl implements ITestLeaveService {
if (StringUtils.isBlank(add.getStatus())) {
add.setStatus(BusinessStatusEnum.DRAFT.getStatus());
}
boolean flag = baseMapper.insert(add) > 0;
boolean flag = leaveMapper.insert(add) > 0;
if (flag) {
bo.setId(add.getId());
}
@@ -157,7 +157,7 @@ public class TestLeaveServiceImpl implements ITestLeaveService {
bo.setApplyCode(System.currentTimeMillis() + StrUtil.EMPTY);
}
TestLeave leave = MapstructUtils.convert(bo, TestLeave.class);
boolean flag = baseMapper.insertOrUpdate(leave);
boolean flag = leaveMapper.insertOrUpdate(leave);
if (flag) {
bo.setId(leave.getId());
// 后端发起需要忽略权限
@@ -187,7 +187,7 @@ public class TestLeaveServiceImpl implements ITestLeaveService {
@Override
public TestLeaveVo updateByBo(TestLeaveBo bo) {
TestLeave update = MapstructUtils.convert(bo, TestLeave.class);
baseMapper.updateById(update);
leaveMapper.updateById(update);
return MapstructUtils.convert(update, TestLeaveVo.class);
}
@@ -201,7 +201,7 @@ public class TestLeaveServiceImpl implements ITestLeaveService {
@Transactional(rollbackFor = Exception.class)
public Boolean deleteWithValidByIds(Collection<Long> ids) {
workflowService.deleteInstance(StreamUtils.toList(ids, Convert::toStr));
return baseMapper.deleteByIds(ids) > 0;
return leaveMapper.deleteByIds(ids) > 0;
}
/**
@@ -214,7 +214,7 @@ public class TestLeaveServiceImpl implements ITestLeaveService {
@EventListener(condition = "#processEvent.flowCode.startsWith('leave')")
public void processHandler(ProcessEvent processEvent) {
log.info("当前任务执行了{}", processEvent.toString());
TestLeave testLeave = baseMapper.selectById(Convert.toLong(processEvent.getBusinessId()));
TestLeave testLeave = leaveMapper.selectById(Convert.toLong(processEvent.getBusinessId()));
testLeave.setStatus(processEvent.getStatus());
// 用于例如审批附件 审批意见等 存储到业务表内 自行根据业务实现存储流程
Map<String, Object> params = processEvent.getParams();
@@ -236,7 +236,7 @@ public class TestLeaveServiceImpl implements ITestLeaveService {
}
String status = BusinessStatusEnum.findByStatus(processEvent.getStatus());
log.info("当前流程状态为{}", status);
baseMapper.updateById(testLeave);
leaveMapper.updateById(testLeave);
}
/**
@@ -264,11 +264,11 @@ public class TestLeaveServiceImpl implements ITestLeaveService {
@EventListener(condition = "#processDeleteEvent.flowCode.startsWith('leave')")
public void processDeleteHandler(ProcessDeleteEvent processDeleteEvent) {
log.info("监听删除流程事件,当前任务执行了{}", processDeleteEvent.toString());
TestLeave testLeave = baseMapper.selectById(Convert.toLong(processDeleteEvent.getBusinessId()));
TestLeave testLeave = leaveMapper.selectById(Convert.toLong(processDeleteEvent.getBusinessId()));
if (ObjectUtil.isNull(testLeave)) {
return;
}
baseMapper.deleteById(testLeave.getId());
leaveMapper.deleteById(testLeave.getId());
}
}