Commit 1a5dc491 by 陶光胜

Merge branch 'developer' of…

Merge branch 'developer' of http://115.159.76.241/base_platform_enterprise/gic-platform-auth into developer
parents 3bf2f913 c581c3b6
......@@ -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() > 0) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "无法删除,正在被使用");
}
roleService.deleteById(id);
return ServiceResponse.success();
}
......
......@@ -208,7 +208,7 @@ public class UserApiServiceImpl implements UserApiService {
}
ServiceResponse<String[]> userResourceIdValid = ValidSplitUtils.validStr(userResourceIds);
if (userResourceIdValid.isSuccess()) {
userResourceIdArr = userRoleValid.getResult();
userResourceIdArr = userResourceIdValid.getResult();
} else {
return ServiceResponse.failure(userResourceIdValid.getCode(), userResourceIdValid.getMessage());
}
......
......@@ -108,7 +108,7 @@
select
a.role_id roleId,
a.role_name roleName,
(select count(b.user_id) from tab_sys_user_role b where a.role_id = b.role_id and b.status = 1 group by b.user_id) authUserCount
(select count(DISTINCT b.user_id) from tab_sys_user_role b where a.role_id = b.role_id and b.status = 1 ) authUserCount
from tab_sys_role a
where a.status = 1
and a.enterprise_id = #{enterpriseId}
......
......@@ -220,7 +220,7 @@
a.phone_number phoneNumber,
a.phone_area_code phoneAreaCode,
(select GROUP_CONCAT(role_name separator '/') from tab_sys_role where role_id in (GROUP_CONCAT(b.role_id))) userRoleNames,
(select GROUP_CONCAT(resource_name separator '/') from tab_sys_resource where resource_id in (GROUP_CONCAT(c.resource_id))) userResourceNames
(select GROUP_CONCAT(d.resource_name separator '/') from tab_sys_resource d WHERE find_in_set( d.resource_Id , GROUP_CONCAT(c.resource_id)) ) userResourceNames
from tab_sys_user a
left join tab_sys_user_role b on a.user_id = b.user_id
left join tab_sys_user_resource c on a.user_id = c.user_id
......@@ -237,6 +237,8 @@
<if test="resourceId != null">
and c.resource_id = #{resourceId}
</if>
GROUP BY a.user_id
</select>
......
......@@ -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
package com.gic.auth.web.controller;
import com.gic.auth.service.MenuApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -19,6 +20,8 @@ public class RoleController {
@Autowired
private RoleApiService roleApiService;
@Autowired
private MenuApiService menuApiService;
@RequestMapping("/get-detail")
public RestResponse getDetail(Integer id) {
......
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