Browse Source

Merge remote-tracking branch 'origin/master'

宋悦 8 years ago
parent
commit
6bbc63dce6

+ 1 - 1
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/StudentApi.java

@@ -56,7 +56,7 @@ public class StudentApi {
     @ApiOperation(value="按ID查询学生",notes="ID查询")
     @GetMapping("/{id}")
     public ResponseEntity getStudentById(@PathVariable Long id){
-        return new ResponseEntity(studentRepo.findById(id),HttpStatus.OK);
+        return new ResponseEntity(studentRepo.findOne(id),HttpStatus.OK);
     }
 
     @ApiOperation(value="新增学生",notes="新增")

+ 87 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/StudentFaceInfoApi.java

@@ -0,0 +1,87 @@
+package cn.com.qmth.examcloud.service.core.api;
+
+import io.swagger.annotations.ApiOperation;
+
+import java.util.Date;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import cn.com.qmth.examcloud.common.util.ErrorMsg;
+import cn.com.qmth.examcloud.service.core.entity.Student;
+import cn.com.qmth.examcloud.service.core.entity.StudentFaceInfo;
+import cn.com.qmth.examcloud.service.core.repo.StudentFaceInfoRepo;
+import cn.com.qmth.examcloud.service.core.repo.StudentRepo;
+
+/**
+ * 学生照片API
+ */
+@RestController
+@RequestMapping("${app.api.root}/studentFaceInfo")
+public class StudentFaceInfoApi {
+
+    @Autowired
+    StudentFaceInfoRepo studentFaceInfoRepo;
+    @Autowired
+    StudentRepo studentRepo;
+
+    @ApiOperation(value="按身份证查询",notes="查询")
+    @GetMapping("/identityNumber")
+    public ResponseEntity findByIdentityNumber(@RequestParam Long orgId,@RequestParam String identityNumber){
+    	Student student  = studentRepo.findByIdentityNumber(identityNumber);
+    	if(student == null){
+    		return new ResponseEntity(new ErrorMsg("该学生不存在"),HttpStatus.OK);
+    	}
+    	StudentFaceInfo studentFaceInfo = studentFaceInfoRepo.findByStudentId(student.getId());
+    	if(studentFaceInfo == null){
+    		studentFaceInfo = new StudentFaceInfo();
+    		studentFaceInfo.setStudent(student);
+    	}
+        return new ResponseEntity(studentFaceInfo,HttpStatus.OK);
+    }
+    
+    @ApiOperation(value="按学号查询",notes="查询")
+    @GetMapping("/studentCode")
+    public ResponseEntity findByStudentCode(@RequestParam Long orgId,@RequestParam String studentCode){
+    	Student student  = studentRepo.findByUserRootOrgIdAndStudentCode(orgId, studentCode);
+    	if(student == null){
+    		return new ResponseEntity(new ErrorMsg("该学生不存在"),HttpStatus.OK);
+    	}
+    	StudentFaceInfo studentFaceInfo = studentFaceInfoRepo.findByStudentId(student.getId());
+    	if(studentFaceInfo == null){
+    		studentFaceInfo = new StudentFaceInfo();
+    		studentFaceInfo.setStudent(student);
+    	}
+        return new ResponseEntity(studentFaceInfo,HttpStatus.OK);
+    }
+    
+    @ApiOperation(value="按ID查询",notes="ID查询")
+    @GetMapping("/{id}")
+    public ResponseEntity getById(@PathVariable Long id){
+        return new ResponseEntity(studentFaceInfoRepo.findOne(id),HttpStatus.OK);
+    }
+
+    @ApiOperation(value="新增学生照片信息",notes="新增")
+    @PostMapping
+    public ResponseEntity add(@RequestBody StudentFaceInfo studentFaceInfo){
+    	studentFaceInfo.setCreateTime(new Date());
+        return new ResponseEntity(studentFaceInfoRepo.save(studentFaceInfo),HttpStatus.CREATED);
+    }
+
+    @ApiOperation(value="更新学生照片信息",notes="更新")
+    @PutMapping
+    public ResponseEntity update(@RequestBody StudentFaceInfo studentFaceInfo){
+    	studentFaceInfo.setUpdateTime(new Date());
+        return new ResponseEntity(studentFaceInfoRepo.save(studentFaceInfo),HttpStatus.OK);
+    }
+    
+}

+ 105 - 0
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/entity/StudentFaceInfo.java

@@ -0,0 +1,105 @@
+package cn.com.qmth.examcloud.service.core.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import org.springframework.format.annotation.DateTimeFormat;
+
+@Entity
+@Table(name = "ecs_core_student_face_info")
+public class StudentFaceInfo implements Serializable {
+
+	private static final long serialVersionUID = -4192537584889662390L;
+
+	@Id
+	@GeneratedValue
+	private Long id;
+	
+	@OneToOne
+	private Student student;
+
+	private String faceToken;
+
+	private String faceSetToken;
+	
+	private String photoMD5;
+	
+	@Temporal(value = TemporalType.DATE)
+	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	private Date createTime;
+
+	@Temporal(value = TemporalType.DATE)
+	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	private Date updateTime;
+
+	public static long getSerialVersionUID() {
+		return serialVersionUID;
+	}
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public Student getStudent() {
+		return student;
+	}
+
+	public void setStudent(Student student) {
+		this.student = student;
+	}
+
+	public String getFaceToken() {
+		return faceToken;
+	}
+
+	public void setFaceToken(String faceToken) {
+		this.faceToken = faceToken;
+	}
+
+	public String getFaceSetToken() {
+		return faceSetToken;
+	}
+
+	public void setFaceSetToken(String faceSetToken) {
+		this.faceSetToken = faceSetToken;
+	}
+
+	public String getPhotoMD5() {
+		return photoMD5;
+	}
+
+	public void setPhotoMD5(String photoMD5) {
+		this.photoMD5 = photoMD5;
+	}
+
+	public Date getCreateTime() {
+		return createTime;
+	}
+
+	public void setCreateTime(Date createTime) {
+		this.createTime = createTime;
+	}
+
+	public Date getUpdateTime() {
+		return updateTime;
+	}
+
+	public void setUpdateTime(Date updateTime) {
+		this.updateTime = updateTime;
+	}
+
+	public StudentFaceInfo() {
+	}
+}

+ 12 - 0
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/repo/StudentFaceInfoRepo.java

@@ -0,0 +1,12 @@
+package cn.com.qmth.examcloud.service.core.repo;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
+
+import cn.com.qmth.examcloud.service.core.entity.StudentFaceInfo;
+
+public interface StudentFaceInfoRepo extends JpaRepository<StudentFaceInfo,Long>,QueryByExampleExecutor<StudentFaceInfo>{
+
+	StudentFaceInfo findByStudentId(Long studentId);
+
+}

+ 0 - 2
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/repo/StudentRepo.java

@@ -10,8 +10,6 @@ import org.springframework.data.repository.query.QueryByExampleExecutor;
  */
 public interface StudentRepo extends JpaRepository<Student,Long>,QueryByExampleExecutor<Student>{
 
-    Student findById(long id);
-
     Student findByUserId(long userId);
 
 	Student findByIdentityNumber(String identityNumber);