From 5c848e0ea57a09d8726fded79b9c95e022c34786 Mon Sep 17 00:00:00 2001 From: shijie <648688341@qq.com> Date: Thu, 4 Mar 2021 11:55:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E7=AE=A1=E7=90=86=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/msdw/tms/controller/StudentController.java | 5 +++-- src/main/java/com/msdw/tms/entity/vo/StudentVo.java | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/msdw/tms/controller/StudentController.java b/src/main/java/com/msdw/tms/controller/StudentController.java index 148f6c7..614c4b9 100644 --- a/src/main/java/com/msdw/tms/controller/StudentController.java +++ b/src/main/java/com/msdw/tms/controller/StudentController.java @@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; import java.io.IOException; import java.util.HashMap; import java.util.List; @@ -46,7 +47,7 @@ public class StudentController implements StudentControllerApi{ @Transactional @Override @PostMapping("/addStudent") - public R addStudent(@RequestBody StudentVo studentVo){ + public R addStudent(@RequestBody @Valid StudentVo studentVo){ studentVo.setSchoolId(ConstantUtils.Keda_schoolId); String account = studentVo.getAccount(); String phone = studentVo.getPhone(); @@ -130,7 +131,7 @@ public class StudentController implements StudentControllerApi{ @Override @Transactional @PutMapping("/updateStudent") - public R updateStudent(@RequestBody StudentVo studentVo) { + public R updateStudent(@RequestBody @Valid StudentVo studentVo) { studentVo.setSchoolId(ConstantUtils.Keda_schoolId);//设定学校id Integer studentId = studentVo.getStudentId(); diff --git a/src/main/java/com/msdw/tms/entity/vo/StudentVo.java b/src/main/java/com/msdw/tms/entity/vo/StudentVo.java index 4c477a3..648238d 100644 --- a/src/main/java/com/msdw/tms/entity/vo/StudentVo.java +++ b/src/main/java/com/msdw/tms/entity/vo/StudentVo.java @@ -5,6 +5,7 @@ import com.msdw.tms.entity.UserInfoEntity; import lombok.Data; import lombok.experimental.Accessors; +import javax.validation.constraints.Pattern; import java.util.List; /** @@ -19,6 +20,7 @@ public class StudentVo extends StudentEntity { //用户姓名 private String userName; //用户账号 + @Pattern(regexp = "^[0-9a-zA-Z]*$",message = "账号只能为数字或字母!") private String account; //密码 private String password;