|
|
|
@ -10,13 +10,16 @@ import com.glxp.api.constant.BusinessType;
|
|
|
|
|
import com.glxp.api.controller.BaseController;
|
|
|
|
|
import com.glxp.api.entity.auth.AuthAdmin;
|
|
|
|
|
import com.glxp.api.entity.auth.AuthRoleAdmin;
|
|
|
|
|
import com.glxp.api.entity.auth.DeptUserEntity;
|
|
|
|
|
import com.glxp.api.entity.auth.SysRole;
|
|
|
|
|
import com.glxp.api.req.auth.AuthAdminQueryRequest;
|
|
|
|
|
import com.glxp.api.req.auth.AuthAdminSaveRequest;
|
|
|
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
|
|
|
import com.glxp.api.res.auth.AuthAdminResponse;
|
|
|
|
|
import com.glxp.api.res.auth.DeptUserResponse;
|
|
|
|
|
import com.glxp.api.service.auth.AuthAdminService;
|
|
|
|
|
import com.glxp.api.service.auth.AuthRoleAdminService;
|
|
|
|
|
import com.glxp.api.service.auth.DeptUserService;
|
|
|
|
|
import com.glxp.api.service.auth.ISysRoleService;
|
|
|
|
|
import com.glxp.api.util.PasswordUtils;
|
|
|
|
|
import com.glxp.api.util.StreamUtils;
|
|
|
|
@ -68,23 +71,28 @@ public class SysUserController extends BaseController {
|
|
|
|
|
authAdminQueryRequest.setIds(ids);
|
|
|
|
|
}
|
|
|
|
|
List<AuthAdmin> authAdminList = userService.listAdminPage(authAdminQueryRequest);
|
|
|
|
|
// 查询所有的权限
|
|
|
|
|
List<Long> adminIds = authAdminList.stream().map(AuthAdmin::getId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 视图列表
|
|
|
|
|
//查询对应角色和部门
|
|
|
|
|
List<AuthAdminResponse> authAdminResponseList = authAdminList.stream().map(item -> {
|
|
|
|
|
AuthAdminResponse authAdminResponse = new AuthAdminResponse();
|
|
|
|
|
BeanUtils.copyProperties(item, authAdminResponse);
|
|
|
|
|
// List<Long> roles = authRoleAdminList.stream()
|
|
|
|
|
// .filter(authRoleAdmin -> authAdminResponse.getId().equals(authRoleAdmin.getAdmin_id()))
|
|
|
|
|
// .map(AuthRoleAdmin::getRole_id)
|
|
|
|
|
// .collect(Collectors.toList());
|
|
|
|
|
List<Long> roles = sysRoleService.selectRoleListByUserId(authAdminResponse.getId());
|
|
|
|
|
List<DeptUserResponse> deptUserResponses = deptUserService.selectByUserId(authAdminResponse.getId());
|
|
|
|
|
if (CollUtil.isNotEmpty(deptUserResponses)) {
|
|
|
|
|
List<Long> depts = new ArrayList<>();
|
|
|
|
|
String deptName = "";
|
|
|
|
|
for (DeptUserResponse deptUserResponse : deptUserResponses) {
|
|
|
|
|
depts.add(deptUserResponse.getDeptId());
|
|
|
|
|
deptName = deptName + "," + deptUserResponse.getDeptName();
|
|
|
|
|
}
|
|
|
|
|
authAdminResponse.setDeptName(deptName.substring(1));
|
|
|
|
|
authAdminResponse.setDepts(depts);
|
|
|
|
|
}
|
|
|
|
|
authAdminResponse.setRoles(roles);
|
|
|
|
|
return authAdminResponse;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PageInfo<AuthAdmin> authAdminPageInfo = new PageInfo<>(authAdminList);
|
|
|
|
|
PageSimpleResponse<AuthAdminResponse> authAdminPageSimpleResponse = new PageSimpleResponse<>();
|
|
|
|
|
authAdminPageSimpleResponse.setTotal(authAdminPageInfo.getTotal());
|
|
|
|
@ -94,7 +102,6 @@ public class SysUserController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据用户编号获取详细信息
|
|
|
|
|
*
|
|
|
|
@ -153,24 +160,13 @@ public class SysUserController extends BaseController {
|
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
|
}
|
|
|
|
|
AuthAdmin curUser = getUser();
|
|
|
|
|
// if (!curUser.getCustomerId().equals("110")) {
|
|
|
|
|
// CustomerInfoEntity customerInfoEntity = customerInfoService.selectById(curUser.getCustomerId());
|
|
|
|
|
// int max = customerInfoEntity.getUserMax();
|
|
|
|
|
// int count = userService.findCountByCustomerId(authAdminSaveRequest.getCustomerId());
|
|
|
|
|
// if (count >= max) {
|
|
|
|
|
// return ResultVOUtils.error(ResultEnum.DATA_REPEAT, "已超过最大用户数");
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// 检查是否存在相同名称的管理员
|
|
|
|
|
AuthAdmin byUserName = userService.findByUserName(authAdminSaveRequest.getUserName());
|
|
|
|
|
if (byUserName != null) {
|
|
|
|
|
return ResultVOUtils.error(ResultEnum.DATA_REPEAT, "当前管理员已存在");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AuthAdmin authAdmin = new AuthAdmin();
|
|
|
|
|
BeanUtils.copyProperties(authAdminSaveRequest, authAdmin);
|
|
|
|
|
|
|
|
|
|
if (authAdmin.getPassWord() != null) {
|
|
|
|
|
authAdmin.setPassWord(PasswordUtils.authAdminPwd(authAdmin.getPassWord()));
|
|
|
|
|
}
|
|
|
|
@ -187,12 +183,27 @@ public class SysUserController extends BaseController {
|
|
|
|
|
userService.insertUserAuth(authAdmin.getId(), authAdminSaveRequest.getRoles());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//插入部门
|
|
|
|
|
if (CollUtil.isNotEmpty(authAdminSaveRequest.getDepts())) {
|
|
|
|
|
List<DeptUserEntity> list = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i < authAdminSaveRequest.getDepts().size(); i++) {
|
|
|
|
|
DeptUserEntity deptUserEntity = new DeptUserEntity();
|
|
|
|
|
deptUserEntity.setUserId(authAdmin.getId());
|
|
|
|
|
deptUserEntity.setDeptId(authAdminSaveRequest.getDepts().get(i));
|
|
|
|
|
list.add(deptUserEntity);
|
|
|
|
|
}
|
|
|
|
|
deptUserService.insertBatch(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, Long> res = new HashMap<>();
|
|
|
|
|
res.put("id", authAdmin.getId());
|
|
|
|
|
return ResultVOUtils.success(res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
DeptUserService deptUserService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改用户
|
|
|
|
|
*/
|
|
|
|
@ -228,6 +239,18 @@ public class SysUserController extends BaseController {
|
|
|
|
|
userService.insertUserAuth(authAdmin.getId(), authAdminSaveRequest.getRoles());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//修改所属部门
|
|
|
|
|
if (CollUtil.isNotEmpty(authAdminSaveRequest.getDepts())) {
|
|
|
|
|
deptUserService.deleteByUser(authAdminSaveRequest.getId());
|
|
|
|
|
List<DeptUserEntity> list = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i < authAdminSaveRequest.getDepts().size(); i++) {
|
|
|
|
|
DeptUserEntity deptUserEntity = new DeptUserEntity();
|
|
|
|
|
deptUserEntity.setUserId(authAdminSaveRequest.getId());
|
|
|
|
|
deptUserEntity.setDeptId(authAdminSaveRequest.getDepts().get(i));
|
|
|
|
|
list.add(deptUserEntity);
|
|
|
|
|
}
|
|
|
|
|
deptUserService.insertBatch(list);
|
|
|
|
|
}
|
|
|
|
|
return ResultVOUtils.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|