|
@@ -1,8 +1,6 @@
|
|
|
package com.ym.mec.collectfee.controller;
|
|
|
|
|
|
|
|
|
-import com.ym.mec.collectfee.common.page.PageInfo;
|
|
|
-import com.ym.mec.collectfee.common.page.QueryInfo;
|
|
|
import com.ym.mec.collectfee.common.web.BaseController;
|
|
|
import com.ym.mec.collectfee.entity.*;
|
|
|
import com.ym.mec.collectfee.service.ApplyInfoService;
|
|
@@ -15,6 +13,7 @@ import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -66,11 +65,19 @@ public class UserController extends BaseController {
|
|
|
@PostMapping("/userApply")
|
|
|
public Object userApply(ApplyInfo applyInfo){
|
|
|
if(applyInfo != null){
|
|
|
- Date date = new Date();
|
|
|
- applyInfo.setCreateTime(date);
|
|
|
- applyInfo.setUpdateTime(date);
|
|
|
- applyInfoService.insert(applyInfo);
|
|
|
- return succeed(applyInfo.getId());
|
|
|
+ try {
|
|
|
+ Date date = new Date();
|
|
|
+ applyInfo.setCreateTime(date);
|
|
|
+ applyInfo.setUpdateTime(date);
|
|
|
+ applyInfoService.insert(applyInfo);
|
|
|
+ return succeed(applyInfo.getId());
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ if(e instanceof DuplicateKeyException){
|
|
|
+ return failed("该用户已存在");
|
|
|
+ }
|
|
|
+ return failed("报名失败");
|
|
|
+ }
|
|
|
}
|
|
|
return failed();
|
|
|
}
|