|
@@ -8,6 +8,7 @@ import cn.com.qmth.stmms.ms.core.repository.StudentRepo;
|
|
|
import cn.com.qmth.stmms.ms.core.specification.StudentSpecification;
|
|
|
import cn.com.qmth.stmms.ms.core.vo.Subject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.dao.DataIntegrityViolationException;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -93,8 +94,16 @@ public class StudentApi {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(method = RequestMethod.POST)
|
|
|
- public Student create(@RequestBody Student domain) {
|
|
|
- return studentRepo.save(domain);
|
|
|
+ public Student create(@RequestBody Student domain) throws Exception {
|
|
|
+ try {
|
|
|
+ return studentRepo.save(domain);
|
|
|
+ } catch (Exception e) {
|
|
|
+ if (e instanceof DataIntegrityViolationException) {
|
|
|
+ throw new Exception("修改失败,同一个考区不允许有重复的考号");
|
|
|
+ }
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
/**
|