package com.sinata.modular.mall.controller;
|
|
import com.sinata.core.base.controller.BaseController;
|
import org.springframework.stereotype.Controller;
|
import com.baomidou.mybatisplus.plugins.Page;
|
import com.sinata.core.common.constant.factory.PageFactory;
|
import com.baomidou.mybatisplus.mapper.Wrapper;
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.sinata.core.common.annotion.BussinessLog;
|
import com.sinata.core.common.annotion.Permission;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.ui.Model;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import com.sinata.core.log.LogObjectHolder;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import com.sinata.modular.mall.model.MallTag;
|
import com.sinata.modular.mall.service.IMallTagService;
|
|
import java.util.List;
|
import java.util.Map;
|
|
import org.springframework.util.StringUtils;
|
|
/**
|
* 商品标签控制器
|
*
|
* @author goku
|
*/
|
@Controller
|
@RequestMapping("/mallTag")
|
public class MallTagController extends BaseController {
|
|
private String PREFIX = "/mall/mallTag/";
|
|
@Autowired
|
private IMallTagService mallTagService;
|
|
/**
|
* 跳转到商品标签首页
|
*/
|
@RequestMapping("")
|
public String index() {
|
return PREFIX + "mallTag.html";
|
}
|
|
/**
|
* 跳转到添加商品标签
|
*/
|
@RequestMapping("/mallTag_add")
|
public String mallTagAdd() {
|
return PREFIX + "mallTag_add.html";
|
}
|
|
/**
|
* 跳转到修改商品标签
|
*/
|
@RequestMapping("/mallTag_update/{mallTagId}")
|
public String mallTagUpdate(@PathVariable Integer mallTagId, Model model) {
|
MallTag mallTag = mallTagService.selectById(mallTagId);
|
model.addAttribute("item", mallTag);
|
LogObjectHolder.me().set(mallTag);
|
return PREFIX + "mallTag_edit.html";
|
}
|
|
/**
|
* 获取商品标签列表
|
*/
|
@ResponseBody
|
@RequestMapping(value = "/list")
|
public Object list(String beginTime, String endTime, String condition, Integer isLock) {
|
Page<Map<String, Object>> page = new PageFactory().defaultPage();
|
Wrapper wrapper = new EntityWrapper<MallTag>().eq("is_delete", 0).orderBy("id", false);
|
|
// 时间搜索
|
if (!StringUtils.isEmpty(beginTime)) {
|
wrapper.ge("create_time", beginTime + " 00:00:00");
|
}
|
if (!StringUtils.isEmpty(endTime)) {
|
wrapper.le("create_time", endTime + " 23:59:59");
|
}
|
if (!StringUtils.isEmpty(condition)) {
|
wrapper.like("tag_name", condition);
|
}
|
if (isLock != null) {
|
wrapper.eq("is_lock", isLock);
|
}
|
|
// 查询数据列表
|
List<Map<String, Object>> list = mallTagService.selectMapsPage(page, wrapper).getRecords();
|
|
page.setRecords(list);
|
return super.packForBT(page);
|
}
|
|
/**
|
* 新增商品标签
|
*/
|
@Permission
|
@ResponseBody
|
@BussinessLog(value = "新增商品标签")
|
@RequestMapping(value = "/add")
|
public Object add(MallTag mallTag) {
|
mallTagService.insert(mallTag);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 删除/批量删除
|
*/
|
@Permission
|
@ResponseBody
|
@BussinessLog(value = "删除/批量删除商品标签")
|
@RequestMapping(value = "/delete")
|
public Object delete(@RequestParam String ids) {
|
// 逻辑删除
|
mallTagService.updateForSet("is_delete = 1", new EntityWrapper<MallTag>().in("id", ids.split(",")));
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改商品标签
|
*/
|
@Permission
|
@ResponseBody
|
@BussinessLog(value = "修改商品标签")
|
@RequestMapping(value = "/update")
|
public Object update(MallTag mallTag) {
|
mallTagService.updateById(mallTag);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改商品标签状态
|
*/
|
@ResponseBody
|
@BussinessLog(value = "修改商品标签状态")
|
@RequestMapping(value = "/updateState")
|
public Object updateState(Integer mallTagId, Integer state) {
|
mallTagService.updateForSet("is_lock = " + state, new EntityWrapper<MallTag>().eq("id", mallTagId));
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 跳转商品标签详情
|
*/
|
@RequestMapping(value = "/detail/{mallTagId}")
|
public Object detail(@PathVariable("mallTagId") Integer mallTagId, Model model) {
|
MallTag mallTag = mallTagService.selectById(mallTagId);
|
model.addAttribute("item", mallTag);
|
return PREFIX + "mallTag_detail.html";
|
}
|
}
|