package com.dsh.guns.modular.system.controller.code; import com.dsh.course.feignClient.account.CityManagerClient; import com.dsh.course.feignClient.account.model.CityManager; import com.dsh.course.feignClient.account.model.Coach; import com.dsh.course.feignClient.account.model.CoachSerchVO; import com.dsh.course.feignClient.other.BannerClient; 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.service.ICityService; import com.dsh.guns.modular.system.util.ResultUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; 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; /** * 广告管理控制器 * */ @Controller @RequestMapping("/advertisement") public class AdvertisementController extends BaseController { private String PREFIX = "/system/advertisement/"; @Autowired private ICityService cityService; @Autowired private CityManagerClient cityManagerClient; @Autowired private BannerClient bannerClient; /** * 跳转到广告页面 */ @RequestMapping("") public String index(Model model) { model.addAttribute("pages",1); model.addAttribute("models",1); return PREFIX + "advertisement.html"; } /** * 跳转到广告添加页面 */ @RequestMapping("/add") public String operator(Model model) { Integer roleType = UserExt.getUser().getObjectType(); model.addAttribute("roleType",roleType); return PREFIX + "advertisement_add.html"; } /** * 跳转到广告编辑页面 */ @RequestMapping("/update/{id}/{type}") public String store(Model model, @PathVariable("id") Integer id,@PathVariable("type")Integer type) { Banner data = bannerClient.getById(id); // type=1 查看详情 type=2 编辑 if (type == 1){ model.addAttribute("type",1); }else{ model.addAttribute("type",2); } Integer roleType = UserExt.getUser().getObjectType(); model.addAttribute("roleType",roleType); model.addAttribute("data",data); return PREFIX + "advertisement_edit.html"; } /** * 广告上下架 */ @RequestMapping("/changeState") public Object changeState(AdvertisementChangeStateDTO dto) { return bannerClient.changeState(dto); } /** * 添加广告 */ @ResponseBody @RequestMapping(value = "/addAdvertisement") public ResultUtil addAdvertisement(@RequestBody Banner banner) { bannerClient.addAdvertisement(banner); return ResultUtil.success("添加成功"); } /** * 添加广告 */ @ResponseBody @RequestMapping(value = "/updateAdvertisement") public ResultUtil updateAdvertisement(@RequestBody Banner banner) { bannerClient.updateAdvertisement(banner); return ResultUtil.success("添加成功"); } /** * 通过id 获取广告管理 数据 */ @ResponseBody @RequestMapping(value = "/getById") public Banner getById(Integer bannerId) { return bannerClient.getById(bannerId); } /** * 获取教练列表 */ @RequestMapping(value = "/listAll") @ResponseBody public List listAll(AdvertisementQuery query) { return bannerClient.listAll(query); } }