StudentController.java 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package com.ym.mec.student.controller;
  2. import com.ym.mec.auth.api.client.SysUserFeignService;
  3. import com.ym.mec.auth.api.entity.SysUser;
  4. import com.ym.mec.biz.dal.entity.Student;
  5. import com.ym.mec.biz.dal.entity.StudentPreRegistration;
  6. import com.ym.mec.biz.service.StudentService;
  7. import com.ym.mec.common.controller.BaseController;
  8. import io.swagger.annotations.Api;
  9. import io.swagger.annotations.ApiOperation;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.http.HttpStatus;
  12. import org.springframework.web.bind.annotation.PostMapping;
  13. import org.springframework.web.bind.annotation.RequestBody;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RestController;
  16. import javax.annotation.Resource;
  17. import java.util.Date;
  18. @RequestMapping("student")
  19. @Api(tags = "学生服务")
  20. @RestController
  21. public class StudentController extends BaseController {
  22. @Resource
  23. private SysUserFeignService sysUserFeignService;
  24. @Autowired
  25. private StudentService studentService;
  26. @ApiOperation("注册")
  27. @PostMapping(value = "/registering")
  28. public Object registering(@RequestBody StudentPreRegistration studentPreRegistration) {
  29. // 判断用户是否存在
  30. SysUser user = sysUserFeignService.queryUserByMobile(studentPreRegistration.getPhone());
  31. if(user != null && user.getId() != null){
  32. if(user.getUserType().contains("STUDENT")){
  33. return succeed("您已注册,请直接下载APP!");
  34. }
  35. }
  36. return studentService.register(studentPreRegistration) ? succeed() : failed();
  37. }
  38. @ApiOperation("更换声部")
  39. @PostMapping(value = "/updateSubject")
  40. public Object updateSubject(Integer subjectId) {
  41. SysUser user = sysUserFeignService.queryUserInfo();
  42. if (user == null || user.getId() == null) {
  43. return failed(HttpStatus.FORBIDDEN, "请登录");
  44. }
  45. Student student = studentService.get(user.getId());
  46. if (student != null) {
  47. student.setSubjectIdList(subjectId + "");
  48. student.setUpdateTime(new Date());
  49. studentService.update(student);
  50. }
  51. return succeed();
  52. }
  53. }