Commit b637e85d by guojuxing

角色删除接口修改:验证是否正在被使用,如果是,不能被删除

parent 4b5d53e8
......@@ -72,4 +72,14 @@ public interface TabSysUserRoleMapper {
* @return java.util.List<com.gic.auth.entity.TabSysUserRole>


 */
List<TabSysUserRole> listUserRoleByUserId(@Param("userId") Integer userId);
/**
* 根据角色查询用户角色
* @Title: listUserRoleByRoleId

* @Description:

 * @author guojuxing
* @param roleId

* @return java.util.List<com.gic.auth.entity.TabSysUserRole>


 */
List<TabSysUserRole> listUserRoleByRoleId(@Param("roleId") Integer roleId);
}
\ No newline at end of file
......@@ -43,4 +43,14 @@ public interface UserRoleService {
* @return java.util.List<com.gic.auth.entity.TabSysUserRole>


 */
List<UserRoleDTO> listUserRoleByUserId(Integer userId);
/**
* 根据角色查询用户角色关联数据
* @Title: listUserRoleByRoleId

* @Description:

 * @author guojuxing
* @param roleId

* @return java.util.List<com.gic.auth.entity.TabSysUserRole>


 */
List<TabSysUserRole> listUserRoleByRoleId(Integer roleId);
}
......@@ -36,4 +36,13 @@ public class UserRoleServiceImpl implements UserRoleService{
}
return new ArrayList<>();
}
@Override
public List<TabSysUserRole> listUserRoleByRoleId(Integer roleId) {
List<TabSysUserRole> list = tabSysUserRoleMapper.listUserRoleByRoleId(roleId);
if (CollectionUtils.isNotEmpty(list)) {
return list;
}
return new ArrayList<>();
}
}
......@@ -6,6 +6,8 @@ import java.util.List;
import com.gic.auth.dto.RoleListDTO;
import com.gic.auth.entity.TabSysRole;
import com.gic.auth.entity.TabSysUserRole;
import com.gic.auth.service.UserRoleService;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.PageHelperUtils;
import com.gic.enterprise.error.ErrorCode;
......@@ -32,6 +34,8 @@ public class RoleApiServiceImpl implements RoleApiService{
private RoleService roleService;
@Autowired
private MenuRoleService menuRoleService;
@Autowired
private UserRoleService userRoleService;
@Transactional(rollbackFor = Exception.class)
@Override
......@@ -103,6 +107,11 @@ public class RoleApiServiceImpl implements RoleApiService{
if (record == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "角色数据有误,查无数据");
}
//判断是否正在被用户使用
List<TabSysUserRole> userRoleList = userRoleService.listUserRoleByRoleId(id);
if (userRoleList.size() < 1) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "无法删除,正在被使用");
}
roleService.deleteById(id);
return ServiceResponse.success();
}
......
......@@ -128,4 +128,13 @@
where user_id = #{userId}
and status = 1
</select>
<select id="listUserRoleByRoleId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_sys_user_role
where role_id = #{userId}
and status = 1
</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