AdminBannersApiController.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. package com.kede.banners.controller;
  2. import javax.annotation.Resource;
  3. import javax.servlet.http.HttpServletRequest;
  4. import org.springframework.web.bind.annotation.RequestMapping;
  5. import org.springframework.web.bind.annotation.RequestMethod;
  6. import org.springframework.web.bind.annotation.RestController;
  7. import com.kede.banners.bo.InputBannerDetails;
  8. import com.kede.banners.service.BannersService;
  9. import com.kede.common.bo.Result;
  10. import com.kede.common.constant.ErrorConstants;
  11. import com.kede.common.controller.BaseApiController;
  12. import com.kede.common.utils.StringUtils;
  13. @RestController
  14. @RequestMapping(value = "/open/admin/banners")
  15. public class AdminBannersApiController extends BaseApiController {
  16. @Resource
  17. private BannersService bannersService;
  18. @RequestMapping(value = "/addBanners", method = RequestMethod.POST)
  19. public Result addBanners(InputBannerDetails ibd) {
  20. Result res =new Result();
  21. if(StringUtils.isBlank(ibd.getBannerUrl())) {
  22. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"图片","图片"));
  23. return res;
  24. }
  25. if (!res.getError().isEmpty()) {
  26. return res;
  27. }
  28. res.data(bannersService.addBannersDetails(ibd));
  29. return res;
  30. }
  31. @RequestMapping(value = "/updateBanners", method = RequestMethod.POST)
  32. public Result updateBanners(InputBannerDetails ibd) {
  33. Result res =new Result();
  34. if(StringUtils.isBlank(ibd.getBannerUrl())) {
  35. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"图片","图片"));
  36. return res;
  37. }
  38. if (!res.getError().isEmpty()) return res;
  39. res.data(bannersService.updateBannersDetails(ibd));
  40. return res;
  41. }
  42. @RequestMapping(value = "/deleteBanners", method = RequestMethod.POST)
  43. public Result deleteBanners(InputBannerDetails ibd) {
  44. Result res =new Result();
  45. if(ibd.getId()==null) {
  46. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"ID","ID"));
  47. return res;
  48. }
  49. res.data(bannersService.deleteBannersDetails(ibd));
  50. return res;
  51. }
  52. @RequestMapping(value = "/listBanners", method = RequestMethod.GET)
  53. public Result listBanners(InputBannerDetails ibd,Integer pageSize,Integer pageNo) {
  54. Result res =new Result();
  55. res.data(bannersService.listBannersDetails(ibd,pageSize,pageNo));
  56. return res;
  57. }
  58. @RequestMapping(value = "/selectBanners", method = RequestMethod.GET)
  59. public Result selectBanners(InputBannerDetails ibd) {
  60. Result res =new Result();
  61. if(ibd.getId()==null) {
  62. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"ID","ID"));
  63. return res;
  64. }
  65. if (!res.getError().isEmpty()) return res;
  66. res.data(bannersService.selectBannersDetails(ibd));
  67. return res;
  68. }
  69. /** 上传图片 **/
  70. @RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
  71. public Result uploadOrderInvoiceFile(HttpServletRequest req){
  72. Result res = new Result();
  73. res.setData(handleFile(res, "/banners_Details/", false, req, "banners_Details"));
  74. return res;
  75. }
  76. }