新增部门用户选择时,角色条件筛选
增加角色部门用户列表的相关接口与实现方法
This commit is contained in:
parent
e09dab48ed
commit
ddfe612c8e
@ -1,6 +1,8 @@
|
|||||||
package ink.wgink.interfaces.role;
|
package ink.wgink.interfaces.role;
|
||||||
|
|
||||||
|
import ink.wgink.pojo.ListPage;
|
||||||
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -32,4 +34,13 @@ public interface IRoleDepartmentUserBaseService {
|
|||||||
*/
|
*/
|
||||||
List<DepartmentUserDTO> listUserByDepartmentIdAndRoleId(String departmentId, String roleId);
|
List<DepartmentUserDTO> listUserByDepartmentIdAndRoleId(String departmentId, String roleId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户分页列表
|
||||||
|
*
|
||||||
|
* @param departmentId 部门ID
|
||||||
|
* @param roleId 角色ID
|
||||||
|
* @param page 分页参数
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
SuccessResultList<List<DepartmentUserDTO>> listPageUserByDepartmentIdAndRoleId(String departmentId, String roleId, ListPage page);
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,16 @@ public interface IUserBaseService {
|
|||||||
*/
|
*/
|
||||||
SuccessResultList<List<UserDTO>> listPageByExcludeIds(List<String> excludeUserIds, ListPage page);
|
SuccessResultList<List<UserDTO>> listPageByExcludeIds(List<String> excludeUserIds, ListPage page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不包含与包含的用户分页列表
|
||||||
|
*
|
||||||
|
* @param excludeUserIds 不包含用户id列表
|
||||||
|
* @param includeUserIds 包含的用户id列表
|
||||||
|
* @param page
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
SuccessResultList<List<UserDTO>> listPageByExcludeIdsAndIncludeIds(List<String> excludeUserIds, List<String> includeUserIds, ListPage page);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 不包含的用户分页列表
|
* 不包含的用户分页列表
|
||||||
*
|
*
|
||||||
@ -104,6 +114,16 @@ public interface IUserBaseService {
|
|||||||
*/
|
*/
|
||||||
List<UserDTO> listByExcludeIds(List<String> excludeUserIds, Map<String, Object> params);
|
List<UserDTO> listByExcludeIds(List<String> excludeUserIds, Map<String, Object> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不包含和包含的用户分页列表
|
||||||
|
*
|
||||||
|
* @param excludeUserIds 不包含用户ID列表
|
||||||
|
* @param includeUserIds 包含用户ID列表
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<UserDTO> listByExcludeIds(List<String> excludeUserIds, List<String> includeUserIds, Map<String, Object> params);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户统计
|
* 用户统计
|
||||||
@ -167,4 +187,5 @@ public interface IUserBaseService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<String> listUserIds(List<UserDTO> userDTOs);
|
List<String> listUserIds(List<UserDTO> userDTOs);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package ink.wgink.login.oauth2.client.remote.role;
|
||||||
|
|
||||||
|
import ink.wgink.annotation.rpc.rest.RemoteService;
|
||||||
|
import ink.wgink.annotation.rpc.rest.method.RemoteGetMethod;
|
||||||
|
import ink.wgink.annotation.rpc.rest.params.RemotePathParams;
|
||||||
|
import ink.wgink.annotation.rpc.rest.params.RemoteQueryParams;
|
||||||
|
import ink.wgink.annotation.rpc.rest.params.RemoteQueryParamsMap;
|
||||||
|
import ink.wgink.annotation.rpc.rest.params.RemoteServerParams;
|
||||||
|
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: IRoleDepartmentUserRemoteService
|
||||||
|
* @Description: 角色部门用户列表
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2022/1/4 6:33 PM
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@RemoteService("/resource/role/department/user")
|
||||||
|
public interface IRoleDepartmentUserRemoteService {
|
||||||
|
|
||||||
|
@RemoteGetMethod("listpage-user/{departmentId}/{roleId}")
|
||||||
|
SuccessResultList<List<DepartmentUserDTO>> listPageUserByDepartmentIdAndRoleId(@RemoteServerParams String userCenter, @RemoteQueryParams("access_token") String accessToken, @RemotePathParams("departmentId") String departmentId, @RemotePathParams("roleId") String roleId, @RemoteQueryParams("page") int page, @RemoteQueryParams("page") int rows, @RemoteQueryParamsMap Map<String, Object> params);
|
||||||
|
|
||||||
|
}
|
@ -3,10 +3,15 @@ package ink.wgink.login.oauth2.client.service.role.impl;
|
|||||||
import ink.wgink.common.base.DefaultBaseService;
|
import ink.wgink.common.base.DefaultBaseService;
|
||||||
import ink.wgink.interfaces.department.IDepartmentBaseService;
|
import ink.wgink.interfaces.department.IDepartmentBaseService;
|
||||||
import ink.wgink.interfaces.department.IDepartmentUserBaseService;
|
import ink.wgink.interfaces.department.IDepartmentUserBaseService;
|
||||||
|
import ink.wgink.login.oauth2.client.remote.role.IRoleDepartmentUserRemoteService;
|
||||||
import ink.wgink.login.oauth2.client.service.role.IRoleDepartmentUserService;
|
import ink.wgink.login.oauth2.client.service.role.IRoleDepartmentUserService;
|
||||||
import ink.wgink.login.oauth2.client.service.role.IRoleUserService;
|
import ink.wgink.login.oauth2.client.service.role.IRoleUserService;
|
||||||
|
import ink.wgink.module.oauth2.manager.OAuth2ClientTokenManager;
|
||||||
|
import ink.wgink.pojo.ListPage;
|
||||||
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
||||||
import ink.wgink.pojo.pos.DepartmentPO;
|
import ink.wgink.pojo.pos.DepartmentPO;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
|
import ink.wgink.properties.ApiPathProperties;
|
||||||
import ink.wgink.util.ArrayListUtil;
|
import ink.wgink.util.ArrayListUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -25,14 +30,16 @@ import java.util.List;
|
|||||||
@Service
|
@Service
|
||||||
public class RoleDepartmentUserServiceImpl extends DefaultBaseService implements IRoleDepartmentUserService {
|
public class RoleDepartmentUserServiceImpl extends DefaultBaseService implements IRoleDepartmentUserService {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private IRoleUserService userService;
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IRoleUserService roleUserService;
|
private IRoleUserService roleUserService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IDepartmentBaseService departmentBaseService;
|
private IDepartmentBaseService departmentBaseService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IDepartmentUserBaseService departmentUserBaseService;
|
private IDepartmentUserBaseService departmentUserBaseService;
|
||||||
|
@Autowired
|
||||||
|
private IRoleDepartmentUserRemoteService roleDepartmentUserRemoteService;
|
||||||
|
@Autowired
|
||||||
|
private ApiPathProperties apiPathProperties;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DepartmentUserDTO> listUserByRoleIdAndAreaCode(String roleId, String areaCode) {
|
public List<DepartmentUserDTO> listUserByRoleIdAndAreaCode(String roleId, String areaCode) {
|
||||||
@ -68,6 +75,11 @@ public class RoleDepartmentUserServiceImpl extends DefaultBaseService implements
|
|||||||
return departmentUserDTOs;
|
return departmentUserDTOs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SuccessResultList<List<DepartmentUserDTO>> listPageUserByDepartmentIdAndRoleId(String departmentId, String roleId, ListPage page) {
|
||||||
|
return roleDepartmentUserRemoteService.listPageUserByDepartmentIdAndRoleId(apiPathProperties.getUserCenter(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), departmentId, roleId, page.getPage(), page.getRows(), page.getParams());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清除没有角色的用户
|
* 清除没有角色的用户
|
||||||
*
|
*
|
||||||
|
@ -86,12 +86,26 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService
|
|||||||
return userRemoteService.listPage(apiPathProperties.getUserCenter(), page.getPage(), page.getRows(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), page.getParams());
|
return userRemoteService.listPage(apiPathProperties.getUserCenter(), page.getPage(), page.getRows(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), page.getParams());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SuccessResultList<List<UserDTO>> listPageByExcludeIdsAndIncludeIds(List<String> excludeUserIds, List<String> includeUserIds, ListPage page) {
|
||||||
|
page.getParams().put("excludeUserIds", excludeUserIds);
|
||||||
|
page.getParams().put("userIds", includeUserIds);
|
||||||
|
return userRemoteService.listPage(apiPathProperties.getUserCenter(), page.getPage(), page.getRows(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), page.getParams());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<UserDTO> listByExcludeIds(List<String> excludeUserIds, Map<String, Object> params) {
|
public List<UserDTO> listByExcludeIds(List<String> excludeUserIds, Map<String, Object> params) {
|
||||||
params.put("excludeUserIds", excludeUserIds);
|
params.put("excludeUserIds", excludeUserIds);
|
||||||
return userRemoteService.list(apiPathProperties.getUserCenter(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), params);
|
return userRemoteService.list(apiPathProperties.getUserCenter(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UserDTO> listByExcludeIds(List<String> excludeUserIds, List<String> includeUserIds, Map<String, Object> params) {
|
||||||
|
params.put("excludeUserIds", excludeUserIds);
|
||||||
|
params.put("userIds", excludeUserIds);
|
||||||
|
return userRemoteService.list(apiPathProperties.getUserCenter(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), params);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int countDateRange(String startDate, String endDate) {
|
public int countDateRange(String startDate, String endDate) {
|
||||||
SuccessResultData<Integer> successResultData = userRemoteService.countDateRange(apiPathProperties.getUserCenter(), startDate, endDate, OAuth2ClientTokenManager.getInstance().getToken().getAccessToken());
|
SuccessResultData<Integer> successResultData = userRemoteService.countDateRange(apiPathProperties.getUserCenter(), startDate, endDate, OAuth2ClientTokenManager.getInstance().getToken().getAccessToken());
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package ink.wgink.service.department.controller.route;
|
package ink.wgink.service.department.controller.route;
|
||||||
|
|
||||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||||
|
import ink.wgink.interfaces.role.IRoleBaseService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@ -22,6 +24,9 @@ import org.springframework.web.servlet.ModelAndView;
|
|||||||
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/department/user")
|
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/department/user")
|
||||||
public class DepartmentUserRouteController {
|
public class DepartmentUserRouteController {
|
||||||
|
|
||||||
|
@Autowired(required = false)
|
||||||
|
private IRoleBaseService roleBaseService;
|
||||||
|
|
||||||
@GetMapping("list")
|
@GetMapping("list")
|
||||||
public ModelAndView list() {
|
public ModelAndView list() {
|
||||||
return new ModelAndView("department/user/list");
|
return new ModelAndView("department/user/list");
|
||||||
@ -29,7 +34,9 @@ public class DepartmentUserRouteController {
|
|||||||
|
|
||||||
@GetMapping("select-user")
|
@GetMapping("select-user")
|
||||||
public ModelAndView selectUser() {
|
public ModelAndView selectUser() {
|
||||||
return new ModelAndView("department/user/select-user");
|
ModelAndView modelAndView = new ModelAndView("department/user/select-user");
|
||||||
|
modelAndView.addObject("hasRoleService", (roleBaseService != null));
|
||||||
|
return modelAndView;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,9 @@ package ink.wgink.service.department.service;
|
|||||||
import ink.wgink.interfaces.department.IDepartmentUserBaseService;
|
import ink.wgink.interfaces.department.IDepartmentUserBaseService;
|
||||||
import ink.wgink.pojo.dtos.department.DepartmentSimpleDTO;
|
import ink.wgink.pojo.dtos.department.DepartmentSimpleDTO;
|
||||||
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
||||||
|
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||||
import ink.wgink.pojo.pos.DepartmentPO;
|
import ink.wgink.pojo.pos.DepartmentPO;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
import ink.wgink.service.department.pojo.vos.DepartmentUserSortVO;
|
import ink.wgink.service.department.pojo.vos.DepartmentUserSortVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -71,6 +73,14 @@ public interface IDepartmentUserService extends IDepartmentUserBaseService {
|
|||||||
*/
|
*/
|
||||||
void updateSort(String departmentId, DepartmentUserSortVO departmentUserSortVO);
|
void updateSort(String departmentId, DepartmentUserSortVO departmentUserSortVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param departmentId
|
||||||
|
* @param userIds
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<DepartmentUserDTO> listByDepartmentIdAndUserIds(String departmentId, List<String> userIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门列表
|
* 部门列表
|
||||||
*
|
*
|
||||||
@ -95,4 +105,30 @@ public interface IDepartmentUserService extends IDepartmentUserBaseService {
|
|||||||
*/
|
*/
|
||||||
List<DepartmentUserDTO> listWithUser(Map<String, Object> params);
|
List<DepartmentUserDTO> listWithUser(Map<String, Object> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机构用户分页列表
|
||||||
|
*
|
||||||
|
* @param successResultList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
SuccessResultList<List<DepartmentUserDTO>> listPageExcludeDepartmentUser(SuccessResultList<List<UserDTO>> successResultList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机构用户分页列表
|
||||||
|
*
|
||||||
|
* @param userDTOs
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<DepartmentUserDTO> listExcludeDepartmentUser(List<UserDTO> userDTOs);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机构用户分页列表
|
||||||
|
*
|
||||||
|
* @param successResultList
|
||||||
|
* @param hasDepartmentUsers
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
SuccessResultList<List<DepartmentUserDTO>> listPageDepartmentUser(SuccessResultList<List<UserDTO>> successResultList, List<DepartmentUserDTO> hasDepartmentUsers);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -168,6 +168,14 @@ public class DepartmentUserServiceImpl extends DefaultBaseService implements IDe
|
|||||||
return list(params);
|
return list(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DepartmentUserDTO> listByDepartmentIdAndUserIds(String departmentId, List<String> userIds) {
|
||||||
|
Map<String, Object> params = getHashMap(2);
|
||||||
|
params.put("departmentId", departmentId);
|
||||||
|
params.put("userIds", userIds);
|
||||||
|
return list(params);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DepartmentUserDTO> list(List<String> departmentIds) {
|
public List<DepartmentUserDTO> list(List<String> departmentIds) {
|
||||||
Map<String, Object> params = getHashMap(2);
|
Map<String, Object> params = getHashMap(2);
|
||||||
@ -304,26 +312,16 @@ public class DepartmentUserServiceImpl extends DefaultBaseService implements IDe
|
|||||||
return listDepartmentUser(userDTOs, hasDepartmentUsers);
|
return listDepartmentUser(userDTOs, hasDepartmentUsers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* 机构用户分页列表
|
public SuccessResultList<List<DepartmentUserDTO>> listPageExcludeDepartmentUser(SuccessResultList<List<UserDTO>> successResultList) {
|
||||||
*
|
|
||||||
* @param successResultList
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private SuccessResultList<List<DepartmentUserDTO>> listPageExcludeDepartmentUser(SuccessResultList<List<UserDTO>> successResultList) {
|
|
||||||
// 查询用户排序
|
// 查询用户排序
|
||||||
List<UserDTO> userDTOs = successResultList.getRows();
|
List<UserDTO> userDTOs = successResultList.getRows();
|
||||||
List<DepartmentUserDTO> departmentUserDTOs = listExcludeDepartmentUser(userDTOs);
|
List<DepartmentUserDTO> departmentUserDTOs = listExcludeDepartmentUser(userDTOs);
|
||||||
return new SuccessResultList<>(departmentUserDTOs, successResultList.getPage(), successResultList.getTotal());
|
return new SuccessResultList<>(departmentUserDTOs, successResultList.getPage(), successResultList.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* 机构用户分页列表
|
public List<DepartmentUserDTO> listExcludeDepartmentUser(List<UserDTO> userDTOs) {
|
||||||
*
|
|
||||||
* @param userDTOs
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private List<DepartmentUserDTO> listExcludeDepartmentUser(List<UserDTO> userDTOs) {
|
|
||||||
// 查询用户排序
|
// 查询用户排序
|
||||||
List<DepartmentUserDTO> departmentUserDTOs = new ArrayList<>();
|
List<DepartmentUserDTO> departmentUserDTOs = new ArrayList<>();
|
||||||
for (UserDTO userDTO : userDTOs) {
|
for (UserDTO userDTO : userDTOs) {
|
||||||
@ -335,14 +333,8 @@ public class DepartmentUserServiceImpl extends DefaultBaseService implements IDe
|
|||||||
return departmentUserDTOs;
|
return departmentUserDTOs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* 机构用户分页列表
|
public SuccessResultList<List<DepartmentUserDTO>> listPageDepartmentUser(SuccessResultList<List<UserDTO>> successResultList, List<DepartmentUserDTO> hasDepartmentUsers) {
|
||||||
*
|
|
||||||
* @param successResultList
|
|
||||||
* @param hasDepartmentUsers
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private SuccessResultList<List<DepartmentUserDTO>> listPageDepartmentUser(SuccessResultList<List<UserDTO>> successResultList, List<DepartmentUserDTO> hasDepartmentUsers) {
|
|
||||||
// 查询用户排序
|
// 查询用户排序
|
||||||
List<UserDTO> userDTOs = successResultList.getRows();
|
List<UserDTO> userDTOs = successResultList.getRows();
|
||||||
List<DepartmentUserDTO> departmentUserDTOs = listDepartmentUser(userDTOs, hasDepartmentUsers);
|
List<DepartmentUserDTO> departmentUserDTOs = listDepartmentUser(userDTOs, hasDepartmentUsers);
|
||||||
|
@ -10,9 +10,21 @@
|
|||||||
<link rel="stylesheet" type="text/css" href="assets/js/vendor/zTree3/css/metroStyle/metroStyle.css"/>
|
<link rel="stylesheet" type="text/css" href="assets/js/vendor/zTree3/css/metroStyle/metroStyle.css"/>
|
||||||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||||
<style>
|
<style th:if="${hasRoleService eq true}">
|
||||||
.user-search {width: 188px !important; display: inline;}
|
.user-search {width: 188px !important; display: inline;}
|
||||||
|
.user-search-role {width: 105px !important; display: inline;}
|
||||||
.user-selected {border-left: 2px solid #009688 !important;}
|
.user-selected {border-left: 2px solid #009688 !important;}
|
||||||
|
.user-selected-avatar {float: left; margin: 5px; width: 40px !important; height: 40px !important;}
|
||||||
|
.user-selected-span {float:left; display: block; width: 120px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
|
||||||
|
.tree-title {margin: 0px 2px 0px 4px; padding: 7px 5px 7px 5px; background: #f1f1f1; font-weight: bold;}
|
||||||
|
</style>
|
||||||
|
<style th:if="${hasRoleService eq false}">
|
||||||
|
.user-search {width: 188px !important; display: inline;}
|
||||||
|
.user-search-role {width: 188px !important; display: inline;}
|
||||||
|
.user-selected {border-left: 2px solid #009688 !important;}
|
||||||
|
.user-selected-avatar {float: left; margin: 5px; width: 40px !important; height: 40px !important;}
|
||||||
|
.user-selected-span {float:left; display: block; width: 188px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
|
||||||
|
.tree-title {margin: 0px 2px 0px 4px; padding: 7px 5px 7px 5px; background: #f1f1f1; font-weight: bold;}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -25,15 +37,42 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-row">
|
<div class="layui-row">
|
||||||
<div class="layui-col-xs5">
|
<div class="layui-col-xs3" th:if="${hasRoleService eq true}">
|
||||||
|
<div class="tree-title">角色树</div>
|
||||||
<div class="selector-tree-wrapper">
|
<div class="selector-tree-wrapper">
|
||||||
<ul id="leftTree" class="ztree"></ul>
|
<ul id="roleTree" class="ztree"></ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-col-xs7">
|
<div class="layui-col-xs4" th:if="${hasRoleService eq true}">
|
||||||
|
<div class="tree-title">组织机构树</div>
|
||||||
|
<div class="selector-tree-wrapper">
|
||||||
|
<ul id="departmentTree" class="ztree"></ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-xs5" th:if="${hasRoleService eq false}">
|
||||||
|
<div class="tree-title">组织机构树</div>
|
||||||
|
<div class="selector-tree-wrapper">
|
||||||
|
<ul id="departmentTree" class="ztree"></ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-xs5" th:if="${hasRoleService eq true}">
|
||||||
<div class="selector-body-wrapper">
|
<div class="selector-body-wrapper">
|
||||||
<div class="selector-body-search">
|
<div class="selector-body-search">
|
||||||
<input type="text" id="searchUser" class="layui-input user-search" placeholder="快捷检索当前列表"/>
|
<input type="text" id="searchUser" class="layui-input user-search-role" placeholder="快捷检索当前列表"/>
|
||||||
|
<div class="layui-btn-group">
|
||||||
|
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-click-select-all-user>全选</button>
|
||||||
|
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-click-clear-all-user>清空</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="users" class="selector-body-content list-group">
|
||||||
|
<div id="userWrapper"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-xs7" th:if="${hasRoleService eq false}">
|
||||||
|
<div class="selector-body-wrapper">
|
||||||
|
<div class="selector-body-search">
|
||||||
|
<input type="text" id="searchUser" class="layui-input user-search-role" placeholder="快捷检索当前列表"/>
|
||||||
<div class="layui-btn-group">
|
<div class="layui-btn-group">
|
||||||
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-click-select-all-user>全选</button>
|
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-click-select-all-user>全选</button>
|
||||||
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-click-clear-all-user>清空</button>
|
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-click-clear-all-user>清空</button>
|
||||||
@ -57,7 +96,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||||
<script>
|
<script th:inline="javascript">
|
||||||
layui.config({
|
layui.config({
|
||||||
base: 'assets/layuiadmin/'
|
base: 'assets/layuiadmin/'
|
||||||
}).extend({
|
}).extend({
|
||||||
@ -70,8 +109,10 @@
|
|||||||
var selectedUserIds = top.dialog.dialogData.selectedUserIds;
|
var selectedUserIds = top.dialog.dialogData.selectedUserIds;
|
||||||
var selectDepartmentUserOldArray = [];
|
var selectDepartmentUserOldArray = [];
|
||||||
var selectDepartmentUserArray = [];
|
var selectDepartmentUserArray = [];
|
||||||
|
var selectRoleId = 0;
|
||||||
var selectedParentId = 0;
|
var selectedParentId = 0;
|
||||||
var searchTimeout;
|
var searchTimeout;
|
||||||
|
var hasRoleService = [[${hasRoleService}]];
|
||||||
top.dialog.dialogData.selectedDepartmentUsers = [];
|
top.dialog.dialogData.selectedDepartmentUsers = [];
|
||||||
|
|
||||||
function closeBox() {
|
function closeBox() {
|
||||||
@ -80,7 +121,7 @@
|
|||||||
function initFrame() {
|
function initFrame() {
|
||||||
var height = $win.height() - 160;
|
var height = $win.height() - 160;
|
||||||
$('.selector-tree-wrapper').css({
|
$('.selector-tree-wrapper').css({
|
||||||
height: height +'px',
|
height: (height - 38) +'px',
|
||||||
border: '1px dotted silver'
|
border: '1px dotted silver'
|
||||||
});
|
});
|
||||||
$('.selector-body-wrapper').css({
|
$('.selector-body-wrapper').css({
|
||||||
@ -91,8 +132,46 @@
|
|||||||
height: ($('.selector-body-wrapper').height() - 30) +'px'
|
height: ($('.selector-body-wrapper').height() - 30) +'px'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// 初始化树
|
// 初始化角色树
|
||||||
function initThree() {
|
function initRoleTree() {
|
||||||
|
var setting = {
|
||||||
|
async: {
|
||||||
|
enable: true,
|
||||||
|
autoLoad: false,
|
||||||
|
type: 'get',
|
||||||
|
url: top.restAjax.path('api/role/listztree', []),
|
||||||
|
autoParam:['id'],
|
||||||
|
otherParam:{},
|
||||||
|
dataFilter: function(treeId, parentNode, childNodes) {
|
||||||
|
if (!childNodes) return null;
|
||||||
|
for (var i=0, l=childNodes.length; i<l; i++) {
|
||||||
|
childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
|
||||||
|
}
|
||||||
|
return childNodes;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
callback: {
|
||||||
|
onClick: function(event, treeId, treeNode) {
|
||||||
|
if(treeNode.id == 0) {
|
||||||
|
selectRoleId = undefined;
|
||||||
|
} else {
|
||||||
|
selectRoleId = treeNode.id;
|
||||||
|
}
|
||||||
|
$('#searchUser').val('');
|
||||||
|
initUsers(selectedParentId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
view: {
|
||||||
|
fontCss: {'color': 'black'}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var zTree = $.fn.zTree.init($('#roleTree'), setting);
|
||||||
|
zTree.addNodes(null, {id: '0', pId: '-1', name: '无角色', url: 'javascript:void(0);', isParent: 'false'});
|
||||||
|
common.refreshTree('roleTree');
|
||||||
|
}
|
||||||
|
// 初始化部门树
|
||||||
|
function initDepartmentTree() {
|
||||||
var setting = {
|
var setting = {
|
||||||
async: {
|
async: {
|
||||||
enable: true,
|
enable: true,
|
||||||
@ -111,6 +190,7 @@
|
|||||||
},
|
},
|
||||||
callback: {
|
callback: {
|
||||||
onClick: function(event, treeId, treeNode) {
|
onClick: function(event, treeId, treeNode) {
|
||||||
|
var parentId;
|
||||||
if(treeNode.id == 0) {
|
if(treeNode.id == 0) {
|
||||||
return;
|
return;
|
||||||
} else if(treeNode.id == 1) {
|
} else if(treeNode.id == 1) {
|
||||||
@ -127,22 +207,17 @@
|
|||||||
fontCss: {'color': 'black'}
|
fontCss: {'color': 'black'}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var zTree = $.fn.zTree.init($('#leftTree'), setting);
|
var zTree = $.fn.zTree.init($('#departmentTree'), setting);
|
||||||
zTree.addNodes(null, {id: '1', pId: '-1', name: '自由用户', url: 'javascript:void(0);', isParent: 'false'});
|
zTree.addNodes(null, {id: '1', pId: '-1', name: '自由用户', url: 'javascript:void(0);', isParent: 'false'});
|
||||||
zTree.addNodes(null, {id: '0', pId: '-1', name: '组织部门', url: 'javascript:void(0);', isParent: 'true'});
|
zTree.addNodes(null, {id: '0', pId: '-1', name: '组织部门', url: 'javascript:void(0);', isParent: 'true'});
|
||||||
common.refreshTree('leftTree');
|
common.refreshTree('departmentTree');
|
||||||
}
|
}
|
||||||
// 添加人员dom
|
// 添加人员dom
|
||||||
function addUserDom(data) {
|
function addUserDom(data) {
|
||||||
var userDom = '';
|
var userDom = '';
|
||||||
for(var i = 0, item; item = data[i++];) {
|
for(var i = 0, item; item = data[i++];) {
|
||||||
var avatarDom;
|
var avatarDom = '<img class="user-avatar user-selected-avatar" src="assets/images/profile-photo.jpg"/> ';
|
||||||
if(null == item.userAvatar || '' == item.userAvatar) {
|
userDom += '<a id="user_'+ item.userId +'" href="javascript:void(0);" class="users list-group-item '+ (isUserSelected(item.userId) ? 'user-selected' : '') +'" lay-click-user data-userid="'+ item.userId +'" data-username="'+ item.userName +'" data-user-username="'+ item.userUsername +'">'+ avatarDom +'<span class="user-selected-span">'+ item.userUsername +'</span><span class="user-selected-span">昵称:'+ item.userName +'</span></a>';
|
||||||
avatarDom = '<img class="user-avatar" src="assets/images/profile-photo.jpg"/> '
|
|
||||||
} else {
|
|
||||||
avatarDom = '<img class="user-avatar" src="route/file/download/false/'+ item.userAvatar +'"/> ';
|
|
||||||
}
|
|
||||||
userDom += '<a id="user_'+ item.userId +'" href="javascript:void(0);" class="users list-group-item '+ (isUserSelected(item.userId) ? 'user-selected' : '') +'" lay-click-user data-userid="'+ item.userId +'" data-username="'+ item.userName +'" data-user-username="'+ item.userUsername +'">'+ avatarDom + item.userName +' ['+ item.userUsername +']</a>';
|
|
||||||
}
|
}
|
||||||
$('#userWrapper').append(userDom);
|
$('#userWrapper').append(userDom);
|
||||||
}
|
}
|
||||||
@ -163,13 +238,8 @@
|
|||||||
}
|
}
|
||||||
var userDom = '';
|
var userDom = '';
|
||||||
for(var i = 0, item; item = data[i++];) {
|
for(var i = 0, item; item = data[i++];) {
|
||||||
var avatarDom;
|
var avatarDom = '<img class="user-avatar user-selected-avatar" src="assets/images/profile-photo.jpg"/> '
|
||||||
if(item.userAvatar) {
|
userDom += '<a id="user_'+ item.userId +'" href="javascript:void(0);" class="users search-users list-group-item '+ (isUserSelected(item.userId) ? 'user-selected' : '') +'" lay-click-user data-userid="'+ item.userId +'" data-username="'+ item.userName +'" data-user-username="'+ item.userUsername +'">'+ avatarDom +'<span class="user-selected-span">'+ item.userUsername +'</span><span class="user-selected-span">昵称:'+ item.userName +'</span></a>';
|
||||||
avatarDom = '<img class="user-avatar" src="assets/images/profile-photo.jpg"/> '
|
|
||||||
} else {
|
|
||||||
avatarDom = '<img class="user-avatar" src="route/file/download/false/'+ item.userAvatar +'"/> ';
|
|
||||||
}
|
|
||||||
userDom += '<a id="user_'+ item.userId +'" href="javascript:void(0);" class="users search-users list-group-item '+ (isUserSelected(item.userId) ? 'user-selected' : '') +'" lay-click-user data-userid="'+ item.userId +'" data-username="'+ item.userName +'" data-user-username="'+ item.userUsername +'">'+ avatarDom + item.userName +' ['+ item.userUsername +']</a>';
|
|
||||||
}
|
}
|
||||||
$('#userWrapper').append(userDom);
|
$('#userWrapper').append(userDom);
|
||||||
}
|
}
|
||||||
@ -181,7 +251,11 @@
|
|||||||
isAuto: false,
|
isAuto: false,
|
||||||
done: function(page, next) {
|
done: function(page, next) {
|
||||||
var loadLayerIndex;
|
var loadLayerIndex;
|
||||||
top.restAjax.get(top.restAjax.path('api/department/user/listpage/{department}', [selectedParentId]), {
|
var url = top.restAjax.path('api/department/user/listpage/{department}', [selectedParentId]);
|
||||||
|
if(selectRoleId) {
|
||||||
|
url = top.restAjax.path('api/role/department/user/listpage-user/{department}/{roleId}', [selectedParentId, selectRoleId]);
|
||||||
|
}
|
||||||
|
top.restAjax.get(url, {
|
||||||
page: page,
|
page: page,
|
||||||
rows: 20
|
rows: 20
|
||||||
}, null, function(code, data) {
|
}, null, function(code, data) {
|
||||||
@ -201,10 +275,13 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var loadLayerIndex;
|
var loadLayerIndex;
|
||||||
top.restAjax.get(top.restAjax.path('api/department/user/list/{department}', [selectedParentId]), {
|
var url = top.restAjax.path('api/department/user/list/{department}', [selectedParentId]);
|
||||||
|
if(selectRoleId) {
|
||||||
|
url = top.restAjax.path('api/role/department/user/list-user/{department}/{roleId}', [selectedParentId, selectRoleId]);
|
||||||
|
}
|
||||||
|
top.restAjax.get(url, {
|
||||||
keywords: searchUser
|
keywords: searchUser
|
||||||
}, null, function(code, data) {
|
}, null, function(code, data) {
|
||||||
console.log(data);
|
|
||||||
addSearchUserDom(data);
|
addSearchUserDom(data);
|
||||||
}, function(code, data) {
|
}, function(code, data) {
|
||||||
top.dialog.msg(data.msg);
|
top.dialog.msg(data.msg);
|
||||||
@ -216,9 +293,9 @@
|
|||||||
}
|
}
|
||||||
// 初始化人员列表
|
// 初始化人员列表
|
||||||
function initUsers(parentId) {
|
function initUsers(parentId) {
|
||||||
selectedParentId = parentId;
|
|
||||||
$('#userWrapper').empty();
|
$('#userWrapper').empty();
|
||||||
$('.layui-flow-more').remove();
|
$('.layui-flow-more').remove();
|
||||||
|
selectedParentId = parentId;
|
||||||
initUserFlowLoad();
|
initUserFlowLoad();
|
||||||
}
|
}
|
||||||
// 初始化选择的人员
|
// 初始化选择的人员
|
||||||
@ -249,7 +326,10 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
initFrame();
|
initFrame();
|
||||||
initThree();
|
if(hasRoleService) {
|
||||||
|
initRoleTree();
|
||||||
|
}
|
||||||
|
initDepartmentTree();
|
||||||
initSelectedUsers(function() {
|
initSelectedUsers(function() {
|
||||||
initUsers(0);
|
initUsers(0);
|
||||||
});
|
});
|
||||||
|
@ -2,8 +2,10 @@ package ink.wgink.service.role.controller.api;
|
|||||||
|
|
||||||
import ink.wgink.common.base.DefaultBaseController;
|
import ink.wgink.common.base.DefaultBaseController;
|
||||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||||
|
import ink.wgink.pojo.ListPage;
|
||||||
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
||||||
import ink.wgink.pojo.result.ErrorResult;
|
import ink.wgink.pojo.result.ErrorResult;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
import ink.wgink.service.role.service.IRoleDepartmentUserService;
|
import ink.wgink.service.role.service.IRoleDepartmentUserService;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -13,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName: RoleDepartmentUserController
|
* @ClassName: RoleDepartmentUserController
|
||||||
@ -53,4 +56,20 @@ public class RoleDepartmentUserController extends DefaultBaseController {
|
|||||||
return roleDepartmentUserService.listUserByDepartmentIdAndRoleId(departmentId, roleId);
|
return roleDepartmentUserService.listUserByDepartmentIdAndRoleId(departmentId, roleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "用户分页列表", notes = "通过部门ID、角色ID用户列表接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path"),
|
||||||
|
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path"),
|
||||||
|
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
|
||||||
|
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
|
||||||
|
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("listpage-user/{departmentId}/{roleId}")
|
||||||
|
public SuccessResultList<List<DepartmentUserDTO>> listPageUserByDepartmentIdAndRoleId(@PathVariable("departmentId") String departmentId, @PathVariable("roleId") String roleId, ListPage page) {
|
||||||
|
Map<String, Object> params = requestParams();
|
||||||
|
page.setParams(params);
|
||||||
|
return roleDepartmentUserService.listPageUserByDepartmentIdAndRoleId(departmentId, roleId, page);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,51 @@
|
|||||||
|
package ink.wgink.service.role.controller.resources;
|
||||||
|
|
||||||
|
import ink.wgink.common.base.DefaultBaseController;
|
||||||
|
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||||
|
import ink.wgink.pojo.ListPage;
|
||||||
|
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
||||||
|
import ink.wgink.pojo.result.ErrorResult;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
|
import ink.wgink.service.role.service.IRoleDepartmentUserService;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: RoleDepartmentUserResourceController
|
||||||
|
* @Description: 角色部门用户
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/11/3 3:04 下午
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Api(tags = ISystemConstant.API_TAGS_RESOURCE_PREFIX + "角色部门用户")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(ISystemConstant.RESOURCE_PREFIX + "/role/department/user")
|
||||||
|
public class RoleDepartmentUserResourceController extends DefaultBaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IRoleDepartmentUserService roleDepartmentUserService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "用户分页列表", notes = "通过部门ID、角色ID用户列表接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path"),
|
||||||
|
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path"),
|
||||||
|
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
|
||||||
|
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
|
||||||
|
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("listpage-user/{departmentId}/{roleId}")
|
||||||
|
public SuccessResultList<List<DepartmentUserDTO>> listPageUserByDepartmentIdAndRoleId(@PathVariable("departmentId") String departmentId, @PathVariable("roleId") String roleId, ListPage page) {
|
||||||
|
Map<String, Object> params = requestParams();
|
||||||
|
page.setParams(params);
|
||||||
|
return roleDepartmentUserService.listPageUserByDepartmentIdAndRoleId(departmentId, roleId, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,12 +1,17 @@
|
|||||||
package ink.wgink.service.role.service.impl;
|
package ink.wgink.service.role.service.impl;
|
||||||
|
|
||||||
import ink.wgink.common.base.DefaultBaseService;
|
import ink.wgink.common.base.DefaultBaseService;
|
||||||
|
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||||
|
import ink.wgink.pojo.ListPage;
|
||||||
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
||||||
|
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||||
import ink.wgink.pojo.pos.DepartmentPO;
|
import ink.wgink.pojo.pos.DepartmentPO;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
import ink.wgink.service.department.service.IDepartmentService;
|
import ink.wgink.service.department.service.IDepartmentService;
|
||||||
import ink.wgink.service.department.service.IDepartmentUserService;
|
import ink.wgink.service.department.service.IDepartmentUserService;
|
||||||
import ink.wgink.service.role.service.IRoleDepartmentUserService;
|
import ink.wgink.service.role.service.IRoleDepartmentUserService;
|
||||||
import ink.wgink.service.role.service.IRoleUserService;
|
import ink.wgink.service.role.service.IRoleUserService;
|
||||||
|
import ink.wgink.service.user.service.IUserService;
|
||||||
import ink.wgink.util.ArrayListUtil;
|
import ink.wgink.util.ArrayListUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -28,6 +33,8 @@ public class RoleDepartmentUserServiceImpl extends DefaultBaseService implements
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IRoleUserService roleUserService;
|
private IRoleUserService roleUserService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private IUserService userService;
|
||||||
|
@Autowired
|
||||||
private IDepartmentService departmentService;
|
private IDepartmentService departmentService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IDepartmentUserService departmentUserService;
|
private IDepartmentUserService departmentUserService;
|
||||||
@ -54,6 +61,21 @@ public class RoleDepartmentUserServiceImpl extends DefaultBaseService implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DepartmentUserDTO> listUserByDepartmentIdAndRoleId(String departmentId, String roleId) {
|
public List<DepartmentUserDTO> listUserByDepartmentIdAndRoleId(String departmentId, String roleId) {
|
||||||
|
if (StringUtils.equals(departmentId, ISystemConstant.TREE_BASE_ROOT_ID_VALUE)) {
|
||||||
|
return listUserByExcludeDepartment(roleId);
|
||||||
|
}
|
||||||
|
return listUser(departmentId, roleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SuccessResultList<List<DepartmentUserDTO>> listPageUserByDepartmentIdAndRoleId(String departmentId, String roleId, ListPage page) {
|
||||||
|
if (StringUtils.equals(departmentId, ISystemConstant.TREE_BASE_ROOT_ID_VALUE)) {
|
||||||
|
return listPageUserByExcludeDepartment(roleId, page);
|
||||||
|
}
|
||||||
|
return listPageUser(departmentId, roleId, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<DepartmentUserDTO> listUser(String departmentId, String roleId) {
|
||||||
List<DepartmentUserDTO> departmentUserDTOs = departmentUserService.list(departmentId);
|
List<DepartmentUserDTO> departmentUserDTOs = departmentUserService.list(departmentId);
|
||||||
if (departmentUserDTOs.isEmpty()) {
|
if (departmentUserDTOs.isEmpty()) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
@ -66,6 +88,57 @@ public class RoleDepartmentUserServiceImpl extends DefaultBaseService implements
|
|||||||
return departmentUserDTOs;
|
return departmentUserDTOs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<DepartmentUserDTO> listUserByExcludeDepartment(String roleId) {
|
||||||
|
List<String> roleUserIds = roleUserService.listUserId(roleId);
|
||||||
|
if (roleUserIds.isEmpty()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
List<DepartmentUserDTO> hasDepartmentUsers = departmentUserService.list(roleUserIds);
|
||||||
|
List<String> departmentUserIds = ArrayListUtil.listBeanStringIdValue(hasDepartmentUsers, "userId", DepartmentUserDTO.class);
|
||||||
|
List<UserDTO> userDTOs = userService.listByExcludeIds(departmentUserIds, roleUserIds, null);
|
||||||
|
return departmentUserService.listExcludeDepartmentUser(userDTOs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 没有组织机构的用户分页列表
|
||||||
|
*
|
||||||
|
* @param roleId 角色ID
|
||||||
|
* @param page
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private SuccessResultList<List<DepartmentUserDTO>> listPageUserByExcludeDepartment(String roleId, ListPage page) {
|
||||||
|
List<String> roleUserIds = roleUserService.listUserId(roleId);
|
||||||
|
if (roleUserIds.isEmpty()) {
|
||||||
|
return new SuccessResultList<>(new ArrayList<>(), 1, 0L);
|
||||||
|
}
|
||||||
|
// 获取所有部门的用户列表
|
||||||
|
List<DepartmentUserDTO> hasDepartmentUsers = departmentUserService.list(getHashMap(0));
|
||||||
|
List<String> hasDepartmentUserIds = ArrayListUtil.listBeanStringIdValue(hasDepartmentUsers, "userId", DepartmentUserDTO.class);
|
||||||
|
SuccessResultList<List<UserDTO>> successResultList = userService.listPageByExcludeIdsAndIncludeIds(hasDepartmentUserIds, roleUserIds, page);
|
||||||
|
return departmentUserService.listPageExcludeDepartmentUser(successResultList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组织机构的用户分页列表
|
||||||
|
*
|
||||||
|
* @param departmentId 组织机构ID
|
||||||
|
* @param page
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private SuccessResultList<List<DepartmentUserDTO>> listPageUser(String departmentId, String roleId, ListPage page) {
|
||||||
|
List<String> roleUserIds = roleUserService.listUserId(roleId);
|
||||||
|
if (roleUserIds.isEmpty()) {
|
||||||
|
return new SuccessResultList<>(new ArrayList<>(), 1, 0L);
|
||||||
|
}
|
||||||
|
List<DepartmentUserDTO> hasDepartmentUsers = departmentUserService.listByDepartmentIdAndUserIds(departmentId, roleUserIds);
|
||||||
|
List<String> userIds = new ArrayList<>();
|
||||||
|
for (DepartmentUserDTO hasDepartmentUserId : hasDepartmentUsers) {
|
||||||
|
userIds.add(hasDepartmentUserId.getUserId());
|
||||||
|
}
|
||||||
|
SuccessResultList<List<UserDTO>> successResultList = userService.listPageByIds(userIds, page);
|
||||||
|
return departmentUserService.listPageDepartmentUser(successResultList, hasDepartmentUsers);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清除没有角色的用户
|
* 清除没有角色的用户
|
||||||
*
|
*
|
||||||
|
@ -79,6 +79,7 @@
|
|||||||
return '<button type="button" class="layui-btn layui-btn-xs" lay-event="userEvent"><i class="fa fa-users"></i> 查看</button>';
|
return '<button type="button" class="layui-btn layui-btn-xs" lay-event="userEvent"><i class="fa fa-users"></i> 查看</button>';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{field:'roleId', width:180, title: '角色ID', align:'center',},
|
||||||
{field:'roleName', width:170, title: '角色名称', align:'center',},
|
{field:'roleName', width:170, title: '角色名称', align:'center',},
|
||||||
{field:'roleSummary', width:170, title: '角色说明', align:'center',},
|
{field:'roleSummary', width:170, title: '角色说明', align:'center',},
|
||||||
{field:'roleCode', width:170, title: '角色编码', align:'center',},
|
{field:'roleCode', width:170, title: '角色编码', align:'center',},
|
||||||
|
@ -409,12 +409,32 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService
|
|||||||
return listPage(page);
|
return listPage(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SuccessResultList<List<UserDTO>> listPageByExcludeIdsAndIncludeIds(List<String> excludeUserIds, List<String> includeUserIds, ListPage page) {
|
||||||
|
page.getParams().put("excludeUserIds", excludeUserIds);
|
||||||
|
page.getParams().put("userIds", includeUserIds);
|
||||||
|
return listPage(page);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<UserDTO> listByExcludeIds(List<String> excludeUserIds, Map<String, Object> params) {
|
public List<UserDTO> listByExcludeIds(List<String> excludeUserIds, Map<String, Object> params) {
|
||||||
|
if(params == null) {
|
||||||
|
params = getHashMap(2);
|
||||||
|
}
|
||||||
params.put("excludeUserIds", excludeUserIds);
|
params.put("excludeUserIds", excludeUserIds);
|
||||||
return list(params);
|
return list(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UserDTO> listByExcludeIds(List<String> excludeUserIds, List<String> includeUserIds, Map<String, Object> params) {
|
||||||
|
if(params == null) {
|
||||||
|
params = getHashMap(2);
|
||||||
|
}
|
||||||
|
params.put("excludeUserIds", excludeUserIds);
|
||||||
|
params.put("userIds", includeUserIds);
|
||||||
|
return list(params);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer count(Map<String, Object> params) {
|
public Integer count(Map<String, Object> params) {
|
||||||
Integer count = userDao.count(params);
|
Integer count = userDao.count(params);
|
||||||
|
Loading…
Reference in New Issue
Block a user