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.MallGoodsDetail;
|
import com.sinata.modular.mall.service.IMallGoodsDetailService;
|
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("/mallGoodsDetail")
|
public class MallGoodsDetailController extends BaseController {
|
|
private String PREFIX = "/mall/mallGoodsDetail/";
|
|
@Autowired
|
private IMallGoodsDetailService mallGoodsDetailService;
|
|
/**
|
* 跳转到商品详情首页
|
*/
|
@RequestMapping("")
|
public String index() {
|
return PREFIX + "mallGoodsDetail.html";
|
}
|
|
/**
|
* 跳转到添加商品详情
|
*/
|
@RequestMapping("/mallGoodsDetail_add")
|
public String mallGoodsDetailAdd() {
|
return PREFIX + "mallGoodsDetail_add.html";
|
}
|
|
/**
|
* 跳转到修改商品详情
|
*/
|
@RequestMapping("/mallGoodsDetail_update/{mallGoodsDetailId}")
|
public String mallGoodsDetailUpdate(@PathVariable Integer mallGoodsDetailId, Model model) {
|
MallGoodsDetail mallGoodsDetail = mallGoodsDetailService.selectById(mallGoodsDetailId);
|
model.addAttribute("item", mallGoodsDetail);
|
LogObjectHolder.me().set(mallGoodsDetail);
|
return PREFIX + "mallGoodsDetail_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<MallGoodsDetail>().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 = mallGoodsDetailService.selectMapsPage(page, wrapper).getRecords();
|
|
page.setRecords(list);
|
return super.packForBT(page);
|
}
|
|
/**
|
* 新增商品详情
|
*/
|
@Permission
|
@ResponseBody
|
@BussinessLog(value = "新增商品详情")
|
@RequestMapping(value = "/add")
|
public Object add(MallGoodsDetail mallGoodsDetail) {
|
mallGoodsDetailService.insert(mallGoodsDetail);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 删除/批量删除
|
*/
|
@Permission
|
@ResponseBody
|
@BussinessLog(value = "删除/批量删除商品详情")
|
@RequestMapping(value = "/delete")
|
public Object delete(@RequestParam String ids) {
|
// 逻辑删除
|
mallGoodsDetailService.updateForSet("is_delete = 1", new EntityWrapper<MallGoodsDetail>().in("id", ids.split(",")));
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改商品详情
|
*/
|
@Permission
|
@ResponseBody
|
@BussinessLog(value = "修改商品详情")
|
@RequestMapping(value = "/update")
|
public Object update(MallGoodsDetail mallGoodsDetail) {
|
mallGoodsDetailService.updateById(mallGoodsDetail);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改商品详情状态
|
*/
|
@ResponseBody
|
@BussinessLog(value = "修改商品详情状态")
|
@RequestMapping(value = "/updateState")
|
public Object updateState(Integer mallGoodsDetailId, Integer state) {
|
mallGoodsDetailService.updateForSet("state = " + state, new EntityWrapper<MallGoodsDetail>().eq("id", mallGoodsDetailId));
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 跳转商品详情详情
|
*/
|
@RequestMapping(value = "/detail/{mallGoodsDetailId}")
|
public Object detail(@PathVariable("mallGoodsDetailId") Integer mallGoodsDetailId, Model model) {
|
MallGoodsDetail mallGoodsDetail = mallGoodsDetailService.selectById(mallGoodsDetailId);
|
model.addAttribute("item", mallGoodsDetail);
|
return PREFIX + "mallGoodsDetail_detail.html";
|
}
|
}
|