| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- package com.kede.banners.controller;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
- import com.kede.banners.bo.InputBannerDetails;
- import com.kede.banners.service.BannersService;
- import com.kede.common.bo.Result;
- import com.kede.common.constant.ErrorConstants;
- import com.kede.common.controller.BaseApiController;
- import com.kede.common.utils.StringUtils;
- @RestController
- @RequestMapping(value = "/open/admin/banners")
- public class AdminBannersApiController extends BaseApiController {
- @Resource
- private BannersService bannersService;
-
- @RequestMapping(value = "/addBanners", method = RequestMethod.POST)
- public Result addBanners(InputBannerDetails ibd) {
- Result res =new Result();
- if(StringUtils.isBlank(ibd.getBannerUrl())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"图片","图片"));
- return res;
- }
- if (!res.getError().isEmpty()) {
- return res;
- }
- res.data(bannersService.addBannersDetails(ibd));
- return res;
- }
-
-
-
- @RequestMapping(value = "/updateBanners", method = RequestMethod.POST)
- public Result updateBanners(InputBannerDetails ibd) {
- Result res =new Result();
- if(StringUtils.isBlank(ibd.getBannerUrl())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"图片","图片"));
- return res;
- }
- if (!res.getError().isEmpty()) return res;
-
- res.data(bannersService.updateBannersDetails(ibd));
- return res;
- }
-
- @RequestMapping(value = "/deleteBanners", method = RequestMethod.POST)
- public Result deleteBanners(InputBannerDetails ibd) {
- Result res =new Result();
- if(ibd.getId()==null) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"ID","ID"));
- return res;
- }
- res.data(bannersService.deleteBannersDetails(ibd));
- return res;
- }
-
- @RequestMapping(value = "/listBanners", method = RequestMethod.GET)
- public Result listBanners(InputBannerDetails ibd,Integer pageSize,Integer pageNo) {
- Result res =new Result();
-
- res.data(bannersService.listBannersDetails(ibd,pageSize,pageNo));
- return res;
- }
-
- @RequestMapping(value = "/selectBanners", method = RequestMethod.GET)
- public Result selectBanners(InputBannerDetails ibd) {
- Result res =new Result();
- if(ibd.getId()==null) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"ID","ID"));
- return res;
- }
- if (!res.getError().isEmpty()) return res;
- res.data(bannersService.selectBannersDetails(ibd));
- return res;
- }
-
- /** 上传图片 **/
- @RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
- public Result uploadOrderInvoiceFile(HttpServletRequest req){
- Result res = new Result();
- res.setData(handleFile(res, "/banners_Details/", false, req, "banners_Details"));
- return res;
- }
-
- }
|