物资接口优化

This commit is contained in:
sxu 2024-11-07 18:18:00 +08:00
parent 035980e849
commit f7d336cfc4
3 changed files with 7 additions and 7 deletions

View File

@ -127,7 +127,7 @@ public interface TypeMapper {
*/
int logicDeleteTypeByTypeIds(Long[] typeIds);
Type queryByName(String typeName);
Type queryByNameAndParentId(@Param("typeName") String typeName, @Param("parentId") Long parentId);
/**
* 根据ID查询

View File

@ -290,8 +290,8 @@ public class TypeServiceImpl implements ITypeService {
@Override
public int insertType(Type type) {
//根据类型名称判断去重
Type maType = typeMapper.queryByName(type.getTypeName());
if (maType != null && maType.getParentId().equals(type.getParentId())) {
Type maType = typeMapper.queryByNameAndParentId(type.getTypeName(), type.getParentId());
if (maType != null) {
throw new RuntimeException("同级下类型名称存在重复!");
}
type.setLevel(String.valueOf(Integer.parseInt(type.getLevel()) + 1));
@ -318,8 +318,8 @@ public class TypeServiceImpl implements ITypeService {
@Override
public int updateType(Type type) {
//根据类型名称判断去重
Type maType = typeMapper.queryByName(type.getTypeName());
if (maType != null && !maType.getTypeId().equals(type.getTypeId()) && maType.getParentId().equals(type.getParentId())) {
Type maType = typeMapper.queryByNameAndParentId(type.getTypeName(), type.getParentId());
if (maType != null && !maType.getTypeId().equals(type.getTypeId())) {
throw new RuntimeException("同级下类型名称存在重复!");
}
type.setUpdateTime(DateUtils.getNowDate());

View File

@ -513,11 +513,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
)
</if>
</select>
<select id="queryByName" resultType="com.bonus.material.ma.domain.Type">
<select id="queryByNameAndParentId" resultType="com.bonus.material.ma.domain.Type">
select
type_id as typeId, parent_id as parentId, type_name as typeName, level as level
from ma_type
where type_name = #{typeName} and del_flag = '0'
where type_name = #{typeName} and parent_id = #{parentId} and del_flag = '0'
</select>
<select id="selectById" resultType="com.bonus.material.ma.domain.Type">