| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- package com.goafanti.ambSystem.controller;
- import com.goafanti.ambSystem.bo.InputAmb;
- import com.goafanti.ambSystem.bo.InputAmbPayment;
- import com.goafanti.ambSystem.service.AmbPaymentService;
- import com.goafanti.ambSystem.service.AmbService;
- import com.goafanti.common.bo.Result;
- import com.goafanti.common.constant.ErrorConstants;
- import com.goafanti.common.controller.CertifyApiController;
- import com.goafanti.common.utils.ParamUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.validation.BindingResult;
- import org.springframework.validation.annotation.Validated;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
- @RestController
- @RequestMapping(value = "/api/admin/ambPayment")
- public class AmbPaymentApiController extends CertifyApiController {
- @Autowired
- private AmbPaymentService ambPaymentService;
- /**
- * 新增巴付款
- * @param in
- * @param bindingResult
- * @return
- */
- @RequestMapping(value="/add",method = RequestMethod.POST)
- public Result addAmb(@Validated InputAmbPayment in, BindingResult bindingResult){
- Result res =new Result();
- if (bindingResult.hasErrors()) {
- res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
- ParamUtils.getParamName(in,bindingResult.getFieldError().getField())));
- return res;
- }
- int i=ambPaymentService.checkAmbPayment(in);
- if (i==-1){
- res.getError().add(buildError(String.format("[%s]已存在,请确认后再新增",in.getName())));
- return res;
- }
- res.data(ambService.addAmb(in));
- return res;
- }
- @RequestMapping(value="/update",method = RequestMethod.POST)
- public Result updateAmb( InputAmb in){
- Result res =new Result();
- if (in.getId()==null){
- res.getError().add(buildErrorMessageParams(ErrorConstants.PARAM_EMPTY_ERROR,"巴编号"));
- return res;
- }
- res.data(ambService.updateAmb(in));
- return res;
- }
- @RequestMapping(value="/delete",method = RequestMethod.POST)
- public Result deleteAmb( InputAmb in){
- Result res =new Result();
- if (in.getId()==null){
- res.getError().add(buildErrorMessageParams(ErrorConstants.PARAM_EMPTY_ERROR,"巴编号"));
- return res;
- }
- int i=ambService.checkAmb(in,2);
- if (i==-1){
- res.getError().add(buildError("巴存在子项目,请先删除所有子项"));
- return res;
- }
- res.data(ambService.deleteAmb(in));
- return res;
- }
- @RequestMapping(value="/details",method = RequestMethod.GET)
- public Result detailsAmb( InputAmb in){
- Result res =new Result();
- if (in.getId()==null){
- res.getError().add(buildErrorMessageParams(ErrorConstants.PARAM_EMPTY_ERROR,"巴编号"));
- return res;
- }
- res.data(ambService.detailsAmb(in));
- return res;
- }
- @RequestMapping(value="/select",method = RequestMethod.GET)
- public Result selectAmb( InputAmb in){
- Result res =new Result();
- res.data(ambService.selectAmb(in));
- return res;
- }
- @RequestMapping(value="/selectAll",method = RequestMethod.GET)
- public Result selectAll( ){
- Result res =new Result();
- res.data(ambService.selectAll());
- return res;
- }
- }
|