wangwei 7 年之前
父节点
当前提交
bc6effb417

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

@@ -41,7 +41,7 @@ public class AuthController extends ControllerSupport {
 	public void logout() {
 		User user = getAccessUser();
 		if (null == user) {
-			throw new StatusException("P-001001", "用户已登出");
+			throw new StatusException("B-001001", "用户已登出");
 		}
 		authService.logout(user);
 	}
@@ -51,10 +51,10 @@ public class AuthController extends ControllerSupport {
 	public User getLoginUser(@RequestParam String key, @RequestParam String token) {
 
 		if (StringUtils.isBlank(key)) {
-			throw new StatusException("P-001009", "key is blank");
+			throw new StatusException("B-001009", "key is blank");
 		}
 		if (StringUtils.isBlank(token)) {
-			throw new StatusException("P-001010", "token is blank");
+			throw new StatusException("B-001010", "token is blank");
 		}
 
 		return authService.getLoginUser(key, token);

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

@@ -1,7 +1,5 @@
 package cn.com.qmth.examcloud.core.basic.api.controller;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
@@ -16,6 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import cn.com.qmth.examcloud.commons.base.exception.StatusException;
 import cn.com.qmth.examcloud.commons.base.util.ErrorMsg;
+import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
 import cn.com.qmth.examcloud.core.basic.api.StudentFaceCloudService;
 import cn.com.qmth.examcloud.core.basic.api.request.SaveStudentFaceInfoReq;
 import cn.com.qmth.examcloud.core.basic.api.response.SaveStudentFaceInfoResp;
@@ -31,9 +30,7 @@ import io.swagger.annotations.ApiOperation;
  */
 @RestController
 @RequestMapping("${$rmp.ctr.basic}/studentFaceInfo")
-public class StudentFaceInfoController {
-
-	private static final Logger LOG = LoggerFactory.getLogger(StudentFaceInfoController.class);
+public class StudentFaceInfoController extends ControllerSupport {
 
 	@Autowired
 	StudentFaceInfoRepo studentFaceInfoRepo;
@@ -88,6 +85,7 @@ public class StudentFaceInfoController {
 	@ApiOperation(value = "新增学生照片信息", notes = "新增")
 	@PostMapping
 	public Long add(@RequestBody SaveStudentFaceInfoReq req) {
+		req.setOperator(getAccessUser().getDisplayName());
 		SaveStudentFaceInfoResp resp = studentFaceCloudService.saveStudentFaceInfo(req);
 		return resp.getId();
 	}
@@ -95,6 +93,7 @@ public class StudentFaceInfoController {
 	@ApiOperation(value = "更新学生照片信息", notes = "更新")
 	@PutMapping
 	public Long update(@RequestBody SaveStudentFaceInfoReq req) {
+		req.setOperator(getAccessUser().getDisplayName());
 		SaveStudentFaceInfoResp resp = studentFaceCloudService.saveStudentFaceInfo(req);
 		return resp.getId();
 	}

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

@@ -46,17 +46,20 @@ public class StudentFaceCloudServiceProvider extends ControllerSupport
 		Long studentId = req.getStudentId();
 		Student student = studentRepo.findOne(studentId);
 		student.setPhotoPath(req.getPhotoPath());
+		String operator = req.getOperator();
 
 		StudentFaceInfo studentFaceInfo = studentFaceInfoRepo.findByStudentId(student.getId());
 		if (studentFaceInfo == null) {
 			studentFaceInfo = new StudentFaceInfo();
 			studentFaceInfo.setStudent(student);
+			studentFaceInfo.setCreateUser(operator);
 		}
 
+		studentFaceInfo.setUpdateUser(operator);
 		studentFaceInfo.setFaceSetToken(req.getFaceSetToken());
 		studentFaceInfo.setFaceToken(req.getFaceToken());
 		StudentFaceInfo studentFaceInfoSave = studentFaceInfoRepo.save(studentFaceInfo);
-		
+
 		SaveStudentFaceInfoResp resp = new SaveStudentFaceInfoResp();
 		resp.setId(studentFaceInfoSave.getId());
 		return resp;

+ 10 - 0
examcloud-core-basic-api/src/main/java/cn/com/qmth/examcloud/core/basic/api/request/SaveStudentFaceInfoReq.java

@@ -23,6 +23,8 @@ public class SaveStudentFaceInfoReq extends BaseRequest {
 
 	private String photoPath;
 
+	private String operator;
+
 	public Long getRootOrgId() {
 		return rootOrgId;
 	}
@@ -63,4 +65,12 @@ public class SaveStudentFaceInfoReq extends BaseRequest {
 		this.photoPath = photoPath;
 	}
 
+	public String getOperator() {
+		return operator;
+	}
+
+	public void setOperator(String operator) {
+		this.operator = operator;
+	}
+
 }

+ 0 - 23
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/entity/StudentFaceInfo.java

@@ -25,8 +25,6 @@ public class StudentFaceInfo extends JpaEntity {
 
 	private String faceSetToken;
 
-	private String photoMD5;
-
 	/**
 	 * 创建人
 	 */
@@ -37,11 +35,6 @@ public class StudentFaceInfo extends JpaEntity {
 	 */
 	private String updateUser;
 
-	/**
-	 * 创建方式 接口-单个 接口-ZIP批量 照片上传工具
-	 */
-	private String createType;
-
 	public Long getId() {
 		return id;
 	}
@@ -74,14 +67,6 @@ public class StudentFaceInfo extends JpaEntity {
 		this.faceSetToken = faceSetToken;
 	}
 
-	public String getPhotoMD5() {
-		return photoMD5;
-	}
-
-	public void setPhotoMD5(String photoMD5) {
-		this.photoMD5 = photoMD5;
-	}
-
 	public String getCreateUser() {
 		return createUser;
 	}
@@ -98,12 +83,4 @@ public class StudentFaceInfo extends JpaEntity {
 		this.updateUser = updateUser;
 	}
 
-	public String getCreateType() {
-		return createType;
-	}
-
-	public void setCreateType(String createType) {
-		this.createType = createType;
-	}
-
 }

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

@@ -224,11 +224,11 @@ public class AuthServiceImpl implements AuthService {
 		int sessionTimeout = PropertiesUtil.getInt(PropKeys.SESSION_TIMEOUT, 3600);
 		User user = redisClient.get(key, User.class, sessionTimeout);
 		if (null == user) {
-			throw new StatusException("P-001012", "未登录");
+			throw new StatusException("B-001012", "未登录");
 		}
 
 		if (!user.getToken().equals(token)) {
-			throw new StatusException("P-001012", "token错误");
+			throw new StatusException("B-001012", "token错误");
 		}
 
 		return user;

+ 14 - 37
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/StudentFaceInfoService.java

@@ -13,50 +13,27 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-
 @Service
 public class StudentFaceInfoService {
 
-    @Autowired
-    StudentFaceInfoRepo studentFaceInfoRepo;
+	@Autowired
+	StudentFaceInfoRepo studentFaceInfoRepo;
 
 	@Autowired
 	StudentRepo studentRepo;
 
-    @Transactional
-    public StudentFaceInfo save(StudentFaceInfo studentFaceInfo) {
-    	StudentFaceInfo old = studentFaceInfoRepo.findByStudentId(studentFaceInfo.getStudent().getId());
-
-		Student student = studentRepo.findOne(studentFaceInfo.getStudent().getId());
-		if(student != null){
-			student.setPhotoPath(student.getIdentityNumber()+"/"+studentFaceInfo.getPhotoMD5());
-			studentRepo.save(student);
+	/**
+	 * 判断faceSet是否可用 faceSet在ecs_core_student_face_info表中的记录数不允许超过8000
+	 * 
+	 * @param faceSet
+	 * @return
+	 */
+	public boolean judgeFaceSetIsAvailable(String faceSet) {
+		if (StringUtils.isBlank(faceSet)) {
+			return false;
 		}
-		
-    	if(old == null){
-			return studentFaceInfoRepo.save(studentFaceInfo);
-    	}
-    	old.setUpdateTime(new Date());
-    	old.setUpdateUser(studentFaceInfo.getUpdateUser());
-    	old.setFaceSetToken(studentFaceInfo.getFaceSetToken());
-    	old.setFaceToken(studentFaceInfo.getFaceToken());
-    	old.setPhotoMD5(studentFaceInfo.getPhotoMD5());
-    	old.setCreateType(studentFaceInfo.getCreateType());
-        return studentFaceInfoRepo.save(old);
-    }
-    
-    /**
-     * 判断faceSet是否可用
-     * faceSet在ecs_core_student_face_info表中的记录数不允许超过8000
-     * @param faceSet
-     * @return
-     */
-    public boolean judgeFaceSetIsAvailable(String faceSet){
-    	if(StringUtils.isBlank(faceSet)){
-    		return false;
-    	}
-    	Long size = studentFaceInfoRepo.countByFaceSetToken(faceSet);
-    	return size<=8000?true:false;
-    }
+		Long size = studentFaceInfoRepo.countByFaceSetToken(faceSet);
+		return size <= 8000 ? true : false;
+	}
 
 }