AmbApiController.java 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package com.goafanti.ambSystem.controller;
  2. import com.goafanti.ambSystem.bo.InputAmb;
  3. import com.goafanti.ambSystem.service.AmbService;
  4. import com.goafanti.common.bo.Result;
  5. import com.goafanti.common.constant.ErrorConstants;
  6. import com.goafanti.common.controller.CertifyApiController;
  7. import com.goafanti.common.utils.*;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.validation.BindingResult;
  10. import org.springframework.validation.annotation.Validated;
  11. import org.springframework.web.bind.annotation.RequestMapping;
  12. import org.springframework.web.bind.annotation.RequestMethod;
  13. import org.springframework.web.bind.annotation.RestController;
  14. @RestController
  15. @RequestMapping(value = "/api/admin/amb")
  16. public class AmbApiController extends CertifyApiController {
  17. @Autowired
  18. private AmbService ambService;
  19. @RequestMapping(value="/add",method = RequestMethod.POST)
  20. public Result addAmb(@Validated InputAmb in,BindingResult bindingResult){
  21. Result res =new Result();
  22. if (bindingResult.hasErrors()) {
  23. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  24. ParamUtils.getParamName(in,bindingResult.getFieldError().getField())));
  25. return res;
  26. }
  27. res.data(ambService.addAmb(in));
  28. return res;
  29. }
  30. @RequestMapping(value="/update",method = RequestMethod.POST)
  31. public Result updateAmb( InputAmb in){
  32. Result res =new Result();
  33. if (in.getId()==null){
  34. res.getError().add(getErrorMessageParams(ErrorConstants.PARAM_EMPTY_ERROR,"巴编号"));
  35. return res;
  36. }
  37. res.data(ambService.updateAmb(in));
  38. return res;
  39. }
  40. @RequestMapping(value="/select",method = RequestMethod.GET)
  41. public Result selectAmb( InputAmb in){
  42. Result res =new Result();
  43. res.data(ambService.selectAmb(in));
  44. return res;
  45. }
  46. @RequestMapping(value="/selectAll",method = RequestMethod.GET)
  47. public Result selectAll( ){
  48. Result res =new Result();
  49. res.data(ambService.selectAll());
  50. return res;
  51. }
  52. }