From 753145b81710f934c28b29a1feb376ce79d4a965 Mon Sep 17 00:00:00 2001 From: 44323 <443237572@qq.com> Date: 星期六, 23 九月 2023 17:52:59 +0800 Subject: [PATCH] 后台代码 --- cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/AdvertisementController.java | 43 +++++++++++++++++++++++++++---------------- 1 files changed, 27 insertions(+), 16 deletions(-) diff --git a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/AdvertisementController.java b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/AdvertisementController.java index 5565a53..aa72a63 100644 --- a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/AdvertisementController.java +++ b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/AdvertisementController.java @@ -8,11 +8,9 @@ import com.dsh.course.feignClient.other.model.Banner; import com.dsh.guns.config.UserExt; import com.dsh.guns.core.base.controller.BaseController; -import com.dsh.guns.modular.system.model.AdvertisementChangeStateDTO; -import com.dsh.guns.modular.system.model.AdvertisementQuery; -import com.dsh.guns.modular.system.model.CoachQuery; -import com.dsh.guns.modular.system.model.User; +import com.dsh.guns.modular.system.model.*; import com.dsh.guns.modular.system.service.ICityService; +import com.dsh.guns.modular.system.service.IStoreService; import com.dsh.guns.modular.system.util.ResultUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -22,10 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashSet; -import java.util.List; +import java.util.*; /** * 广告管理控制器 @@ -41,16 +36,22 @@ private CityManagerClient cityManagerClient; @Autowired private BannerClient bannerClient; - + @Autowired + private IStoreService storeService; /** * 跳转到广告页面 */ @RequestMapping("") public String index(Model model) { - model.addAttribute("pages",1); + List<TTurn> pages = storeService.pageList(); + List<Integer> ids = new ArrayList<>(); + for (TTurn page : pages) { + ids.add(page.getId()); + } + List<TTurn> res = storeService.getPage(ids); + model.addAttribute("pages",res); model.addAttribute("models",1); - return PREFIX + "advertisement.html"; } /** @@ -69,6 +70,8 @@ @RequestMapping("/update/{id}/{type}") public String store(Model model, @PathVariable("id") Integer id,@PathVariable("type")Integer type) { Banner data = bannerClient.getById(id); + List<Map<String, Object>> pages = storeService.typeChange(data.getModel()); + List<Map<String, Object>> types = storeService.typeChangeOne(data.getJumpPage()); // type=1 查看详情 type=2 编辑 if (type == 1){ model.addAttribute("type",1); @@ -78,6 +81,8 @@ Integer roleType = UserExt.getUser().getObjectType(); model.addAttribute("roleType",roleType); model.addAttribute("data",data); + model.addAttribute("pages",pages); + model.addAttribute("types",types); return PREFIX + "advertisement_edit.html"; } @@ -85,9 +90,10 @@ * 广告上下架 */ @RequestMapping("/changeState") - public Object changeState(AdvertisementChangeStateDTO dto) { - - return bannerClient.changeState(dto); + @ResponseBody + public Object changeState(@RequestBody AdvertisementChangeStateDTO dto) { + bannerClient.changeState(dto); + return ResultUtil.success(); } /** * 添加广告 @@ -95,16 +101,21 @@ @ResponseBody @RequestMapping(value = "/addAdvertisement") public ResultUtil addAdvertisement(@RequestBody Banner banner) { + banner.setInsertTime(new Date()); bannerClient.addAdvertisement(banner); return ResultUtil.success("添加成功"); } /** - * 添加广告 + * 编辑广告 */ @ResponseBody @RequestMapping(value = "/updateAdvertisement") public ResultUtil updateAdvertisement(@RequestBody Banner banner) { - + Banner byId = bannerClient.getById(banner.getId()); + // 如果为空 则没有改变图片 + if (banner.getImg().equals("")||banner==null){ + banner.setImg(byId.getImg()); + } bannerClient.updateAdvertisement(banner); return ResultUtil.success("添加成功"); } -- Gitblit v1.7.1