处理异常问题
This commit is contained in:
parent
f6953704bc
commit
1075fb2eff
@ -2,7 +2,6 @@ package ink.wgink.interfaces.role;
|
|||||||
|
|
||||||
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,7 +21,7 @@ public interface IRoleDepartmentUserBaseService {
|
|||||||
* @param areaCode 地区编码
|
* @param areaCode 地区编码
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<DepartmentUserDTO> listUserByRoleIdAndAreaCode(String roleId, String areaCode) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException;
|
List<DepartmentUserDTO> listUserByRoleIdAndAreaCode(String roleId, String areaCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取指定部门中指定角色的用户列表接口
|
* 获取指定部门中指定角色的用户列表接口
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package ink.wgink.util;
|
package ink.wgink.util;
|
||||||
|
|
||||||
|
import ink.wgink.exceptions.base.SystemException;
|
||||||
import ink.wgink.util.string.WStringUtil;
|
import ink.wgink.util.string.WStringUtil;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
@ -44,19 +45,23 @@ public class ArrayListUtil {
|
|||||||
* @param beanClass
|
* @param beanClass
|
||||||
* @param <T>
|
* @param <T>
|
||||||
* @return
|
* @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 {
|
public static <T> List<String> listBeanStringIdValue(List<T> beans, String propertyName, Class<T> beanClass) {
|
||||||
|
if (beans.isEmpty()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
Set<String> beanStringIdSet = new HashSet<>();
|
Set<String> beanStringIdSet = new HashSet<>();
|
||||||
for (Object bean : beans) {
|
try {
|
||||||
Method method = bean.getClass().getMethod("get" + WStringUtil.firstToUpper(propertyName));
|
for (Object bean : beans) {
|
||||||
Object result = method.invoke(bean);
|
Method method = bean.getClass().getMethod("get" + WStringUtil.firstToUpper(propertyName));
|
||||||
if (result == null) {
|
Object result = method.invoke(bean);
|
||||||
continue;
|
if (result == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
beanStringIdSet.add(result.toString());
|
||||||
}
|
}
|
||||||
beanStringIdSet.add(result.toString());
|
} catch (Exception e) {
|
||||||
|
throw new SystemException(e);
|
||||||
}
|
}
|
||||||
return new ArrayList<>(beanStringIdSet);
|
return new ArrayList<>(beanStringIdSet);
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -36,7 +35,7 @@ public class RoleDepartmentUserServiceImpl extends DefaultBaseService implements
|
|||||||
private IDepartmentUserBaseService departmentUserBaseService;
|
private IDepartmentUserBaseService departmentUserBaseService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DepartmentUserDTO> listUserByRoleIdAndAreaCode(String roleId, String areaCode) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
|
public List<DepartmentUserDTO> listUserByRoleIdAndAreaCode(String roleId, String areaCode) {
|
||||||
// 地区下所有组织机构
|
// 地区下所有组织机构
|
||||||
List<DepartmentPO> departmentPOs = departmentBaseService.listPOByAreaCode(areaCode);
|
List<DepartmentPO> departmentPOs = departmentBaseService.listPOByAreaCode(areaCode);
|
||||||
if (departmentPOs.isEmpty()) {
|
if (departmentPOs.isEmpty()) {
|
||||||
|
@ -12,7 +12,6 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,7 +37,7 @@ public class RoleDepartmentUserController extends DefaultBaseController {
|
|||||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
@GetMapping("list-user/{roleId}/{areaCode}")
|
@GetMapping("list-user/{roleId}/{areaCode}")
|
||||||
public List<DepartmentUserDTO> listUserByRoleIdAndAreaCode(@PathVariable("roleId") String roleId,
|
public List<DepartmentUserDTO> listUserByRoleIdAndAreaCode(@PathVariable("roleId") String roleId,
|
||||||
@PathVariable("areaCode") String areaCode) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
|
@PathVariable("areaCode") String areaCode) {
|
||||||
return roleDepartmentUserService.listUserByRoleIdAndAreaCode(roleId, areaCode);
|
return roleDepartmentUserService.listUserByRoleIdAndAreaCode(roleId, areaCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -34,7 +33,7 @@ public class RoleDepartmentUserServiceImpl extends DefaultBaseService implements
|
|||||||
private IDepartmentUserService departmentUserService;
|
private IDepartmentUserService departmentUserService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DepartmentUserDTO> listUserByRoleIdAndAreaCode(String roleId, String areaCode) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
|
public List<DepartmentUserDTO> listUserByRoleIdAndAreaCode(String roleId, String areaCode) {
|
||||||
// 地区下所有组织机构
|
// 地区下所有组织机构
|
||||||
List<DepartmentPO> departmentPOs = departmentService.listPOByAreaCode(areaCode);
|
List<DepartmentPO> departmentPOs = departmentService.listPOByAreaCode(areaCode);
|
||||||
if (departmentPOs.isEmpty()) {
|
if (departmentPOs.isEmpty()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user