|
|
@@ -1,20 +1,58 @@
|
|
|
package com.goafanti.contract.controller;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.validation.Valid;
|
|
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import com.goafanti.cognizance.service.OrgCognizanceService;
|
|
|
import com.goafanti.common.bo.Result;
|
|
|
+import com.goafanti.common.constant.ErrorConstants;
|
|
|
import com.goafanti.common.controller.CertifyApiController;
|
|
|
+import com.goafanti.common.enums.ContractFields;
|
|
|
+import com.goafanti.common.model.Contract;
|
|
|
+import com.goafanti.common.model.User;
|
|
|
import com.goafanti.common.utils.StringUtils;
|
|
|
+import com.goafanti.contract.bo.InputSaveContract;
|
|
|
import com.goafanti.contract.service.ContractService;
|
|
|
+import com.goafanti.core.shiro.token.TokenManager;
|
|
|
@RestController
|
|
|
@RequestMapping(value = "/api/user/contract")
|
|
|
public class ContractApiController extends CertifyApiController{
|
|
|
@Resource
|
|
|
private ContractService contractService;
|
|
|
+ @Resource
|
|
|
+ private OrgCognizanceService orgCognizanceService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 提交申请新合同
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/apply", method = RequestMethod.POST)
|
|
|
+ public Result apply(@Valid InputSaveContract contract, BindingResult bindingResult){
|
|
|
+ Result res = new Result();
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
|
|
|
+ ContractFields.getFieldDesc(bindingResult.getFieldError().getField())));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ User curUser = TokenManager.getUserToken();
|
|
|
+ if (!checkCertify(res, curUser)) {
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ if (null != contract.getCognizanceYear() && !contract.getCognizanceYear().equals(0)) {
|
|
|
+ if (!disposeCog(contract.getCognizanceYear(), contract.getUid(), res).getError().isEmpty()) {
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Contract c = new Contract();
|
|
|
+ BeanUtils.copyProperties(contract, c);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 合同列表
|
|
|
@@ -35,4 +73,14 @@ public class ContractApiController extends CertifyApiController{
|
|
|
endDateFormattedDate, pNo, pSize));
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
+ private Result disposeCog(Integer year, String uid, Result res) {
|
|
|
+ Integer latelyYear = orgCognizanceService.selectLatelyRecordYear(uid);
|
|
|
+ if (null != latelyYear && year - latelyYear < 4) {
|
|
|
+ res.getError()
|
|
|
+ .add(buildError(ErrorConstants.STATUS_ERROR, "高企认定申请中或认定未到期!无法提交新申请!", "高企认定申请中或认定未到期!无法提交新申请!"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
}
|