|
@@ -94,12 +94,10 @@ public class UserController extends ControllerSupport {
|
|
|
*/
|
|
|
@ApiOperation(value = "查询所有用户", notes = "")
|
|
|
@GetMapping("all/{curPage}/{pageSize}")
|
|
|
- public PageInfo<UserDomain> getUserPage(@PathVariable Integer curPage,
|
|
|
- @PathVariable Integer pageSize, @RequestParam(required = false) Long rootOrgId,
|
|
|
- @RequestParam String loginName, @RequestParam String name,
|
|
|
- @RequestParam(required = false) Boolean enable,
|
|
|
- @RequestParam(required = false) Long roleId, @RequestParam(required = false) Long orgId,
|
|
|
- @RequestParam(required = false) String roleCode) {
|
|
|
+ public PageInfo<UserDomain> getUserPage(@PathVariable Integer curPage, @PathVariable Integer pageSize,
|
|
|
+ @RequestParam(required = false) Long rootOrgId, @RequestParam String loginName, @RequestParam String name,
|
|
|
+ @RequestParam(required = false) Boolean enable, @RequestParam(required = false) Long roleId,
|
|
|
+ @RequestParam(required = false) Long orgId, @RequestParam(required = false) String roleCode) {
|
|
|
|
|
|
User accessUser = getAccessUser();
|
|
|
|
|
@@ -127,8 +125,7 @@ public class UserController extends ControllerSupport {
|
|
|
} else if (StringUtils.isNotBlank(roleCode)) {
|
|
|
RoleEntity roleEntity = roleRepo.findByCodeAndRootOrgIdIsNull(roleCode.trim());
|
|
|
if (null == roleEntity) {
|
|
|
- roleEntity = roleRepo.findByCodeAndRootOrgId(roleCode.trim(),
|
|
|
- accessUser.getRootOrgId());
|
|
|
+ roleEntity = roleRepo.findByCodeAndRootOrgId(roleCode.trim(), accessUser.getRootOrgId());
|
|
|
}
|
|
|
if (null == roleEntity) {
|
|
|
throw new StatusException("B-150002", "角色不存在");
|
|
@@ -155,8 +152,7 @@ public class UserController extends ControllerSupport {
|
|
|
predicates.add(cb.equal(root.get("enable"), enable));
|
|
|
}
|
|
|
if (null != finalRoleId) {
|
|
|
- Subquery<UserRoleRelationEntity> subquery = query
|
|
|
- .subquery(UserRoleRelationEntity.class);
|
|
|
+ Subquery<UserRoleRelationEntity> subquery = query.subquery(UserRoleRelationEntity.class);
|
|
|
Root<UserRoleRelationEntity> subRoot = subquery.from(UserRoleRelationEntity.class);
|
|
|
subquery.select(subRoot.get("userId"));
|
|
|
Predicate p1 = cb.equal(subRoot.get("roleId"), finalRoleId);
|
|
@@ -166,8 +162,7 @@ public class UserController extends ControllerSupport {
|
|
|
}
|
|
|
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
};
|
|
|
- Pageable pageable = new PageRequest(curPage - 1, pageSize, Sort.Direction.DESC,
|
|
|
- "updateTime");
|
|
|
+ Pageable pageable = new PageRequest(curPage - 1, pageSize, Sort.Direction.DESC, "updateTime");
|
|
|
|
|
|
Page<UserEntity> userList = userRepo.findAll(specification, pageable);
|
|
|
|
|
@@ -184,6 +179,7 @@ public class UserController extends ControllerSupport {
|
|
|
bean.setUpdateTime(next.getUpdateTime());
|
|
|
bean.setCreationTime(next.getCreationTime());
|
|
|
bean.setOrgId(next.getOrgId());
|
|
|
+ bean.setPhoneNumber(next.getPhoneNumber());
|
|
|
if (null != bean.getOrgId()) {
|
|
|
OrgEntity org = orgRepo.findOne(Long.valueOf(bean.getOrgId()));
|
|
|
if (null != org) {
|
|
@@ -194,8 +190,7 @@ public class UserController extends ControllerSupport {
|
|
|
bean.setRootOrgName(rootOrg.getName());
|
|
|
bean.setEnable(next.getEnable());
|
|
|
|
|
|
- List<UserRoleRelationEntity> relationList = userRoleRelationRepo
|
|
|
- .findAllByUserId(next.getId());
|
|
|
+ List<UserRoleRelationEntity> relationList = userRoleRelationRepo.findAllByUserId(next.getId());
|
|
|
List<String> roleNameList = Lists.newArrayList();
|
|
|
List<Long> roleIdList = Lists.newArrayList();
|
|
|
List<String> roleCodeList = Lists.newArrayList();
|
|
@@ -224,10 +219,8 @@ public class UserController extends ControllerSupport {
|
|
|
@ApiOperation(value = "模糊查询用户", notes = "")
|
|
|
@GetMapping("query")
|
|
|
public List<UserDomain> query(@RequestParam(required = false) Long rootOrgId,
|
|
|
- @RequestParam(required = false) String rootOrgCode,
|
|
|
- @RequestParam(required = false) String loginName,
|
|
|
- @RequestParam(required = false) String name,
|
|
|
- @RequestParam(required = false) Boolean enable,
|
|
|
+ @RequestParam(required = false) String rootOrgCode, @RequestParam(required = false) String loginName,
|
|
|
+ @RequestParam(required = false) String name, @RequestParam(required = false) Boolean enable,
|
|
|
@RequestParam(required = false) Long roleId, @RequestParam(required = false) Long orgId,
|
|
|
@RequestParam(required = false) String roleCode) {
|
|
|
|
|
@@ -292,8 +285,7 @@ public class UserController extends ControllerSupport {
|
|
|
predicates.add(cb.equal(root.get("enable"), enable));
|
|
|
}
|
|
|
if (null != finalRoleId) {
|
|
|
- Subquery<UserRoleRelationEntity> subquery = query
|
|
|
- .subquery(UserRoleRelationEntity.class);
|
|
|
+ Subquery<UserRoleRelationEntity> subquery = query.subquery(UserRoleRelationEntity.class);
|
|
|
Root<UserRoleRelationEntity> subRoot = subquery.from(UserRoleRelationEntity.class);
|
|
|
subquery.select(subRoot.get("userId"));
|
|
|
Predicate p1 = cb.equal(subRoot.get("roleId"), finalRoleId);
|
|
@@ -331,8 +323,7 @@ public class UserController extends ControllerSupport {
|
|
|
bean.setRootOrgName(rootOrg.getName());
|
|
|
bean.setEnable(next.getEnable());
|
|
|
|
|
|
- List<UserRoleRelationEntity> relationList = userRoleRelationRepo
|
|
|
- .findAllByUserId(next.getId());
|
|
|
+ List<UserRoleRelationEntity> relationList = userRoleRelationRepo.findAllByUserId(next.getId());
|
|
|
List<String> roleNameList = Lists.newArrayList();
|
|
|
List<Long> roleIdList = Lists.newArrayList();
|
|
|
List<String> roleCodeList = Lists.newArrayList();
|
|
@@ -542,7 +533,7 @@ public class UserController extends ControllerSupport {
|
|
|
userEntity.setId(userForm.getId());
|
|
|
userEntity.setEnable(userForm.getEnable());
|
|
|
userEntity.setLoginName(userForm.getLoginName());
|
|
|
- userEntity.setPhoneNumber(userForm.getMobile());
|
|
|
+ userEntity.setPhoneNumber(userForm.getPhoneNumber());
|
|
|
userEntity.setName(userForm.getName());
|
|
|
userEntity.setOrgId(orgId);
|
|
|
userEntity.setRootOrgId(rootOrgId);
|
|
@@ -574,8 +565,7 @@ public class UserController extends ControllerSupport {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- UserRoleRelationEntity relation = new UserRoleRelationEntity(saved.getId(),
|
|
|
- curRoleEntity.getId());
|
|
|
+ UserRoleRelationEntity relation = new UserRoleRelationEntity(saved.getId(), curRoleEntity.getId());
|
|
|
userRoles.add(relation);
|
|
|
}
|
|
|
|
|
@@ -614,8 +604,7 @@ public class UserController extends ControllerSupport {
|
|
|
@ApiOperation(value = "重置用户密码", notes = "重置密码")
|
|
|
@PutMapping("/resetPass/{id}")
|
|
|
public void resetPass(@PathVariable String id) {
|
|
|
- List<Long> ids = Stream.of(id.split(",")).map(s -> Long.parseLong(s.trim()))
|
|
|
- .collect(Collectors.toList());
|
|
|
+ List<Long> ids = Stream.of(id.split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
|
|
|
|
|
|
for (Long userId : ids) {
|
|
|
if (isSuperAdmin(userId)) {
|
|
@@ -630,8 +619,7 @@ public class UserController extends ControllerSupport {
|
|
|
@ApiOperation(value = "启用用户", notes = "启用用户")
|
|
|
@PutMapping("/enable/{ids}")
|
|
|
public List<String> enableUser(@PathVariable String ids) {
|
|
|
- List<Long> userIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
|
|
|
- .collect(Collectors.toList());
|
|
|
+ List<Long> userIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
|
|
|
List<String> ret = Lists.newArrayList();
|
|
|
for (Long userId : userIds) {
|
|
|
if (isSuperAdmin(userId)) {
|
|
@@ -648,8 +636,7 @@ public class UserController extends ControllerSupport {
|
|
|
@ApiOperation(value = "禁用用户", notes = "禁用用户")
|
|
|
@PutMapping("/disable/{ids}")
|
|
|
public List<String> disableUser(@PathVariable String ids) {
|
|
|
- List<Long> userIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
|
|
|
- .collect(Collectors.toList());
|
|
|
+ List<Long> userIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
|
|
|
List<String> ret = Lists.newArrayList();
|
|
|
for (Long userId : userIds) {
|
|
|
if (isSuperAdmin(userId)) {
|
|
@@ -686,8 +673,7 @@ public class UserController extends ControllerSupport {
|
|
|
@ApiOperation(value = "按id删除用户", notes = "删除")
|
|
|
@DeleteMapping("/{ids}")
|
|
|
public void deleteUser(@PathVariable String ids) {
|
|
|
- List<Long> userIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
|
|
|
- .collect(Collectors.toList());
|
|
|
+ List<Long> userIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
|
|
|
for (Long userId : userIds) {
|
|
|
userRepo.delete(userId);
|
|
|
}
|