package com.goafanti.ambSystem.controller; import com.goafanti.ambSystem.bo.InputAmb; 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.*; 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/amb") public class AmbApiController extends CertifyApiController { @Autowired private AmbService ambService; @RequestMapping(value="/add",method = RequestMethod.POST) public Result addAmb(@Validated InputAmb 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; } 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(getErrorMessageParams(ErrorConstants.PARAM_EMPTY_ERROR,"巴编号")); return res; } res.data(ambService.updateAmb(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; } }