修改代码
This commit is contained in:
parent
83827a953f
commit
6bd0dbe4e4
|
|
@ -58,4 +58,12 @@ public interface IGroupDomain
|
|||
* @return 结果
|
||||
*/
|
||||
int deleteGroupByGroupIds(Long[] groupIds);
|
||||
|
||||
/**
|
||||
* 根据分组名称查询分组
|
||||
*
|
||||
* @param groupName 分组名称
|
||||
* @return 分组
|
||||
*/
|
||||
Group selectGroupByGroupName(String groupName);
|
||||
}
|
||||
|
|
@ -68,4 +68,11 @@ public class GroupDomainImpl implements IGroupDomain
|
|||
{
|
||||
return groupMapper.deleteGroupByGroupIds(groupIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Group selectGroupByGroupName(String groupName)
|
||||
{
|
||||
GroupEntity entity = groupMapper.selectGroupByGroupName(groupName);
|
||||
return GroupConvert.from(entity);
|
||||
}
|
||||
}
|
||||
|
|
@ -58,4 +58,12 @@ public interface GroupMapper
|
|||
* @return 影响行数
|
||||
*/
|
||||
int deleteGroupByGroupIds(Long[] groupIds);
|
||||
|
||||
/**
|
||||
* 根据分组名称查询分组
|
||||
*
|
||||
* @param groupName 分组名称
|
||||
* @return 分组信息
|
||||
*/
|
||||
GroupEntity selectGroupByGroupName(String groupName);
|
||||
}
|
||||
|
|
@ -63,6 +63,13 @@ public class GroupServiceImpl implements IGroupService
|
|||
@Override
|
||||
public int updateGroup(GroupDTO groupDTO)
|
||||
{
|
||||
// 校验分组名称是否已被其他分组使用
|
||||
Group existingGroup = groupDomain.selectGroupByGroupName(groupDTO.getGroupName());
|
||||
if (existingGroup != null && !existingGroup.getGroupId().equals(groupDTO.getGroupId()))
|
||||
{
|
||||
throw new RuntimeException("分组名称已存在: " + groupDTO.getGroupName());
|
||||
}
|
||||
|
||||
Group model = GroupDTOConvert.to(groupDTO);
|
||||
return groupDomain.updateGroup(model);
|
||||
}
|
||||
|
|
@ -82,6 +89,13 @@ public class GroupServiceImpl implements IGroupService
|
|||
@Override
|
||||
public Long createGroup(GroupDTO groupDTO)
|
||||
{
|
||||
// 校验分组名称是否已存在
|
||||
Group existingGroup = groupDomain.selectGroupByGroupName(groupDTO.getGroupName());
|
||||
if (existingGroup != null)
|
||||
{
|
||||
throw new RuntimeException("分组名称已存在: " + groupDTO.getGroupName());
|
||||
}
|
||||
|
||||
Group model = GroupDTOConvert.to(groupDTO);
|
||||
groupDomain.insertGroup(model);
|
||||
return model.getGroupId();
|
||||
|
|
|
|||
|
|
@ -25,6 +25,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
where group_id = #{groupId}
|
||||
</select>
|
||||
|
||||
<select id="selectGroupByGroupName" parameterType="String" resultMap="GroupResult">
|
||||
<include refid="selectGroupVo"/>
|
||||
where group_name = #{groupName}
|
||||
</select>
|
||||
|
||||
<select id="selectGroupList" parameterType="com.ruoyi.device.mapper.entity.GroupEntity" resultMap="GroupResult">
|
||||
<include refid="selectGroupVo"/>
|
||||
<where>
|
||||
|
|
|
|||
Loading…
Reference in New Issue