部门角色变更:取消从people对接, 沿用系统之前的组织角色用户关系
This commit is contained in:
+4
@@ -19,6 +19,8 @@ import com.jero.modules.system.model.DepartIdModel;
|
||||
import com.jero.modules.system.service.ISysDepartService;
|
||||
import com.jero.modules.system.service.ISysUserDepartService;
|
||||
import com.jero.modules.system.service.ISysUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
@@ -53,6 +55,7 @@ import java.util.*;
|
||||
@RestController
|
||||
@RequestMapping("/sys/sysDepart")
|
||||
@Slf4j
|
||||
@Api(tags = "部门管理")
|
||||
public class SysDepartController {
|
||||
|
||||
@Autowired
|
||||
@@ -94,6 +97,7 @@ public class SysDepartController {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "部门管理-查询树状结构")
|
||||
@RequiresPermissions("sys:depart:list")
|
||||
@RequestMapping(value = "/queryTreeList", method = RequestMethod.GET)
|
||||
public Result<List<SysDepartTreeModel>> queryTreeList() {
|
||||
|
||||
+4
@@ -16,6 +16,8 @@ import com.jero.modules.system.service.ISysPermissionDataRuleService;
|
||||
import com.jero.modules.system.service.ISysPermissionService;
|
||||
import com.jero.modules.system.service.ISysRolePermissionService;
|
||||
import com.jero.modules.system.service.ISysRoleService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
@@ -46,6 +48,7 @@ import java.util.*;
|
||||
@RestController
|
||||
@RequestMapping("/sys/role")
|
||||
@Slf4j
|
||||
@Api(tags = "角色管理")
|
||||
public class SysRoleController {
|
||||
@Autowired
|
||||
private ISysRoleService sysRoleService;
|
||||
@@ -67,6 +70,7 @@ public class SysRoleController {
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "角色管理-分页查询")
|
||||
@RequiresPermissions("sys:role:list")
|
||||
@RequestMapping(value = "/page", method = RequestMethod.GET)
|
||||
public Result<IPage<SysRole>> queryPageList(SysRole role,
|
||||
|
||||
+2
-21
@@ -188,25 +188,7 @@ public class SysUserController {
|
||||
user.setPassword(sysUser.getPassword());
|
||||
String roles = jsonObject.getString("selectedroles");
|
||||
String departs = jsonObject.getString("selecteddeparts");
|
||||
List<SysDepartRole> departRoleList = departRoleService.queryByDepartId(departs);
|
||||
List<String> roleIdList = departRoleList.stream()
|
||||
.map(SysDepartRole::getRoleId)
|
||||
.collect(Collectors.toList());
|
||||
String[] targetRoleIdList = roles.split(",");
|
||||
List<String> droleIdList = new ArrayList<>();
|
||||
for(int i = 0; i < targetRoleIdList.length; i++){
|
||||
String targetRoleId = targetRoleIdList[i];
|
||||
if(!roleIdList.contains(targetRoleId)){
|
||||
return result.error500("存在不是用户部门下的角色");
|
||||
}
|
||||
List<String> droleIds = departRoleList.stream()
|
||||
.filter(e->e.getRoleId().equals(targetRoleId))
|
||||
.map(SysDepartRole::getId)
|
||||
.collect(Collectors.toList());
|
||||
droleIdList.addAll(droleIds);
|
||||
}
|
||||
droleIdList = droleIdList.stream().distinct().collect(Collectors.toList());
|
||||
sysUserService.editUserWithRole(user, droleIdList);
|
||||
sysUserService.editUserWithRole(user, roles);
|
||||
// 不允许修改部门
|
||||
// sysUserService.editUserWithDepart(user, departs);
|
||||
sysUserService.updateNullPhoneEmail();
|
||||
@@ -366,8 +348,7 @@ public class SysUserController {
|
||||
public Result<List<DepartIdModel>> getUserDepartsList(@RequestParam(name = "userId", required = true) String userId) {
|
||||
Result<List<DepartIdModel>> result = new Result<>();
|
||||
try {
|
||||
// List<DepartIdModel> depIdModelList = this.sysUserDepartService.queryDepartIdsOfUser(userId);
|
||||
List<DepartIdModel> depIdModelList = this.sysUserService.getDepIdsByUserId(userId);
|
||||
List<DepartIdModel> depIdModelList = this.sysUserDepartService.queryDepartIdsOfUser(userId);
|
||||
if (depIdModelList != null && depIdModelList.size() > 0) {
|
||||
result.setSuccess(true);
|
||||
result.setMessage("查找成功");
|
||||
|
||||
+18
-15
@@ -3,33 +3,36 @@
|
||||
<mapper namespace="com.jero.modules.system.mapper.SysDepartMapper">
|
||||
|
||||
<select id="queryUserDeparts" parameterType="String" resultType="com.jero.modules.system.entity.SysDepart">
|
||||
select d.*
|
||||
from sys_depart d, sys_depart_role_user dru, sys_depart_role dr
|
||||
WHERE d.id = dr.depart_id
|
||||
and dr.id = dru.drole_id
|
||||
and dru.user_id = #{userId}
|
||||
select *
|
||||
from sys_depart
|
||||
where id IN (
|
||||
select dep_id
|
||||
from sys_user_depart
|
||||
where user_id = #{userId}
|
||||
)
|
||||
</select>
|
||||
|
||||
<!-- 根据username查询所拥有的部门 -->
|
||||
<select id="queryDepartsByUsername" parameterType="String" resultType="com.jero.modules.system.entity.SysDepart">
|
||||
select d.*
|
||||
from sys_depart d, sys_depart_role_user dru, sys_depart_role dr
|
||||
WHERE d.id = dr.depart_id
|
||||
and dr.id = dru.drole_id
|
||||
and dru.user_id in (
|
||||
SELECT *
|
||||
FROM sys_depart
|
||||
WHERE id IN (
|
||||
SELECT dep_id
|
||||
FROM sys_user_depart
|
||||
WHERE user_id = (
|
||||
SELECT id
|
||||
FROM sys_user
|
||||
WHERE username = #{username}
|
||||
)
|
||||
)
|
||||
</select>
|
||||
|
||||
<!-- 根据部门Id查询,当前和下级所有部门IDS -->
|
||||
<select id="getSubDepIdsByDepId" resultType="java.lang.String">
|
||||
SELECT sd.id
|
||||
FROM sys_depart sd,( SELECT ( @nodes := queryChildrenTempNode (#{departId})) AS pids ) t
|
||||
WHERE
|
||||
FIND_IN_SET( sd.id, t.pids )
|
||||
AND del_flag = 0
|
||||
select id
|
||||
from sys_depart
|
||||
where del_flag = '0'
|
||||
and org_code like concat((select org_code from sys_depart where id=#{departId}),'%')
|
||||
</select>
|
||||
|
||||
<!--根据部门编码获取我的部门下所有部门ids -->
|
||||
|
||||
+3
-2
@@ -38,8 +38,9 @@
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
<!-- join sys_role b on a.role_id = b.id
|
||||
join sys_user_role c on c.role_id = b.id -->
|
||||
|
||||
<!--join sys_role b on a.role_id = b.id
|
||||
join sys_user_role c on c.role_id = b.id-->
|
||||
<!-- 获取登录用户拥有的权限 -->
|
||||
<select id="queryByUser" parameterType="Object" resultMap="SysPermission">
|
||||
SELECT * FROM (
|
||||
|
||||
+6
-18
@@ -26,17 +26,7 @@
|
||||
|
||||
<!-- 查询用户的所属部门名称信息 -->
|
||||
<select id="getDepNamesByUserIds" resultType="com.jero.modules.system.vo.SysUserDepVo">
|
||||
SELECT distinct
|
||||
d.depart_name,
|
||||
dru.user_id
|
||||
FROM
|
||||
sys_depart_role_user dru,
|
||||
sys_depart_role dr,
|
||||
sys_depart d
|
||||
WHERE
|
||||
d.id = dr.depart_id
|
||||
and dr.id = dru.drole_id
|
||||
and dru.user_id in
|
||||
select d.depart_name,ud.user_id from sys_user_depart ud,sys_depart d where d.id = ud.dep_id and ud.user_id in
|
||||
<foreach collection="userIds" index="index" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
@@ -48,20 +38,18 @@
|
||||
d.depart_name departName,
|
||||
d.id id
|
||||
FROM
|
||||
sys_depart_role_user dru,
|
||||
sys_depart_role dr,
|
||||
sys_user_depart ud,
|
||||
sys_depart d
|
||||
WHERE
|
||||
d.id = dr.depart_id
|
||||
and dr.id = dru.drole_id
|
||||
and dru.user_id = #{userId}
|
||||
d.id = ud.dep_id
|
||||
and ud.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<!-- 通过多个部门IDS,查询部门下的用户信息 -->
|
||||
<select id="getUserByDepIds" resultType="com.jero.modules.system.entity.SysUser">
|
||||
select * from sys_user where del_flag = 0
|
||||
<if test="departIds!=null and departIds.size()>0">
|
||||
and id in (select dru.user_id from sys_depart_role dr, sys_depart_role_user dru where dr.id = dru.drole_id and dr.depart_id in
|
||||
and id in (select user_id from sys_user_depart where dep_id in
|
||||
<foreach collection="departIds" index="index" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
@@ -76,7 +64,7 @@
|
||||
<select id="getUserListByDepIds" resultType="com.jero.modules.system.entity.SysUser">
|
||||
select * from sys_user where del_flag = 0
|
||||
<if test="departIds!=null and departIds.size()>0">
|
||||
and id in (select dru.user_id from sys_depart_role dr, sys_depart_role_user dru where dr.id = dru.drole_id and dr.depart_id in
|
||||
and id in (select user_id from sys_user_depart where dep_id in
|
||||
<foreach collection="departIds" index="index" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
|
||||
-2
@@ -21,6 +21,4 @@ public interface ISysDepartRoleService extends IService<SysDepartRole> {
|
||||
*/
|
||||
List<SysDepartRole> queryDeptRoleByDeptAndUser(String orgCode, String userId);
|
||||
|
||||
List<SysDepartRole> queryByDepartId(String departIds);
|
||||
|
||||
}
|
||||
|
||||
+1
-2
@@ -74,7 +74,7 @@ public interface ISysUserService extends IService<SysUser> {
|
||||
* @param user
|
||||
* @param roles
|
||||
*/
|
||||
public void editUserWithRole(SysUser user,List<String> droleIdList);
|
||||
public void editUserWithRole(SysUser user,String roles);
|
||||
|
||||
/**
|
||||
* 获取用户的授权角色
|
||||
@@ -119,7 +119,6 @@ public interface ISysUserService extends IService<SysUser> {
|
||||
*/
|
||||
public Map<String,String> getDepNamesByUserIds(List<String> userIds);
|
||||
|
||||
public List<DepartIdModel> getDepIdsByUserId(String userId);
|
||||
/**
|
||||
* 根据部门 Id 和 QueryWrapper 查询
|
||||
*
|
||||
|
||||
-5
@@ -24,9 +24,4 @@ public class SysDepartRoleServiceImpl extends ServiceImpl<SysDepartRoleMapper, S
|
||||
return this.baseMapper.queryDeptRoleByDeptAndUser(orgCode,userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDepartRole> queryByDepartId(String departIds){
|
||||
List<String> deoartIdList = StringUtils.stringToList(departIds);
|
||||
return this.list(new QueryWrapper<SysDepartRole>().lambda().in(SysDepartRole::getDepartId, deoartIdList));
|
||||
}
|
||||
}
|
||||
|
||||
+7
-26
@@ -136,24 +136,17 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
@Override
|
||||
@CacheEvict(value= {CacheConstant.SYS_USERS_CACHE}, allEntries=true)
|
||||
@Transactional
|
||||
public void editUserWithRole(SysUser user,List<String> droleIdList) {
|
||||
public void editUserWithRole(SysUser user,String roles) {
|
||||
this.updateById(user);
|
||||
//先删后加
|
||||
departRoleUserMapper.delete(new QueryWrapper<SysDepartRoleUser>().lambda().eq(SysDepartRoleUser::getUserId, user.getId()));
|
||||
if(CollectionUtil.isNotEmpty(droleIdList)) {
|
||||
for (String droleId : droleIdList) {
|
||||
SysDepartRoleUser departRoleUser = new SysDepartRoleUser(user.getId(), droleId);
|
||||
departRoleUserMapper.insert(departRoleUser);
|
||||
sysUserRoleMapper.delete(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, user.getId()));
|
||||
if(oConvertUtils.isNotEmpty(roles)) {
|
||||
String[] arr = roles.split(",");
|
||||
for (String roleId : arr) {
|
||||
SysUserRole userRole = new SysUserRole(user.getId(), roleId);
|
||||
sysUserRoleMapper.insert(userRole);
|
||||
}
|
||||
}
|
||||
// sysUserRoleMapper.delete(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, user.getId()));
|
||||
// if(oConvertUtils.isNotEmpty(roles)) {
|
||||
// String[] arr = roles.split(",");
|
||||
// for (String roleId : arr) {
|
||||
// SysUserRole userRole = new SysUserRole(user.getId(), roleId);
|
||||
// sysUserRoleMapper.insert(userRole);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -265,18 +258,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DepartIdModel> getDepIdsByUserId(String userId) {
|
||||
List<SysDepart> departList = this.baseMapper.getDepIdsByUserId(userId);
|
||||
List<DepartIdModel> depIdModelList = new ArrayList<>();
|
||||
if(departList != null || departList.size() > 0) {
|
||||
for(SysDepart depart : departList) {
|
||||
depIdModelList.add(new DepartIdModel().convertByUserDepart(depart));
|
||||
}
|
||||
}
|
||||
return depIdModelList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<SysUser> getUserByDepartIdAndQueryWrapper(Page<SysUser> page, String departId, QueryWrapper<SysUser> queryWrapper) {
|
||||
LambdaQueryWrapper<SysUser> lambdaQueryWrapper = queryWrapper.lambda();
|
||||
|
||||
Reference in New Issue
Block a user