|
@@ -35,74 +35,81 @@ import cn.com.qmth.examcloud.core.basic.service.impl.StudentFaceInfoService;
|
|
|
@RequestMapping("${$rmp.ctr.basic}/studentFaceInfo")
|
|
|
public class StudentFaceInfoController {
|
|
|
|
|
|
- private static final Logger LOG = LoggerFactory.getLogger(StudentFaceInfoController.class);
|
|
|
-
|
|
|
- @Autowired
|
|
|
- StudentFaceInfoRepo studentFaceInfoRepo;
|
|
|
- @Autowired
|
|
|
- StudentFaceInfoService studentFaceInfoService;
|
|
|
- @Autowired
|
|
|
- StudentRepo studentRepo;
|
|
|
-
|
|
|
- @ApiOperation(value = "按身份证查询", notes = "查询")
|
|
|
- @GetMapping("/identityNumber")
|
|
|
- public ResponseEntity findByIdentityNumber(@RequestParam String identityNumber, @RequestParam Long orgId) {
|
|
|
- Student student = studentRepo.findByIdentityNumberAndRootOrgId(identityNumber, orgId);
|
|
|
- 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.findByStudentCodeAndRootOrgId(studentCode,orgId);
|
|
|
- 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) {
|
|
|
- return new ResponseEntity(studentFaceInfoService.save(studentFaceInfo), HttpStatus.CREATED);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "更新学生照片信息", notes = "更新")
|
|
|
- @PutMapping
|
|
|
- public ResponseEntity update(@RequestBody StudentFaceInfo studentFaceInfo) {
|
|
|
- StudentFaceInfo studentFaceInfo4Update = studentFaceInfoRepo.findByStudentId(studentFaceInfo.getStudent().getId());
|
|
|
- LOG.info("根据学生id" + studentFaceInfo.getStudent().getId() + "找到照片信息:" + studentFaceInfo4Update.getId());
|
|
|
- studentFaceInfo4Update.setUpdateTime(new Date());
|
|
|
- studentFaceInfo4Update.setUpdateUser(studentFaceInfo.getUpdateUser());
|
|
|
- studentFaceInfo4Update.setCreateType(studentFaceInfo.getCreateType());
|
|
|
- studentFaceInfo4Update.setPhotoMD5(studentFaceInfo.getPhotoMD5());
|
|
|
- studentFaceInfo4Update.setFaceToken(studentFaceInfo.getFaceToken());
|
|
|
- studentFaceInfo4Update.setFaceSetToken(studentFaceInfo.getFaceSetToken());
|
|
|
- Student student = studentRepo.findOne(studentFaceInfo.getStudent().getId());
|
|
|
- if(student != null){
|
|
|
- student.setPhotoPath(student.getIdentityNumber()+"/"+studentFaceInfo.getPhotoMD5());
|
|
|
- studentRepo.save(student);
|
|
|
- }
|
|
|
- return new ResponseEntity(studentFaceInfoRepo.save(studentFaceInfo4Update), HttpStatus.OK);
|
|
|
- }
|
|
|
+ private static final Logger LOG = LoggerFactory.getLogger(StudentFaceInfoController.class);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ StudentFaceInfoRepo studentFaceInfoRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ StudentFaceInfoService studentFaceInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ StudentRepo studentRepo;
|
|
|
+
|
|
|
+ @ApiOperation(value = "按身份证查询", notes = "查询")
|
|
|
+ @GetMapping("/identityNumber")
|
|
|
+ public ResponseEntity findByIdentityNumber(@RequestParam String identityNumber,
|
|
|
+ @RequestParam Long orgId) {
|
|
|
+ Student student = studentRepo.findByIdentityNumberAndRootOrgId(identityNumber, orgId);
|
|
|
+ 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.findByStudentCodeAndRootOrgId(studentCode, orgId);
|
|
|
+ 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 StudentFaceInfo add(@RequestBody StudentFaceInfo studentFaceInfo) {
|
|
|
+ StudentFaceInfo saved = studentFaceInfoService.save(studentFaceInfo);
|
|
|
+ return saved;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "更新学生照片信息", notes = "更新")
|
|
|
+ @PutMapping
|
|
|
+ public ResponseEntity update(@RequestBody StudentFaceInfo studentFaceInfo) {
|
|
|
+ StudentFaceInfo studentFaceInfo4Update = studentFaceInfoRepo
|
|
|
+ .findByStudentId(studentFaceInfo.getStudent().getId());
|
|
|
+ LOG.info("根据学生id" + studentFaceInfo.getStudent().getId() + "找到照片信息:"
|
|
|
+ + studentFaceInfo4Update.getId());
|
|
|
+ studentFaceInfo4Update.setUpdateTime(new Date());
|
|
|
+ studentFaceInfo4Update.setUpdateUser(studentFaceInfo.getUpdateUser());
|
|
|
+ studentFaceInfo4Update.setCreateType(studentFaceInfo.getCreateType());
|
|
|
+ studentFaceInfo4Update.setPhotoMD5(studentFaceInfo.getPhotoMD5());
|
|
|
+ studentFaceInfo4Update.setFaceToken(studentFaceInfo.getFaceToken());
|
|
|
+ studentFaceInfo4Update.setFaceSetToken(studentFaceInfo.getFaceSetToken());
|
|
|
+ Student student = studentRepo.findOne(studentFaceInfo.getStudent().getId());
|
|
|
+ if (student != null) {
|
|
|
+ student.setPhotoPath(student.getIdentityNumber() + "/" + studentFaceInfo.getPhotoMD5());
|
|
|
+ studentRepo.save(student);
|
|
|
+ }
|
|
|
+ return new ResponseEntity(studentFaceInfoRepo.save(studentFaceInfo4Update), HttpStatus.OK);
|
|
|
+ }
|
|
|
|
|
|
}
|