Commit aa145dfc by guojuxing

新增/编辑角色验证名称重复

parent 747a2c29
......@@ -77,4 +77,16 @@ public interface TabSysRoleMapper {
int deleteByRoleId(@Param("roleId") Integer roleId);
List<TabSysRole> listRoleNoPage(@Param("enterpriseId") Integer enterpriseId);
/**
* 查询数量根据名称
* @Title: countRepeatRoleName

* @Description:

 * @author guojuxing
* @param enterpriseId
* @param roleId
* @param roleName

* @return int


 */
int countRepeatRoleName(@Param("enterpriseId") Integer enterpriseId, @Param("roleId") Integer roleId, @Param("roleName") String roleName);
}
\ No newline at end of file
......@@ -68,4 +68,16 @@ public interface RoleService {
* @return java.util.List<com.gic.auth.entity.TabSysRole>


 */
List<TabSysRole> listRole(Integer enterpriseId);
/**
* 权限名称是否重复
* @Title: isRepeatRoleName

* @Description:

 * @author guojuxing
* @param enterpriseId
* @param roleId
* @param roleName

* @return boolean


 */
boolean isRepeatRoleName(Integer enterpriseId, Integer roleId, String roleName);
}
......@@ -58,4 +58,13 @@ public class RoleServiceImpl implements RoleService{
public List<TabSysRole> listRole(Integer enterpriseId) {
return tabSysRoleMapper.listRoleNoPage(enterpriseId);
}
@Override
public boolean isRepeatRoleName(Integer enterpriseId, Integer roleId, String roleName) {
int count = tabSysRoleMapper.countRepeatRoleName(enterpriseId, roleId, roleName);
if (count > 0) {
return true;
}
return false;
}
}
......@@ -48,6 +48,11 @@ public class RoleApiServiceImpl implements RoleApiService{
dto.setCreateTime(new Date());
dto.setStatus(1);
//验证名称不能重复
if (roleService.isRepeatRoleName(dto.getEnterpriseId(), null, dto.getRoleName())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "权限名称重复");
}
Integer roleId = roleService.save(dto);
//删除之前的角色菜单数据
......@@ -72,6 +77,11 @@ public class RoleApiServiceImpl implements RoleApiService{
return paramValid;
}
//验证名称不能重复
if (roleService.isRepeatRoleName(record.getEnterpriseId(), dto.getRoleId(), dto.getRoleName())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "权限名称重复");
}
roleService.update(dto);
//删除之前的角色菜单数据
menuRoleService.deleteByRoleId(dto.getRoleId());
......
......@@ -130,4 +130,15 @@
where status = 1
and enterprise_id = #{enterpriseId}
</select>
<select id="countRepeatRoleName" resultType="int">
select count(1) from tab_sys_role
where status = 1
<if test="roleId != null">
and role_id <![CDATA[ <> ]]> #{roleId}
</if>
and enterprise_id = #{enterpriseId}
and role_name = #{roleName}
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment