|
@@ -11,7 +11,10 @@ import com.schoolinout.common.core.redis.RedisCache;
|
|
import com.schoolinout.common.exception.ServiceException;
|
|
import com.schoolinout.common.exception.ServiceException;
|
|
import com.schoolinout.common.exception.user.UserPasswordNotMatchException;
|
|
import com.schoolinout.common.exception.user.UserPasswordNotMatchException;
|
|
import com.schoolinout.common.utils.StringUtils;
|
|
import com.schoolinout.common.utils.StringUtils;
|
|
|
|
+import com.schoolinout.common.validate.groups.Login;
|
|
|
|
+import com.schoolinout.common.validate.groups.Save;
|
|
import com.schoolinout.framework.web.service.TokenService;
|
|
import com.schoolinout.framework.web.service.TokenService;
|
|
|
|
+import com.schoolinout.system.domain.Parent;
|
|
import com.schoolinout.system.domain.ParentStudent;
|
|
import com.schoolinout.system.domain.ParentStudent;
|
|
import com.schoolinout.system.domain.Student;
|
|
import com.schoolinout.system.domain.Student;
|
|
import com.schoolinout.system.domain.dto.ApiParentDto;
|
|
import com.schoolinout.system.domain.dto.ApiParentDto;
|
|
@@ -65,7 +68,7 @@ public class Api_ParentController {
|
|
|
|
|
|
@Operation(summary = "家长登入")
|
|
@Operation(summary = "家长登入")
|
|
@PostMapping("/login")
|
|
@PostMapping("/login")
|
|
- public AjaxResult parentLogin(@Validated @RequestBody ApiParentDto form) {
|
|
|
|
|
|
+ public AjaxResult parentLogin(@Validated(Login.class) @RequestBody ApiParentDto form) {
|
|
// step1:校验验证码是否正确
|
|
// step1:校验验证码是否正确
|
|
boolean matches = form.getPhone().matches("^1[34578]\\d{9}$");
|
|
boolean matches = form.getPhone().matches("^1[34578]\\d{9}$");
|
|
if (!matches) {
|
|
if (!matches) {
|
|
@@ -112,12 +115,34 @@ public class Api_ParentController {
|
|
|
|
|
|
@Operation(summary = "家长注册")
|
|
@Operation(summary = "家长注册")
|
|
@PostMapping("/register")
|
|
@PostMapping("/register")
|
|
- public AjaxResult parentRegister(@Validated @RequestBody ApiParentDto form) {
|
|
|
|
- // step1:校验验证码是否正确
|
|
|
|
- // step2:通过手机号去查询家长
|
|
|
|
- // step3:通过学号去查询学生
|
|
|
|
- // step4:返回登入成功的令牌
|
|
|
|
- return AjaxResult.success();
|
|
|
|
|
|
+ public AjaxResult parentRegister(@Validated(Save.class) @RequestBody ApiParentDto form) {
|
|
|
|
+ // step1: 校验手机号是否正确
|
|
|
|
+ boolean matches = form.getPhone().matches("^1[34578]\\d{9}$");
|
|
|
|
+ if (!matches) {
|
|
|
|
+ return AjaxResult.error("手机号输入格式不正确");
|
|
|
|
+ }
|
|
|
|
+ // step2:校验手机号是否存在用户
|
|
|
|
+ Parent parent = new Parent();
|
|
|
|
+ parent.setParentPhone(form.getPhone());
|
|
|
|
+ parent = parentService.listParentSimple(parent);
|
|
|
|
+ if (parent != null) {
|
|
|
|
+ return AjaxResult.error("当前手机号已注册!");
|
|
|
|
+ }
|
|
|
|
+ // step3:校验要绑定的学号的学生是否存在
|
|
|
|
+ Student student = new Student();
|
|
|
|
+ student.setStudentNum(form.getStudentNum());
|
|
|
|
+ student = studentService.listStudentSimple(student);
|
|
|
|
+ if (student == null) {
|
|
|
|
+ return AjaxResult.error("不存在该学号");
|
|
|
|
+ }
|
|
|
|
+ // step4:校验成功则添加对应的关系
|
|
|
|
+ parent = new Parent();
|
|
|
|
+ parent.setParentName(form.getName());
|
|
|
|
+ parent.setParentPhone(form.getPhone());
|
|
|
|
+ parent.setRelation(form.getRelation());
|
|
|
|
+ parent.setStudentIds(String.valueOf(student.getId()));
|
|
|
|
+ parentService.saveParent(parent);
|
|
|
|
+ return AjaxResult.success("注册成功,请去登入!");
|
|
}
|
|
}
|
|
|
|
|
|
@Operation(summary = "发送手机号验证码")
|
|
@Operation(summary = "发送手机号验证码")
|