新增角色部门用户功能,修改部门地区选择
This commit is contained in:
parent
7d0bc13636
commit
f6953704bc
@ -163,4 +163,20 @@ public interface IDepartmentBaseService {
|
||||
*/
|
||||
List<DepartmentPO> listPOByParentIdAndUpdateDate(String departmentParentId, String updateDate);
|
||||
|
||||
/**
|
||||
* 通过区域编码获取组织部门列表
|
||||
*
|
||||
* @param departmentAreaCode 部门区域编码
|
||||
* @return
|
||||
*/
|
||||
List<DepartmentPO> listPOByAreaCode(String departmentAreaCode);
|
||||
|
||||
/**
|
||||
* 通过区域编码、部门类型获取组织部门列表
|
||||
*
|
||||
* @param departmentAreaCode
|
||||
* @param departmentType
|
||||
* @return
|
||||
*/
|
||||
List<DepartmentPO> listPOByAreaCodeAndType(String departmentAreaCode, Integer departmentType);
|
||||
}
|
||||
|
@ -95,4 +95,11 @@ public interface IDepartmentUserBaseService {
|
||||
* @return
|
||||
*/
|
||||
List<DepartmentUserDTO> list(String departmentId, Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 设置用户
|
||||
*
|
||||
* @param departmentUserDTOs
|
||||
*/
|
||||
void setUser(List<DepartmentUserDTO> departmentUserDTOs);
|
||||
}
|
||||
|
@ -0,0 +1,36 @@
|
||||
package ink.wgink.interfaces.role;
|
||||
|
||||
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: IRoleDepartmentUserBaseService
|
||||
* @Description: 角色部门用户
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/11/3 4:11 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface IRoleDepartmentUserBaseService {
|
||||
|
||||
|
||||
/**
|
||||
* 获取指定地区下所有部门中指定角色的用户列表
|
||||
*
|
||||
* @param roleId 通过角色ID
|
||||
* @param areaCode 地区编码
|
||||
* @return
|
||||
*/
|
||||
List<DepartmentUserDTO> listUserByRoleIdAndAreaCode(String roleId, String areaCode) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException;
|
||||
|
||||
/**
|
||||
* 获取指定部门中指定角色的用户列表接口
|
||||
*
|
||||
* @param departmentId 部门ID
|
||||
* @param roleId 角色ID
|
||||
* @return
|
||||
*/
|
||||
List<DepartmentUserDTO> listUserByDepartmentIdAndRoleId(String departmentId, String roleId);
|
||||
|
||||
}
|
@ -1,7 +1,11 @@
|
||||
package ink.wgink.util;
|
||||
|
||||
import ink.wgink.util.string.WStringUtil;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
@ -32,4 +36,28 @@ public class ArrayListUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取bean中的字符串ID值列表
|
||||
*
|
||||
* @param beans
|
||||
* @param propertyName
|
||||
* @param beanClass
|
||||
* @param <T>
|
||||
* @return
|
||||
* @throws NoSuchMethodException
|
||||
* @throws InvocationTargetException
|
||||
* @throws IllegalAccessException
|
||||
*/
|
||||
public static <T> List<String> listBeanStringIdValue(List<T> beans, String propertyName, Class<T> beanClass) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
||||
Set<String> beanStringIdSet = new HashSet<>();
|
||||
for (Object bean : beans) {
|
||||
Method method = bean.getClass().getMethod("get" + WStringUtil.firstToUpper(propertyName));
|
||||
Object result = method.invoke(bean);
|
||||
if (result == null) {
|
||||
continue;
|
||||
}
|
||||
beanStringIdSet.add(result.toString());
|
||||
}
|
||||
return new ArrayList<>(beanStringIdSet);
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ public class RestRemoteHandler implements InvocationHandler {
|
||||
if (arg == null) {
|
||||
throw new SystemException("路径参数不能为空: " + variableName);
|
||||
}
|
||||
pathVariableParamsMap.put(variableName, URLEncoder.encode(arg.toString(), "UTF-8"));
|
||||
pathVariableParamsMap.put(variableName, URLEncoder.encode(String.valueOf(arg), "UTF-8"));
|
||||
}
|
||||
return pathVariableParamsMap;
|
||||
}
|
||||
@ -168,7 +168,7 @@ public class RestRemoteHandler implements InvocationHandler {
|
||||
if (arg == null) {
|
||||
continue;
|
||||
}
|
||||
queryVariableParamsMap.put(variableName, URLEncoder.encode(arg.toString(), "UTF-8"));
|
||||
queryVariableParamsMap.put(variableName, URLEncoder.encode(String.valueOf(arg), "UTF-8"));
|
||||
}
|
||||
return queryVariableParamsMap;
|
||||
}
|
||||
@ -196,7 +196,7 @@ public class RestRemoteHandler implements InvocationHandler {
|
||||
if (arg == null) {
|
||||
continue;
|
||||
}
|
||||
formVariableParamsMap.add(variableName, arg.toString());
|
||||
formVariableParamsMap.add(variableName, String.valueOf(arg));
|
||||
}
|
||||
return formVariableParamsMap;
|
||||
}
|
||||
@ -224,7 +224,7 @@ public class RestRemoteHandler implements InvocationHandler {
|
||||
if (arg == null) {
|
||||
continue;
|
||||
}
|
||||
headerVariableParamsMap.put(variableName, arg.toString());
|
||||
headerVariableParamsMap.put(variableName, String.valueOf(arg));
|
||||
}
|
||||
return headerVariableParamsMap;
|
||||
}
|
||||
@ -274,7 +274,7 @@ public class RestRemoteHandler implements InvocationHandler {
|
||||
Map<String, Object> argMap = (Map<String, Object>) args[i];
|
||||
Map<String, String> queryMap = new HashMap<>();
|
||||
for (Map.Entry<String, Object> kv : argMap.entrySet()) {
|
||||
queryMap.put(kv.getKey(), URLEncoder.encode(kv.getValue().toString(), "UTF-8"));
|
||||
queryMap.put(kv.getKey(), URLEncoder.encode(String.valueOf(kv.getValue()), "UTF-8"));
|
||||
}
|
||||
return queryMap;
|
||||
}
|
||||
@ -297,7 +297,7 @@ public class RestRemoteHandler implements InvocationHandler {
|
||||
if (args[i] == null) {
|
||||
continue;
|
||||
}
|
||||
return args[i].toString();
|
||||
return String.valueOf(args[i]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -63,4 +63,9 @@ public interface IDepartmentRemoteService {
|
||||
@RemoteGetMethod("/list-po/parentid/{departmentParentId}/update-date/{updateDate}")
|
||||
List<DepartmentPO> listPOByParentIdAndUpdateDate(@RemoteServerParams String userCenter, @RemotePathParams("departmentParentId") String departmentParentId, @RemotePathParams("updateDate") String updateDate, @RemoteQueryParams("access_token") String accessToken);
|
||||
|
||||
@RemoteGetMethod("/list-po/area-code/{areaCode}")
|
||||
List<DepartmentPO> listPOByAreaCode(@RemoteServerParams String userCenter, @RemotePathParams("areaCode") String areaCode, @RemoteQueryParams("access_token") String accessToken);
|
||||
|
||||
@RemoteGetMethod("/list-po/area-code/{areaCode}/type/{departmentType}")
|
||||
List<DepartmentPO> listPOByAreaCodeAndType(@RemoteServerParams String userCenter, @RemotePathParams("areaCode") String departmentAreaCode, @RemotePathParams("departmentType") Integer departmentType, @RemoteQueryParams("access_token") String accessToken);
|
||||
}
|
||||
|
@ -162,4 +162,14 @@ public class DepartmentServiceImpl extends DefaultBaseService implements IDepart
|
||||
public List<DepartmentPO> listPOByParentIdAndUpdateDate(String departmentParentId, String updateDate) {
|
||||
return departmentRemoteService.listPOByParentIdAndUpdateDate(apiPathProperties.getUserCenter(), departmentParentId, updateDate, OAuth2ClientTokenManager.getInstance().getToken().getAccessToken());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DepartmentPO> listPOByAreaCode(String departmentAreaCode) {
|
||||
return departmentRemoteService.listPOByAreaCode(apiPathProperties.getUserCenter(), departmentAreaCode, OAuth2ClientTokenManager.getInstance().getToken().getAccessToken());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DepartmentPO> listPOByAreaCodeAndType(String departmentAreaCode, Integer departmentType) {
|
||||
return departmentRemoteService.listPOByAreaCodeAndType(apiPathProperties.getUserCenter(), departmentAreaCode, departmentType, OAuth2ClientTokenManager.getInstance().getToken().getAccessToken());
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package ink.wgink.login.oauth2.client.service.department.impl;
|
||||
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.interfaces.user.IUserBaseService;
|
||||
import ink.wgink.login.oauth2.client.remote.department.IDepartmentUserRemoteService;
|
||||
import ink.wgink.login.oauth2.client.service.department.IDepartmentUserService;
|
||||
import ink.wgink.module.oauth2.manager.OAuth2ClientTokenManager;
|
||||
@ -15,9 +15,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @ClassName: DepartmentUserServiceImpl
|
||||
@ -29,6 +27,8 @@ import java.util.Map;
|
||||
@Service
|
||||
public class DepartmentUserServiceImpl extends DefaultBaseService implements IDepartmentUserService {
|
||||
|
||||
@Autowired
|
||||
private IUserBaseService userBaseService;
|
||||
@Autowired
|
||||
private IDepartmentUserRemoteService departmentUserRemoteService;
|
||||
@Autowired
|
||||
@ -88,4 +88,24 @@ public class DepartmentUserServiceImpl extends DefaultBaseService implements IDe
|
||||
return departmentUserRemoteService.list(apiPathProperties.getUserCenter(), departmentId, OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUser(List<DepartmentUserDTO> departmentUserDTOs) {
|
||||
if (departmentUserDTOs.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Set<String> userIdSet = new HashSet<>();
|
||||
for (DepartmentUserDTO hasDepartmentUserId : departmentUserDTOs) {
|
||||
userIdSet.add(hasDepartmentUserId.getUserId());
|
||||
}
|
||||
List<UserDTO> userDTOs = userBaseService.listByUserIds(new ArrayList<>(userIdSet));
|
||||
for (DepartmentUserDTO departmentUserDTO : departmentUserDTOs) {
|
||||
for (UserDTO userDTO : userDTOs) {
|
||||
if (StringUtils.equals(departmentUserDTO.getUserId(), userDTO.getUserId())) {
|
||||
departmentUserDTO.setUser(userDTO);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
package ink.wgink.login.oauth2.client.service.role;
|
||||
|
||||
import ink.wgink.interfaces.role.IRoleDepartmentUserBaseService;
|
||||
|
||||
/**
|
||||
* @ClassName: IRoleDepartmentUserService
|
||||
* @Description: 角色部门用户
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/11/3 4:13 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface IRoleDepartmentUserService extends IRoleDepartmentUserBaseService {
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package ink.wgink.login.oauth2.client.service.role.impl;
|
||||
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.interfaces.department.IDepartmentBaseService;
|
||||
import ink.wgink.interfaces.department.IDepartmentUserBaseService;
|
||||
import ink.wgink.login.oauth2.client.service.role.IRoleDepartmentUserService;
|
||||
import ink.wgink.login.oauth2.client.service.role.IRoleUserService;
|
||||
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
||||
import ink.wgink.pojo.pos.DepartmentPO;
|
||||
import ink.wgink.util.ArrayListUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: RoleDepartmentUserServiceImpl
|
||||
* @Description: 角色部门用户
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/11/3 4:14 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Service
|
||||
public class RoleDepartmentUserServiceImpl extends DefaultBaseService implements IRoleDepartmentUserService {
|
||||
|
||||
@Autowired
|
||||
private IRoleUserService userService;
|
||||
@Autowired
|
||||
private IRoleUserService roleUserService;
|
||||
@Autowired
|
||||
private IDepartmentBaseService departmentBaseService;
|
||||
@Autowired
|
||||
private IDepartmentUserBaseService departmentUserBaseService;
|
||||
|
||||
@Override
|
||||
public List<DepartmentUserDTO> listUserByRoleIdAndAreaCode(String roleId, String areaCode) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
|
||||
// 地区下所有组织机构
|
||||
List<DepartmentPO> departmentPOs = departmentBaseService.listPOByAreaCode(areaCode);
|
||||
if (departmentPOs.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<String> roleUserIds = roleUserService.listUserId(roleId);
|
||||
if (roleUserIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<String> departmentIds = ArrayListUtil.listBeanStringIdValue(departmentPOs, "departmentId", DepartmentPO.class);
|
||||
List<DepartmentUserDTO> departmentUserDTOs = departmentUserBaseService.list(departmentIds);
|
||||
if (departmentUserDTOs.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
clearNoRoleUser(departmentUserDTOs, roleUserIds);
|
||||
return departmentUserDTOs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DepartmentUserDTO> listUserByDepartmentIdAndRoleId(String departmentId, String roleId) {
|
||||
List<DepartmentUserDTO> departmentUserDTOs = departmentUserBaseService.list(departmentId);
|
||||
if (departmentUserDTOs.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<String> roleUserIds = roleUserService.listUserId(roleId);
|
||||
if (roleUserIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
clearNoRoleUser(departmentUserDTOs, roleUserIds);
|
||||
return departmentUserDTOs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除没有角色的用户
|
||||
*
|
||||
* @param departmentUserDTOs
|
||||
* @param roleUserIds
|
||||
*/
|
||||
private void clearNoRoleUser(List<DepartmentUserDTO> departmentUserDTOs, List<String> roleUserIds) {
|
||||
// 去除没有角色的用户
|
||||
for (int i = 0; i < departmentUserDTOs.size(); i++) {
|
||||
DepartmentUserDTO departmentUserDTO = departmentUserDTOs.get(i);
|
||||
boolean isExist = false;
|
||||
for (String roleUserId : roleUserIds) {
|
||||
if (StringUtils.equals(departmentUserDTO.getUserId(), roleUserId)) {
|
||||
isExist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isExist) {
|
||||
departmentUserDTOs.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
departmentUserBaseService.setUser(departmentUserDTOs);
|
||||
}
|
||||
}
|
@ -142,7 +142,7 @@ public class DepartmentResourceController extends DefaultBaseController {
|
||||
return departmentService.listId(params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "组织部门详情", notes = "组织部门详情接口")
|
||||
@ApiOperation(value = "组织部门列表", notes = "组织部门列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentParentId", value = "上级部门ID", paramType = "path")
|
||||
})
|
||||
@ -152,7 +152,7 @@ public class DepartmentResourceController extends DefaultBaseController {
|
||||
return departmentService.listPOByParentId(departmentParentId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "组织部门详情", notes = "组织部门详情接口")
|
||||
@ApiOperation(value = "组织部门列表", notes = "组织部门列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path")
|
||||
})
|
||||
@ -162,7 +162,7 @@ public class DepartmentResourceController extends DefaultBaseController {
|
||||
return departmentService.listPO(idsVO.getIds());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "组织部门详情", notes = "组织部门详情接口")
|
||||
@ApiOperation(value = "组织部门列表", notes = "组织部门列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentParentId", value = "上级部门ID", paramType = "path"),
|
||||
@ApiImplicitParam(name = "addDate", value = "添加时间,yyyy-MM-dd", paramType = "path")
|
||||
@ -173,7 +173,7 @@ public class DepartmentResourceController extends DefaultBaseController {
|
||||
return departmentService.listPOByParentIdAndAddDate(departmentParentId, addDate);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "组织部门详情", notes = "组织部门详情接口")
|
||||
@ApiOperation(value = "组织部门列表", notes = "组织部门列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentParentId", value = "上级部门ID", paramType = "path"),
|
||||
@ApiImplicitParam(name = "updateDate", value = "修改时间,yyyy-MM-dd", paramType = "path")
|
||||
@ -184,6 +184,27 @@ public class DepartmentResourceController extends DefaultBaseController {
|
||||
return departmentService.listPOByParentIdAndUpdateDate(departmentParentId, updateDate);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "组织部门列表", notes = "组织部门列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "areaCode", value = "地区编码", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("list-po/area-code/{areaCode}")
|
||||
public List<DepartmentPO> listPOByAreaCode(@PathVariable("areaCode") String areaCode) {
|
||||
return departmentService.listPOByAreaCode(areaCode);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "组织部门列表", notes = "组织部门列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "areaCode", value = "地区编码", paramType = "path"),
|
||||
@ApiImplicitParam(name = "departmentType", value = "组织部门类型", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("list-po/area-code/{areaCode}/type/{departmentType}")
|
||||
public List<DepartmentPO> listPOByAreaCode(@PathVariable("areaCode") String areaCode, @PathVariable("departmentType") Integer departmentType) {
|
||||
return departmentService.listPOByAreaCodeAndType(areaCode, departmentType);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "统计", notes = "统计接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("count")
|
||||
|
@ -94,4 +94,5 @@ public interface IDepartmentUserService extends IDepartmentUserBaseService {
|
||||
* @return
|
||||
*/
|
||||
List<DepartmentUserDTO> listWithUser(Map<String, Object> params);
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.exceptions.SaveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.module.dictionary.pojo.dtos.AreaDTO;
|
||||
import ink.wgink.module.dictionary.service.IAreaService;
|
||||
import ink.wgink.module.file.excel.error.AbstractErrorExcelHandler;
|
||||
import ink.wgink.module.file.service.IFileService;
|
||||
@ -330,8 +329,8 @@ public class DepartmentServiceImpl extends DefaultBaseService implements IDepart
|
||||
|
||||
@Override
|
||||
public List<DepartmentPO> listPO(List<String> departmentIds) {
|
||||
if(departmentIds.isEmpty()) {
|
||||
|
||||
if (departmentIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("departmentIds", departmentIds);
|
||||
@ -353,6 +352,21 @@ public class DepartmentServiceImpl extends DefaultBaseService implements IDepart
|
||||
return listSimpleByParentIdAndAddDateOrUpdateDate(departmentParentId, null, updateDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DepartmentPO> listPOByAreaCode(String departmentAreaCode) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("departmentAreaCode", departmentAreaCode);
|
||||
return listPO(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DepartmentPO> listPOByAreaCodeAndType(String departmentAreaCode, Integer departmentType) {
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
params.put("departmentAreaCode", departmentAreaCode);
|
||||
params.put("departmentType", departmentType);
|
||||
return listPO(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过上级ID和新增或修改日期获取组织列表(简单模式)
|
||||
*
|
||||
|
@ -365,12 +365,8 @@ public class DepartmentUserServiceImpl extends DefaultBaseService implements IDe
|
||||
return departmentUserDTOs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户
|
||||
*
|
||||
* @param departmentUserDTOs
|
||||
*/
|
||||
private void setUser(List<DepartmentUserDTO> departmentUserDTOs) {
|
||||
@Override
|
||||
public void setUser(List<DepartmentUserDTO> departmentUserDTOs) {
|
||||
if (departmentUserDTOs.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -661,6 +661,14 @@
|
||||
AND
|
||||
gmt_modified <![CDATA[ >= ]]> #{updateDate}
|
||||
</if>
|
||||
<if test="departmentAreaCode != null and departmentAreaCode != ''">
|
||||
AND
|
||||
department_area_code = #{departmentAreaCode}
|
||||
</if>
|
||||
<if test="departmentType != null and departmentType != ''">
|
||||
AND
|
||||
department_type = #{departmentType}
|
||||
</if>
|
||||
<if test="orderByCode != null">
|
||||
ORDER BY
|
||||
department_code
|
||||
|
@ -0,0 +1,57 @@
|
||||
package ink.wgink.service.role.controller.api;
|
||||
|
||||
import ink.wgink.common.base.DefaultBaseController;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
||||
import ink.wgink.pojo.result.ErrorResult;
|
||||
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.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: RoleDepartmentUserController
|
||||
* @Description: 角色部门用户
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/11/3 3:04 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "角色部门用户")
|
||||
@RestController
|
||||
@RequestMapping(ISystemConstant.API_PREFIX + "/role/department/user")
|
||||
public class RoleDepartmentUserController extends DefaultBaseController {
|
||||
|
||||
@Autowired
|
||||
private IRoleDepartmentUserService roleDepartmentUserService;
|
||||
|
||||
@ApiOperation(value = "用户列表(通过角色ID、地区编码)", notes = "获取指定地区下所有部门中指定角色的用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path", dataType = "String", required = true),
|
||||
@ApiImplicitParam(name = "areaCode", value = "地区编码", paramType = "path", dataType = "String", required = true),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("list-user/{roleId}/{areaCode}")
|
||||
public List<DepartmentUserDTO> listUserByRoleIdAndAreaCode(@PathVariable("roleId") String roleId,
|
||||
@PathVariable("areaCode") String areaCode) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
|
||||
return roleDepartmentUserService.listUserByRoleIdAndAreaCode(roleId, areaCode);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户列表(通过部门ID、角色ID)", notes = "获取指定部门中指定角色的用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path", dataType = "String", required = true),
|
||||
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path", dataType = "String", required = true),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("list-user/{departmentId}/{roleId}")
|
||||
public List<DepartmentUserDTO> listUserByDepartmentIdAndRoleId(@PathVariable("departmentId") String departmentId,
|
||||
@PathVariable("roleId") String roleId) {
|
||||
return roleDepartmentUserService.listUserByDepartmentIdAndRoleId(departmentId, roleId);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package ink.wgink.service.role.service;
|
||||
|
||||
import ink.wgink.interfaces.role.IRoleDepartmentUserBaseService;
|
||||
|
||||
/**
|
||||
* @ClassName: IRoleDepartmentUserService
|
||||
* @Description: 角色部门用户
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/11/3 3:05 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface IRoleDepartmentUserService extends IRoleDepartmentUserBaseService {
|
||||
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package ink.wgink.service.role.service.impl;
|
||||
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
||||
import ink.wgink.pojo.pos.DepartmentPO;
|
||||
import ink.wgink.service.department.service.IDepartmentService;
|
||||
import ink.wgink.service.department.service.IDepartmentUserService;
|
||||
import ink.wgink.service.role.service.IRoleDepartmentUserService;
|
||||
import ink.wgink.service.role.service.IRoleUserService;
|
||||
import ink.wgink.util.ArrayListUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: RoleDepartmentUserServiceImpl
|
||||
* @Description: 角色部门用户
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/11/3 3:05 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Service
|
||||
public class RoleDepartmentUserServiceImpl extends DefaultBaseService implements IRoleDepartmentUserService {
|
||||
|
||||
@Autowired
|
||||
private IRoleUserService roleUserService;
|
||||
@Autowired
|
||||
private IDepartmentService departmentService;
|
||||
@Autowired
|
||||
private IDepartmentUserService departmentUserService;
|
||||
|
||||
@Override
|
||||
public List<DepartmentUserDTO> listUserByRoleIdAndAreaCode(String roleId, String areaCode) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
|
||||
// 地区下所有组织机构
|
||||
List<DepartmentPO> departmentPOs = departmentService.listPOByAreaCode(areaCode);
|
||||
if (departmentPOs.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<String> roleUserIds = roleUserService.listUserId(roleId);
|
||||
if (roleUserIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<String> departmentIds = ArrayListUtil.listBeanStringIdValue(departmentPOs, "departmentId", DepartmentPO.class);
|
||||
List<DepartmentUserDTO> departmentUserDTOs = departmentUserService.list(departmentIds);
|
||||
if (departmentUserDTOs.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
clearNoRoleUser(departmentUserDTOs, roleUserIds);
|
||||
return departmentUserDTOs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DepartmentUserDTO> listUserByDepartmentIdAndRoleId(String departmentId, String roleId) {
|
||||
List<DepartmentUserDTO> departmentUserDTOs = departmentUserService.list(departmentId);
|
||||
if (departmentUserDTOs.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<String> roleUserIds = roleUserService.listUserId(roleId);
|
||||
if (roleUserIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
clearNoRoleUser(departmentUserDTOs, roleUserIds);
|
||||
return departmentUserDTOs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除没有角色的用户
|
||||
*
|
||||
* @param departmentUserDTOs
|
||||
* @param roleUserIds
|
||||
*/
|
||||
private void clearNoRoleUser(List<DepartmentUserDTO> departmentUserDTOs, List<String> roleUserIds) {
|
||||
// 去除没有角色的用户
|
||||
for (int i = 0; i < departmentUserDTOs.size(); i++) {
|
||||
DepartmentUserDTO departmentUserDTO = departmentUserDTOs.get(i);
|
||||
boolean isExist = false;
|
||||
for (String roleUserId : roleUserIds) {
|
||||
if (StringUtils.equals(departmentUserDTO.getUserId(), roleUserId)) {
|
||||
isExist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isExist) {
|
||||
departmentUserDTOs.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
departmentUserService.setUser(departmentUserDTOs);
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user