物资接口优化
This commit is contained in:
parent
035980e849
commit
f7d336cfc4
|
|
@ -127,7 +127,7 @@ public interface TypeMapper {
|
||||||
*/
|
*/
|
||||||
int logicDeleteTypeByTypeIds(Long[] typeIds);
|
int logicDeleteTypeByTypeIds(Long[] typeIds);
|
||||||
|
|
||||||
Type queryByName(String typeName);
|
Type queryByNameAndParentId(@Param("typeName") String typeName, @Param("parentId") Long parentId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ID查询
|
* 根据ID查询
|
||||||
|
|
|
||||||
|
|
@ -290,8 +290,8 @@ public class TypeServiceImpl implements ITypeService {
|
||||||
@Override
|
@Override
|
||||||
public int insertType(Type type) {
|
public int insertType(Type type) {
|
||||||
//根据类型名称判断,去重
|
//根据类型名称判断,去重
|
||||||
Type maType = typeMapper.queryByName(type.getTypeName());
|
Type maType = typeMapper.queryByNameAndParentId(type.getTypeName(), type.getParentId());
|
||||||
if (maType != null && maType.getParentId().equals(type.getParentId())) {
|
if (maType != null) {
|
||||||
throw new RuntimeException("同级下类型名称存在重复!");
|
throw new RuntimeException("同级下类型名称存在重复!");
|
||||||
}
|
}
|
||||||
type.setLevel(String.valueOf(Integer.parseInt(type.getLevel()) + 1));
|
type.setLevel(String.valueOf(Integer.parseInt(type.getLevel()) + 1));
|
||||||
|
|
@ -318,8 +318,8 @@ public class TypeServiceImpl implements ITypeService {
|
||||||
@Override
|
@Override
|
||||||
public int updateType(Type type) {
|
public int updateType(Type type) {
|
||||||
//根据类型名称判断,去重
|
//根据类型名称判断,去重
|
||||||
Type maType = typeMapper.queryByName(type.getTypeName());
|
Type maType = typeMapper.queryByNameAndParentId(type.getTypeName(), type.getParentId());
|
||||||
if (maType != null && !maType.getTypeId().equals(type.getTypeId()) && maType.getParentId().equals(type.getParentId())) {
|
if (maType != null && !maType.getTypeId().equals(type.getTypeId())) {
|
||||||
throw new RuntimeException("同级下类型名称存在重复!");
|
throw new RuntimeException("同级下类型名称存在重复!");
|
||||||
}
|
}
|
||||||
type.setUpdateTime(DateUtils.getNowDate());
|
type.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
|
|
||||||
|
|
@ -513,11 +513,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
<select id="queryByName" resultType="com.bonus.material.ma.domain.Type">
|
<select id="queryByNameAndParentId" resultType="com.bonus.material.ma.domain.Type">
|
||||||
select
|
select
|
||||||
type_id as typeId, parent_id as parentId, type_name as typeName, level as level
|
type_id as typeId, parent_id as parentId, type_name as typeName, level as level
|
||||||
from ma_type
|
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>
|
||||||
|
|
||||||
<select id="selectById" resultType="com.bonus.material.ma.domain.Type">
|
<select id="selectById" resultType="com.bonus.material.ma.domain.Type">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue