diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/common/ErrorCodeConstants.java b/dl-module-base/src/main/java/cn/iocoder/yudao/common/ErrorCodeConstants.java index 3ef2f593..281cc774 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/common/ErrorCodeConstants.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/common/ErrorCodeConstants.java @@ -5,6 +5,5 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode; public interface ErrorCodeConstants { ErrorCode BASE_TYPE_NOT_EXISTS = new ErrorCode(500, "配置类型不存在"); ErrorCode BASE_TYPE_EXITS_CHILDREN = new ErrorCode(500, "存在存在子配置类型,无法删除"); - ErrorCode BASE_TYPE_NAME_DUPLICATE = new ErrorCode(500, "同父级下配置类型名称重复"); - ErrorCode BASE_TYPE_PARENT_IS_CHILD = new ErrorCode(500, "不能设置自己的子BaseType为父BaseType"); + ErrorCode BASE_TYPE_NAME_DUPLICATE = new ErrorCode(500, "同父级下配置类型名称或编码重复"); } diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/conf/entity/BaseType.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/conf/entity/BaseType.java index 500da7d7..6d7edfc9 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/conf/entity/BaseType.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/conf/entity/BaseType.java @@ -43,6 +43,8 @@ public class BaseType extends TenantBaseDO { * 类型(01账目分类;02配件分类;03服务分类) */ private String type; + /**排序*/ + private double sort; /** * 备注 */ diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/conf/service/BaseTypeService.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/conf/service/BaseTypeService.java index e28099df..4f9e29b0 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/conf/service/BaseTypeService.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/conf/service/BaseTypeService.java @@ -27,9 +27,10 @@ public interface BaseTypeService extends IService { /** * 删除配置类型 - * - * @param id 编号 - */ + * @author PQZ + * @date 17:07 2024/9/10 + * @param id 配置类型id + **/ void deleteBaseType(String id); /** diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/conf/service/impl/BaseTypeServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/conf/service/impl/BaseTypeServiceImpl.java index 5d891076..1cc03841 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/conf/service/impl/BaseTypeServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/conf/service/impl/BaseTypeServiceImpl.java @@ -45,7 +45,7 @@ public class BaseTypeServiceImpl extends ServiceImpl i public void saveBaseType(BaseTypeSaveReqVO saveReqVO) { /*1、数据校验*/ //同级别下校验名称是否重复 - validateBaseTypeNameUnique(saveReqVO.getId(),saveReqVO.getParentId(),saveReqVO.getType(),saveReqVO.getName()); + validateBaseTypeNameUnique(saveReqVO.getId(),saveReqVO.getParentId(),saveReqVO.getType(),saveReqVO.getName(),saveReqVO.getCode()); /*2、数据保存*/ //类型转换 BaseType baseType = BeanUtils.toBean(saveReqVO, BaseType.class); @@ -53,7 +53,12 @@ public class BaseTypeServiceImpl extends ServiceImpl i saveOrUpdate(baseType); } - + /** + * 删除配置类型 + * @author PQZ + * @date 17:07 2024/9/10 + * @param id 配置类型id + **/ @Override public void deleteBaseType(String id) { // 校验是否有子配置类型 @@ -75,16 +80,21 @@ public class BaseTypeServiceImpl extends ServiceImpl i * @param parentId 父类id * @param type 配置类型 * @param name 名称 + * @param code 编码 * @author PQZ * @date 11:34 2024/9/10 **/ - private void validateBaseTypeNameUnique(String id, String parentId, String type, String name) { + private void validateBaseTypeNameUnique(String id, String parentId, String type, String name,String code) { //配置类型不能为空 if (StringUtils.isBlank(type)) { throw exception(BASE_TYPE_NOT_EXISTS); } LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.eq(BaseDO::getDeleted, 0).eq(BaseType::getType, type).eq(BaseType::getName, name).eq(BaseType::getParentId, parentId); + lambdaQueryWrapper.eq(BaseDO::getDeleted, 0) + .eq(BaseType::getType, type) + .eq(BaseType::getName, name) + .eq(BaseType::getName, code) + .eq(BaseType::getParentId, parentId); //id存在为编辑情况,排除自身 if (null != id) { lambdaQueryWrapper.ne(BaseType::getId, id); diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/conf/vo/BaseTypeRespVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/conf/vo/BaseTypeRespVO.java index bd64509a..b1f90bac 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/conf/vo/BaseTypeRespVO.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/conf/vo/BaseTypeRespVO.java @@ -13,7 +13,7 @@ import com.alibaba.excel.annotation.*; @ExcelIgnoreUnannotated public class BaseTypeRespVO extends BaseType { /**关联子公司*/ - List corpIds; + List corpIds = new ArrayList<>(); /**子公司名称字符串*/ String corpNames; } \ No newline at end of file diff --git a/dl-module-base/src/main/resources/mapper/baseType/BaseTypeMapper.xml b/dl-module-base/src/main/resources/mapper/baseType/BaseTypeMapper.xml index b0dbf3e4..e2692a83 100644 --- a/dl-module-base/src/main/resources/mapper/baseType/BaseTypeMapper.xml +++ b/dl-module-base/src/main/resources/mapper/baseType/BaseTypeMapper.xml @@ -17,6 +17,7 @@ dl_base_type dbt LEFT JOIN base_company bc ON FIND_IN_SET(bc.id, dbt.corp_id) > 0 + dbt.deleted = 0 and dbt.type = #{entity.type} @@ -31,6 +32,7 @@ GROUP BY - dbt.id; + dbt.id + order by dbt.sort asc \ No newline at end of file