package com.sinata.modular.mall.controller;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.baomidou.mybatisplus.mapper.Wrapper;
|
import com.baomidou.mybatisplus.plugins.Page;
|
import com.sinata.core.base.controller.BaseController;
|
import com.sinata.core.common.annotion.BussinessLog;
|
import com.sinata.core.common.annotion.Permission;
|
import com.sinata.core.common.constant.factory.PageFactory;
|
import com.sinata.core.log.LogObjectHolder;
|
import com.sinata.modular.mall.model.MallGoodsSpecValue;
|
import com.sinata.modular.mall.service.IMallGoodsSpecValueService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.ui.Model;
|
import org.springframework.util.StringUtils;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 规格值控制器
|
*
|
* @author goku
|
*/
|
@Controller
|
@RequestMapping("/mallGoodsSpecValue")
|
public class MallGoodsSpecValueController extends BaseController {
|
|
private String PREFIX = "/mall/mallGoodsSpecValue/";
|
|
@Autowired
|
private IMallGoodsSpecValueService mallGoodsSpecValueService;
|
|
/**
|
* 跳转到规格值首页
|
*/
|
@RequestMapping("")
|
public String index() {
|
return PREFIX + "mallGoodsSpecValue.html";
|
}
|
|
/**
|
* 跳转到添加规格值
|
*/
|
@RequestMapping("/mallGoodsSpecValue_add")
|
public String mallGoodsSpecValueAdd() {
|
return PREFIX + "mallGoodsSpecValue_add.html";
|
}
|
|
/**
|
* 跳转到修改规格值
|
*/
|
@RequestMapping("/mallGoodsSpecValue_update/{mallGoodsSpecValueId}")
|
public String mallGoodsSpecValueUpdate(@PathVariable Integer mallGoodsSpecValueId, Model model) {
|
MallGoodsSpecValue mallGoodsSpecValue = mallGoodsSpecValueService.selectById(mallGoodsSpecValueId);
|
model.addAttribute("item", mallGoodsSpecValue);
|
LogObjectHolder.me().set(mallGoodsSpecValue);
|
return PREFIX + "mallGoodsSpecValue_edit.html";
|
}
|
|
/**
|
* 获取规格值列表
|
*/
|
@ResponseBody
|
@RequestMapping(value = "/list")
|
public Object list(String beginTime, String endTime, String condition) {
|
Page<Map<String, Object>> page = new PageFactory().defaultPage();
|
Wrapper wrapper = new EntityWrapper<MallGoodsSpecValue>().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");
|
}
|
|
// 查询数据列表
|
List<Map<String, Object>> list = mallGoodsSpecValueService.selectMapsPage(page, wrapper).getRecords();
|
|
page.setRecords(list);
|
return super.packForBT(page);
|
}
|
|
/**
|
* 新增规格值
|
*/
|
@Permission
|
@ResponseBody
|
@BussinessLog(value = "新增规格值")
|
@RequestMapping(value = "/add")
|
public Object add(MallGoodsSpecValue mallGoodsSpecValue) {
|
mallGoodsSpecValueService.insert(mallGoodsSpecValue);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 删除/批量删除
|
*/
|
@Permission
|
@ResponseBody
|
@BussinessLog(value = "删除/批量删除规格值")
|
@RequestMapping(value = "/delete")
|
public Object delete(@RequestParam String ids) {
|
// 逻辑删除
|
mallGoodsSpecValueService.updateForSet("is_delete = 1", new EntityWrapper<MallGoodsSpecValue>().in("id", ids.split(",")));
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改规格值
|
*/
|
@Permission
|
@ResponseBody
|
@BussinessLog(value = "修改规格值")
|
@RequestMapping(value = "/update")
|
public Object update(MallGoodsSpecValue mallGoodsSpecValue) {
|
mallGoodsSpecValueService.updateById(mallGoodsSpecValue);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改规格值状态
|
*/
|
@ResponseBody
|
@BussinessLog(value = "修改规格值状态")
|
@RequestMapping(value = "/updateState")
|
public Object updateState(Integer mallGoodsSpecValueId, Integer state) {
|
mallGoodsSpecValueService.updateForSet("state = " + state, new EntityWrapper<MallGoodsSpecValue>().eq("id", mallGoodsSpecValueId));
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 跳转规格值详情
|
*/
|
@RequestMapping(value = "/detail/{mallGoodsSpecValueId}")
|
public Object detail(@PathVariable("mallGoodsSpecValueId") Integer mallGoodsSpecValueId, Model model) {
|
MallGoodsSpecValue mallGoodsSpecValue = mallGoodsSpecValueService.selectById(mallGoodsSpecValueId);
|
model.addAttribute("item", mallGoodsSpecValue);
|
return PREFIX + "mallGoodsSpecValue_detail.html";
|
}
|
}
|