package com.stylefeng.guns.modular.system.controller.general;
|
|
import com.baomidou.mybatisplus.plugins.Page;
|
import com.stylefeng.guns.core.base.controller.BaseController;
|
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
|
import com.stylefeng.guns.core.shiro.ShiroKit;
|
import com.stylefeng.guns.core.util.SinataUtil;
|
import com.stylefeng.guns.core.util.ToolUtil;
|
import com.stylefeng.guns.modular.system.model.MerchantCoupon;
|
import com.stylefeng.guns.modular.system.service.IMerchantCouponService;
|
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.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import java.util.Date;
|
import java.util.List;
|
import java.util.Map;
|
|
|
/**
|
* 商家卷/商家商品卷控制层
|
*/
|
@Controller
|
@RequestMapping("/merchantCoupon")
|
public class MerchantCouponController extends BaseController {
|
|
private String PREFIX = "/system/merchantCoupon/";
|
|
@Autowired
|
private IMerchantCouponService merchantCouponService;
|
|
|
/**
|
* 跳转商家卷管理列表
|
*
|
* @return
|
*/
|
@RequestMapping("/index")
|
public String index() {
|
return PREFIX + "merchantCoupon.html";
|
}
|
|
/**
|
* @param startTime
|
* @param endTime
|
* @param merchantName 商家名
|
* @param name 商家卷名
|
* @return
|
*/
|
@RequestMapping("/list")
|
@ResponseBody
|
public Object list(String startTime, String endTime, String merchantName, String name, Integer type) {
|
|
Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
|
List<Map<String, Object>> list = merchantCouponService.list(startTime, endTime, merchantName, name, type, page);
|
page.setRecords(list);
|
return super.packForBT(page);
|
}
|
|
/**
|
* 跳转到添加商家卷添加
|
*
|
* @param model
|
* @return
|
*/
|
@RequestMapping("/merchantCoupon_add/{type}")
|
public String openMerchantCouponAdd(@PathVariable Integer type, Model model) {
|
|
/*查询商家列表*/
|
List<Map<String, Object>> list = merchantCouponService.getMerchantList();
|
model.addAttribute("item", list);
|
model.addAttribute("type", type);
|
|
return PREFIX + "merchantCoupon_add.html";
|
}
|
|
|
/**
|
* 添加商家券
|
*
|
* @param coupon
|
* @return
|
*/
|
@RequestMapping("/add")
|
@ResponseBody
|
public Object add(MerchantCoupon coupon) {
|
|
if (SinataUtil.isNotEmpty(coupon.getContent())) {
|
coupon.setContent(ToolUtil.cleanXSS(coupon.getContent()));
|
}
|
coupon.setCreateTime(new Date());
|
coupon.setState(1);
|
merchantCouponService.insert(coupon);
|
|
return SUCCESS_TIP;
|
}
|
|
@RequestMapping("/merchantCoupon_update")
|
public String openMerchantCouponUpdate(Integer type, Integer id, Model model) {
|
|
MerchantCoupon merchantCoupon = merchantCouponService.selectById(id);
|
model.addAttribute("item", merchantCoupon);
|
|
List<Map<String, Object>> list = merchantCouponService.getMerchantList();
|
model.addAttribute("merchantList", list);
|
model.addAttribute("type", type);
|
|
return PREFIX + "merchantCoupon_edit.html";
|
}
|
|
/**
|
* 编辑商家卷信息
|
*
|
* @param coupon
|
* @return
|
*/
|
@RequestMapping("/update")
|
@ResponseBody
|
public Object update(MerchantCoupon coupon) {
|
|
if (SinataUtil.isNotEmpty(coupon.getContent())) {
|
coupon.setContent(ToolUtil.cleanXSS(coupon.getContent()));
|
}
|
merchantCouponService.updateById(coupon);
|
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 编辑商家卷信息
|
*
|
* @param id
|
* @return
|
*/
|
@RequestMapping("/remove")
|
@ResponseBody
|
public Object remove(Integer id) {
|
|
MerchantCoupon merchantCoupon = merchantCouponService.selectById(id);
|
|
if (ToolUtil.isNotEmpty(merchantCoupon)) {
|
merchantCoupon.setState(3);
|
merchantCouponService.updateById(merchantCoupon);
|
}
|
return SUCCESS_TIP;
|
}
|
|
|
@RequestMapping("/merchandiseCouponIndex")
|
public String merchandiseCouponIndex() {
|
return PREFIX + "merchandiseCoupon.html";
|
}
|
|
}
|