package com.dsh.guns.modular.system.controller.code; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.dsh.course.feignClient.activity.CouponClient; import com.dsh.course.feignClient.activity.model.Coupon; import com.dsh.course.feignClient.activity.model.CouponExamineListSearch; import com.dsh.course.feignClient.activity.model.CouponListOfSearch; import com.dsh.guns.core.base.controller.BaseController; import com.dsh.guns.core.common.constant.factory.PageFactory; import com.dsh.guns.core.exception.GunsException; import com.dsh.guns.core.util.ToolUtil; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import java.util.List; import java.util.Map; /** * 优惠券审核 控制器 */ @Controller @RequestMapping("/tCouponExamine") public class TCouponExamineController extends BaseController { private String PREFIX = "/system/tCouponExamine/"; @Resource private CouponClient client; /** * 优惠券审核列表页 */ @RequestMapping("") public String index(Model model) { return PREFIX + "TCouponExamineList.html"; } /** * 获取 优惠券审核列表 */ @RequestMapping(value = "/list") @ResponseBody public Object listOfDatas(String name, Integer type, Integer distributionMethod , Integer userPopulation, Integer auditStatus) { Page> page = new PageFactory>().defaultPage(); CouponExamineListSearch ofSearch = new CouponExamineListSearch(); ofSearch.setPage(page); ofSearch.setName(name); ofSearch.setType(type); ofSearch.setDistributionMethod(distributionMethod); ofSearch.setUserPopulation(userPopulation); ofSearch.setAuditStatus(auditStatus); return client.getCouponExamineListOfSearch(ofSearch); } /** * 获取 优惠券审核详情 */ @RequestMapping(value = "/couponOfDetail/{id}") @ResponseBody public String detailOfCoupon(@PathVariable Integer id, Model model){ Map stringObjectMap = client.queryCouponExamineDetail(id); model.addAttribute(stringObjectMap); return PREFIX + "TCouponExamineInfo.html"; } /** * 获取 优惠券审核详情 */ @RequestMapping(value = "/couponExaminePage/{id}") @ResponseBody public String couponExaminePage(@PathVariable Integer id, Model model){ model.addAttribute("id",id); return PREFIX + "TCouponExamine.html"; } @RequestMapping(value = "/examine") @ResponseBody public Object examine(Integer couponOfId, Integer state, String remark) { Coupon coupon = client.queryCouponById(couponOfId); try { if (state == 1) { coupon.setAuditStatus(2); } if (state == 2) { coupon.setAuditStatus(3); coupon.setAuditRemark(remark); } client.updateCouponData(coupon); return SUCCESS_TIP; }catch (Exception e){ e.printStackTrace(); return ERROR; } } }