字典类型service/controller单元测试完善

This commit is contained in:
gaoqr
2026-01-14 17:38:07 +08:00
parent 1e052edbe7
commit 76a1ad2003
3 changed files with 409 additions and 191 deletions
@@ -1,8 +1,7 @@
package com.cf.imes.module.system.service.dict;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.cf.imes.framework.common.enums.DeletedCodeEnum;
import com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.framework.common.pojo.PageResult;
@@ -86,8 +85,12 @@ public class DictTypeServiceImpl implements DictTypeService {
// 字典类型发生改变,更新关联字典数据
String oldDictTypeDOType = oldDictTypeDO.getType();
if (ObjectUtil.isAllNotEmpty(oldDictTypeDOType, updateReqVOType) && ObjectUtil.notEqual(oldDictTypeDOType, updateReqVOType)) {
dictDataMapper.update(new LambdaUpdateWrapper<DictDataDO>().set(DictDataDO::getDictType, updateReqVOType).eq(DictDataDO::getDictType, oldDictTypeDOType).eq(DictDataDO::getStatus, DeletedCodeEnum.NOT_DELETED.getStatus()));
if (ObjectUtil.notEqual(oldDictTypeDOType, updateReqVOType)) {
UpdateWrapper<DictDataDO> wrapper = new UpdateWrapper<>();
wrapper.set("dict_type", updateReqVOType);
wrapper.eq("dict_type", oldDictTypeDOType);
wrapper.eq("status", DeletedCodeEnum.NOT_DELETED.getStatus());
dictDataMapper.update(wrapper);
}
}
@@ -125,9 +128,6 @@ public class DictTypeServiceImpl implements DictTypeService {
@VisibleForTesting
void validateDictTypeUnique(Long id, String type) {
if (CharSequenceUtil.isEmpty(type)) {
return;
}
DictTypeDO dictType = dictTypeMapper.selectByType(type);
if (dictType == null) {
return;