Bläddra i källkod

更新用户类型

wangwei 7 år sedan
förälder
incheckning
afcd341023

+ 12 - 30
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/OrgController.java

@@ -2,7 +2,6 @@ package cn.com.qmth.examcloud.core.basic.api.controller;
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Date;
@@ -17,10 +16,7 @@ import org.apache.commons.fileupload.FileItem;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
@@ -42,7 +38,6 @@ import cn.com.qmth.examcloud.commons.base.util.ErrorMsg;
 import cn.com.qmth.examcloud.commons.base.util.PropertiesUtil;
 import cn.com.qmth.examcloud.commons.base.util.excel.ExcelError;
 import cn.com.qmth.examcloud.commons.web.security.bean.User;
-import cn.com.qmth.examcloud.commons.web.security.entity.AccessUser;
 import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
 import cn.com.qmth.examcloud.core.basic.base.constants.PropKeys;
 import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
@@ -60,8 +55,6 @@ import io.swagger.annotations.ApiOperation;
 @RequestMapping("${$rmp.ctr.basic}/org")
 public class OrgController extends ControllerSupport{
 
-    private static final Logger LOG = LoggerFactory.getLogger(OrgController.class);
-
     @Autowired
     OrgRepo orgRepo;
 
@@ -110,30 +103,19 @@ public class OrgController extends ControllerSupport{
         return new ResponseEntity(orgService.findOne(id), HttpStatus.OK);
     }
 
-    @ApiOperation(value = "查询下属机构不带分页", notes = "不分页")
-    @GetMapping("/sub/{parentId}")
-    public ResponseEntity getOrgByParentId(@PathVariable Long parentId,HttpServletRequest request) {
-        cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
-        if(accessUser != null){
-            if(accessUser.getRootOrgId().longValue() != accessUser.getOrgId().longValue()){
-            	return new ResponseEntity(orgRepo.findById(accessUser.getOrgId()), HttpStatus.OK);
-               // return new ResponseEntity(orgRepo.findById(parentId), HttpStatus.OK);
-            }
-        }
-        return new ResponseEntity(orgRepo.findByParentId(parentId), HttpStatus.OK);
-    }
+	@ApiOperation(value = "查询下属机构不带分页", notes = "不分页")
+	@GetMapping("/sub/{parentId}")
+	public List<Org> getOrgByParentId(@PathVariable Long parentId, HttpServletRequest request) {
+		List<Org> orgList = orgRepo.findByParentId(parentId);
+		return orgList;
+	}
 
-    @ApiOperation(value = "查询下属机构不带分页", notes = "不分页")
-    @GetMapping("/sub/both/{parentId}")
-    public ResponseEntity getBothOrg(@PathVariable Long parentId,HttpServletRequest request) {
-        cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
-        if(accessUser != null){
-            if(accessUser.getRootOrgId().longValue() != accessUser.getOrgId().longValue()){
-                return new ResponseEntity(orgRepo.findById(parentId), HttpStatus.OK);
-            }
-        }
-        return new ResponseEntity(orgRepo.findBothByParentId(parentId), HttpStatus.OK);
-    }
+	@ApiOperation(value = "查询下属机构不带分页", notes = "不分页")
+	@GetMapping("/sub/both/{parentId}")
+	public List<Org> getBothOrg(@PathVariable Long parentId, HttpServletRequest request) {
+		List<Org> orgList = orgRepo.findBothByParentId(parentId);
+		return orgList;
+	}
 
     @ApiOperation(value = "查询下属机构分页带查询", notes = "分页")
     @GetMapping("/sub/{parentId}/{curPage}/{pageSize}")

+ 4 - 4
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/UserController.java

@@ -42,6 +42,7 @@ import cn.com.qmth.examcloud.commons.web.security.enums.UacPolicy;
 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.api.controller.bean.UserForm;
+import cn.com.qmth.examcloud.core.basic.base.enums.UserType;
 import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
 import cn.com.qmth.examcloud.core.basic.dao.RoleRepo;
 import cn.com.qmth.examcloud.core.basic.dao.UserRepo;
@@ -50,7 +51,6 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.RoleEntity;
 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.enums.UserScope;
-import cn.com.qmth.examcloud.core.basic.dao.enums.UserType;
 import cn.com.qmth.examcloud.core.basic.service.bean.UserInfo;
 import cn.com.qmth.examcloud.core.basic.service.impl.UserServiceImpl;
 import io.swagger.annotations.ApiOperation;
@@ -151,7 +151,7 @@ public class UserController extends ControllerSupport {
 	@ApiOperation(value = "按orgId查询用户", notes = "机构id查询机构用户")
 	@GetMapping("/org/{orgId}")
 	public ResponseEntity getUserByOrgId(@PathVariable long orgId) {
-		List<UserEntity> userList = userRepo.findByOrgIdAndType(orgId, UserType.NOT_STUDENT.name());
+		List<UserEntity> userList = userRepo.findByOrgIdAndType(orgId, UserType.COMMON.name());
 		return new ResponseEntity(userList, HttpStatus.OK);
 	}
 
@@ -159,7 +159,7 @@ public class UserController extends ControllerSupport {
 	@GetMapping("/rootOrg/{rootOrgId}")
 	public ResponseEntity getUserByRootOrgId(@PathVariable long rootOrgId) {
 		List<UserEntity> userList = userRepo.findByRootOrgIdAndType(rootOrgId,
-				UserType.NOT_STUDENT.name());
+				UserType.COMMON.name());
 		return new ResponseEntity(userList, HttpStatus.OK);
 	}
 
@@ -237,7 +237,7 @@ public class UserController extends ControllerSupport {
 		userEntity.setRootOrgId(rootOrgId);
 		userEntity.setPassword(userForm.getPassword());
 		userEntity.setScope(UserScope.ORG);
-		userEntity.setType(UserType.NOT_STUDENT);
+		userEntity.setType(UserType.COMMON);
 		userEntity.setUpdateTime(new Date());
 
 		List<UserRole> userRoles = Lists.newArrayList();

+ 2 - 2
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/entity/Org.java

@@ -1,6 +1,5 @@
 package cn.com.qmth.examcloud.core.basic.dao.entity;
 
-import java.io.Serializable;
 import java.util.Date;
 
 import javax.persistence.Entity;
@@ -16,6 +15,7 @@ import javax.validation.constraints.NotNull;
 import org.springframework.format.annotation.DateTimeFormat;
 
 import cn.com.qmth.examcloud.commons.base.util.excel.ExcelProperty;
+import cn.com.qmth.examcloud.commons.web.cloud.api.JsonSerializable;
 import cn.com.qmth.examcloud.core.basic.dao.enums.OrgType;
 
 /**
@@ -23,7 +23,7 @@ import cn.com.qmth.examcloud.core.basic.dao.enums.OrgType;
  */
 @Entity
 @Table(name = "ecs_core_org")
-public class Org implements Serializable{
+public class Org implements JsonSerializable{
 
     private static final long serialVersionUID = -592353272256492483L;
 

+ 1 - 1
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/entity/UserEntity.java

@@ -9,9 +9,9 @@ import javax.validation.constraints.NotNull;
 import org.springframework.format.annotation.DateTimeFormat;
 
 import cn.com.qmth.examcloud.commons.web.cloud.api.JsonSerializable;
+import cn.com.qmth.examcloud.core.basic.base.enums.UserType;
 import cn.com.qmth.examcloud.core.basic.dao.enums.Gender;
 import cn.com.qmth.examcloud.core.basic.dao.enums.UserScope;
-import cn.com.qmth.examcloud.core.basic.dao.enums.UserType;
 
 /**
  * Created by songyue on 17/1/13.

+ 0 - 8
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/enums/UserType.java

@@ -1,8 +0,0 @@
-package cn.com.qmth.examcloud.core.basic.dao.enums;
-
-/**
- * Created by songyue on 17/2/22.
- */
-public enum UserType {
-    NOT_STUDENT,STUDENT,PRINT
-}

+ 2 - 2
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/OrgService.java

@@ -21,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
 import cn.com.qmth.examcloud.commons.base.util.excel.ExcelError;
 import cn.com.qmth.examcloud.commons.base.util.excel.ExcelReader;
 import cn.com.qmth.examcloud.commons.base.util.excel.ExcelReaderHandle;
+import cn.com.qmth.examcloud.core.basic.base.enums.UserType;
 import cn.com.qmth.examcloud.core.basic.dao.ExamSiteRepo;
 import cn.com.qmth.examcloud.core.basic.dao.OrgMemRepo;
 import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
@@ -32,7 +33,6 @@ 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.enums.OrgType;
 import cn.com.qmth.examcloud.core.basic.dao.enums.UserScope;
-import cn.com.qmth.examcloud.core.basic.dao.enums.UserType;
 import cn.com.qmth.examcloud.core.basic.service.bean.OrgDto;
 
 @Service
@@ -111,7 +111,7 @@ public class OrgService {
 	 * @param tempOrg
      */
 	private void createOrgUser(Org tempOrg){
-		UserEntity user = new UserEntity(tempOrg.getName(), UserScope.ORG, tempOrg.getRootId(), tempOrg.getId(), UserType.NOT_STUDENT);
+		UserEntity user = new UserEntity(tempOrg.getName(), UserScope.ORG, tempOrg.getRootId(), tempOrg.getId(), UserType.COMMON);
 		user.setLoginName(tempOrg.getCode());
 		user.setEnable(true);
 		user.setCreateTime(new Date());

+ 1 - 1
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/StudentService.java

@@ -19,6 +19,7 @@ import org.springframework.stereotype.Service;
 
 import cn.com.qmth.examcloud.commons.base.util.ErrorMsg;
 import cn.com.qmth.examcloud.commons.web.security.AccessCtrlUtil;
+import cn.com.qmth.examcloud.core.basic.base.enums.UserType;
 import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
 import cn.com.qmth.examcloud.core.basic.dao.StudentRepo;
 import cn.com.qmth.examcloud.core.basic.dao.UserRepo;
@@ -29,7 +30,6 @@ 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.enums.LoginType;
 import cn.com.qmth.examcloud.core.basic.dao.enums.UserScope;
-import cn.com.qmth.examcloud.core.basic.dao.enums.UserType;
 import cn.com.qmth.examcloud.core.basic.service.bean.UserInfo;
 
 /**

+ 4 - 4
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/UserServiceImpl.java

@@ -29,6 +29,7 @@ import cn.com.qmth.examcloud.commons.web.security.AccessUserOpsForRedis;
 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.core.basic.base.enums.AccountType;
+import cn.com.qmth.examcloud.core.basic.base.enums.UserType;
 import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
 import cn.com.qmth.examcloud.core.basic.dao.StudentRepo;
 import cn.com.qmth.examcloud.core.basic.dao.ThirdPartyAccessRepo;
@@ -46,7 +47,6 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.UserLogin;
 import cn.com.qmth.examcloud.core.basic.dao.entity.UserOpsLog;
 import cn.com.qmth.examcloud.core.basic.dao.entity.UserRole;
 import cn.com.qmth.examcloud.core.basic.dao.enums.UserScope;
-import cn.com.qmth.examcloud.core.basic.dao.enums.UserType;
 import cn.com.qmth.examcloud.core.basic.service.AuthService;
 import cn.com.qmth.examcloud.core.basic.service.UserService;
 import cn.com.qmth.examcloud.core.basic.service.bean.LoginInfo;
@@ -225,7 +225,7 @@ public class UserServiceImpl  implements UserService{
     public void initPassword(long userId){
         UserEntity user = userRepo.findOne(userId);
         //根据用户类型采用不同的初始化策略
-        if(user.getType() == UserType.NOT_STUDENT){
+        if(user.getType() == UserType.COMMON){
             //初始化为默认密码
             user.setPassword(Consts.DEFAULT_PASSWORD);
 
@@ -485,7 +485,7 @@ public class UserServiceImpl  implements UserService{
 	public Specification<UserEntity> getSpecification(UserEntity user){
 		Specification<UserEntity> specification = (root, query, cb) -> {
 			List<Predicate> predicates = new ArrayList<>();
-			predicates.add(cb.equal(root.get("type"),UserType.NOT_STUDENT));
+			predicates.add(cb.equal(root.get("type"),UserType.COMMON));
             predicates.add(cb.equal(root.get("rootOrgId"),user.getRootOrgId()));
             Join join = root.join("userRoles");
             predicates.add(cb.equal(join.get("roleCode"), RoleMeta.MARKER.name()));
@@ -530,7 +530,7 @@ public class UserServiceImpl  implements UserService{
 		userRoles.add(userRole);
 		user.setUserRoles(userRoles);
 		user.setScope(UserScope.ORG);
-		user.setType(UserType.NOT_STUDENT);
+		user.setType(UserType.COMMON);
 		user.setCreateTime(new Date());
 		return userRepo.save(user);
 	}