账目分类,服务分类,配件分类

This commit is contained in:
PQZ 2024-09-10 17:59:02 +08:00
parent 8bb0c90b40
commit f433aff58f
6 changed files with 25 additions and 11 deletions

View File

@ -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, "同父级下配置类型名称或编码重复");
}

View File

@ -43,6 +43,8 @@ public class BaseType extends TenantBaseDO {
* 类型01账目分类02配件分类03服务分类
*/
private String type;
/**排序*/
private double sort;
/**
* 备注
*/

View File

@ -27,9 +27,10 @@ public interface BaseTypeService extends IService<BaseType> {
/**
* 删除配置类型
*
* @param id 编号
*/
* @author PQZ
* @date 17:07 2024/9/10
* @param id 配置类型id
**/
void deleteBaseType(String id);
/**

View File

@ -45,7 +45,7 @@ public class BaseTypeServiceImpl extends ServiceImpl<BaseTypeMapper, BaseType> 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<BaseTypeMapper, BaseType> 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<BaseTypeMapper, BaseType> 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<BaseType> 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);

View File

@ -13,7 +13,7 @@ import com.alibaba.excel.annotation.*;
@ExcelIgnoreUnannotated
public class BaseTypeRespVO extends BaseType {
/**关联子公司*/
List<String> corpIds;
List<String> corpIds = new ArrayList<>();
/**子公司名称字符串*/
String corpNames;
}

View File

@ -17,6 +17,7 @@
dl_base_type dbt
LEFT JOIN base_company bc ON FIND_IN_SET(bc.id, dbt.corp_id) > 0
<where>
dbt.deleted = 0
<if test="entity.type != null and entity.type != ''">
and dbt.type = #{entity.type}
</if>
@ -31,6 +32,7 @@
</if>
</where>
GROUP BY
dbt.id;
dbt.id
order by dbt.sort asc
</select>
</mapper>