|
@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
+import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -12,12 +13,15 @@ import java.util.stream.Stream;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
import org.apache.commons.lang.StringEscapeUtils;
|
|
import org.apache.commons.lang.StringEscapeUtils;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.PageImpl;
|
|
import org.springframework.data.domain.PageImpl;
|
|
import org.springframework.data.domain.PageRequest;
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
|
+import org.springframework.data.domain.Sort;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
-import org.springframework.util.StringUtils;
|
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
@@ -29,13 +33,17 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
|
+
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.base.util.ErrorMsg;
|
|
import cn.com.qmth.examcloud.commons.base.util.ErrorMsg;
|
|
|
|
+import cn.com.qmth.examcloud.commons.web.helpers.page.PageInfo;
|
|
import cn.com.qmth.examcloud.commons.web.security.annotation.Uac;
|
|
import cn.com.qmth.examcloud.commons.web.security.annotation.Uac;
|
|
import cn.com.qmth.examcloud.commons.web.security.entity.AccessUser;
|
|
import cn.com.qmth.examcloud.commons.web.security.entity.AccessUser;
|
|
import cn.com.qmth.examcloud.commons.web.security.enums.RoleMeta;
|
|
import cn.com.qmth.examcloud.commons.web.security.enums.RoleMeta;
|
|
import cn.com.qmth.examcloud.commons.web.security.enums.UacPolicy;
|
|
import cn.com.qmth.examcloud.commons.web.security.enums.UacPolicy;
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.controller.bean.FullUserInfo;
|
|
import cn.com.qmth.examcloud.core.basic.dao.UserRepo;
|
|
import cn.com.qmth.examcloud.core.basic.dao.UserRepo;
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.UserEntity;
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.UserEntity;
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.UserRole;
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.UserRole;
|
|
@@ -57,27 +65,49 @@ public class UserController extends ControllerSupport{
|
|
@Autowired
|
|
@Autowired
|
|
UserRepo userRepo;
|
|
UserRepo userRepo;
|
|
|
|
|
|
|
|
+ @ApiOperation(value = "查询所有用户", notes = "")
|
|
|
|
+ @GetMapping("/all/{curPage}/{pageSize}")
|
|
|
|
+ public PageInfo<FullUserInfo> getAllUser(@PathVariable Integer curPage,
|
|
|
|
+ @PathVariable Integer pageSize, @RequestParam Long orgId,
|
|
|
|
+ @RequestParam String loginName, @RequestParam String name, @RequestParam String enable,
|
|
|
|
+ @RequestParam String roleCode, @RequestParam String type) {
|
|
|
|
|
|
- @ApiOperation(value = "查询所有用户", notes = "分页带查询")
|
|
|
|
- @GetMapping("/all/{curPage}/{pageSize}")
|
|
|
|
- public ResponseEntity getAllUser(@ModelAttribute UserEntity userCriteria,
|
|
|
|
- @PathVariable Integer curPage,
|
|
|
|
- @PathVariable Integer pageSize,
|
|
|
|
- HttpServletRequest request) {
|
|
|
|
- cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
|
|
- if (accessUser != null) {
|
|
|
|
- if (accessUser.getRootOrgId() == 0) {
|
|
|
|
- return new ResponseEntity(userService.findOrgUser(userCriteria,
|
|
|
|
- new PageRequest(curPage - 1, pageSize)), HttpStatus.OK);
|
|
|
|
- } else {
|
|
|
|
- userCriteria.setRootOrgId(accessUser.getRootOrgId());
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- return new ResponseEntity(HttpStatus.NOT_FOUND);
|
|
|
|
- }
|
|
|
|
- return new ResponseEntity(userService.findAll(userCriteria,
|
|
|
|
- new PageRequest(curPage - 1, pageSize)), HttpStatus.OK);
|
|
|
|
- }
|
|
|
|
|
|
+ cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
|
|
+ if ((!isSuperAdmin()) && (!orgId.equals(accessUser.getRootOrgId()))) {
|
|
|
|
+ throw new StatusException("B-150001", "非法请求");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Pageable pageable = new PageRequest(curPage - 1, pageSize, Sort.Direction.DESC,
|
|
|
|
+ "update_time");
|
|
|
|
+
|
|
|
|
+ loginName = "%" + loginName.trim() + "%";
|
|
|
|
+ name = "%" + name.trim() + "%";
|
|
|
|
+
|
|
|
|
+ Page<UserEntity> userList = userRepo.findAll(orgId, name, loginName, type, roleCode,
|
|
|
|
+ pageable);
|
|
|
|
+ Iterator<UserEntity> iterator = userList.iterator();
|
|
|
|
+
|
|
|
|
+ List<FullUserInfo> fullUserInfoList = Lists.newArrayList();
|
|
|
|
+ while (iterator.hasNext()) {
|
|
|
|
+ UserEntity next = iterator.next();
|
|
|
|
+ FullUserInfo bean = new FullUserInfo();
|
|
|
|
+ bean.setId(next.getId());
|
|
|
|
+ bean.setLoginName(next.getLoginName());
|
|
|
|
+ bean.setName(next.getName());
|
|
|
|
+ bean.setRootOrgId(next.getRootOrgId());
|
|
|
|
+
|
|
|
|
+ List<UserRole> userRoles = next.getUserRoles();
|
|
|
|
+ for (UserRole cur : userRoles) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ fullUserInfoList.add(bean);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ PageInfo<FullUserInfo> ret = new PageInfo<FullUserInfo>();
|
|
|
|
+ ret.setList(fullUserInfoList);
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
|
|
@ApiOperation(value = "按id查询用户", notes = "id查询")
|
|
@ApiOperation(value = "按id查询用户", notes = "id查询")
|
|
@GetMapping("/{id}")
|
|
@GetMapping("/{id}")
|