商品列表、新增、删除
This commit is contained in:
parent
7a2c3683bd
commit
79d0296406
|
|
@ -6,39 +6,42 @@ import com.ghy.common.core.controller.BaseController;
|
||||||
import com.ghy.common.core.domain.AjaxResult;
|
import com.ghy.common.core.domain.AjaxResult;
|
||||||
import com.ghy.common.core.page.TableDataInfo;
|
import com.ghy.common.core.page.TableDataInfo;
|
||||||
import com.ghy.common.enums.BusinessType;
|
import com.ghy.common.enums.BusinessType;
|
||||||
|
import com.ghy.common.utils.ShiroUtils;
|
||||||
import com.ghy.common.utils.poi.ExcelUtil;
|
import com.ghy.common.utils.poi.ExcelUtil;
|
||||||
|
import com.ghy.goods.domain.DeptGoodsCategory;
|
||||||
import com.ghy.goods.domain.Goods;
|
import com.ghy.goods.domain.Goods;
|
||||||
|
import com.ghy.goods.service.DeptGoodsCategoryService;
|
||||||
import com.ghy.goods.service.GoodsService;
|
import com.ghy.goods.service.GoodsService;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/goods/goods")
|
@RequestMapping("/goods/goods")
|
||||||
public class GoodsController extends BaseController {
|
public class GoodsController extends BaseController {
|
||||||
|
|
||||||
private String prefix = "goods/goods";
|
private static final String PREFIX = "goods/goods";
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private GoodsService goodsService;
|
private GoodsService goodsService;
|
||||||
|
@Resource
|
||||||
|
private DeptGoodsCategoryService deptGoodsCategoryService;
|
||||||
|
|
||||||
@RequiresPermissions("goods:goods:view")
|
@RequiresPermissions("goods:goods:view")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String goods()
|
public String goods() {
|
||||||
{
|
return PREFIX + "/goods";
|
||||||
return prefix + "/goods";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("goods:goods:list")
|
@RequiresPermissions("goods:goods:list")
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TableDataInfo list(Goods goods)
|
public TableDataInfo list(Goods goods) {
|
||||||
{
|
|
||||||
startPage();
|
startPage();
|
||||||
List<Goods> list = goodsService.selectGoodsList(goods);
|
List<Goods> list = goodsService.selectGoodsList(goods);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
|
|
@ -48,8 +51,7 @@ public class GoodsController extends BaseController {
|
||||||
@RequiresPermissions("goods:goods:export")
|
@RequiresPermissions("goods:goods:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult export(Goods goods)
|
public AjaxResult export(Goods goods) {
|
||||||
{
|
|
||||||
List<Goods> list = goodsService.selectGoodsList(goods);
|
List<Goods> list = goodsService.selectGoodsList(goods);
|
||||||
ExcelUtil<Goods> util = new ExcelUtil<Goods>(Goods.class);
|
ExcelUtil<Goods> util = new ExcelUtil<Goods>(Goods.class);
|
||||||
return util.exportExcel(list, "商品数据");
|
return util.exportExcel(list, "商品数据");
|
||||||
|
|
@ -57,16 +59,12 @@ public class GoodsController extends BaseController {
|
||||||
|
|
||||||
@RequiresPermissions("goods:goods:remove")
|
@RequiresPermissions("goods:goods:remove")
|
||||||
@Log(title = "商品管理", businessType = BusinessType.DELETE)
|
@Log(title = "商品管理", businessType = BusinessType.DELETE)
|
||||||
@PostMapping("/remove")
|
@PostMapping("/remove/{ids}")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult remove(String ids)
|
public AjaxResult remove(@PathVariable String ids) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
return toAjax(goodsService.deleteGoodsByIds(ids));
|
return toAjax(goodsService.deleteGoodsByIds(ids));
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return error(e.getMessage());
|
return error(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -75,9 +73,10 @@ public class GoodsController extends BaseController {
|
||||||
* 新增商品
|
* 新增商品
|
||||||
*/
|
*/
|
||||||
@GetMapping("/add")
|
@GetMapping("/add")
|
||||||
public String add()
|
public String add(ModelMap mmap) {
|
||||||
{
|
Long parentId = ShiroUtils.getSysUser().getParentId();
|
||||||
return prefix + "/add";
|
mmap.put("deptGoodsCategories", deptGoodsCategoryService.list(parentId));
|
||||||
|
return PREFIX + "/add";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -87,17 +86,14 @@ public class GoodsController extends BaseController {
|
||||||
@Log(title = "商品管理", businessType = BusinessType.INSERT)
|
@Log(title = "商品管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult addSave(@Validated Goods goods)
|
public AjaxResult addSave(@Validated Goods goods) {
|
||||||
{
|
if (UserConstants.GOODS_CODE_NOT_UNIQUE.equals(goodsService.checkGoodsNameUnique(goods))) {
|
||||||
if (UserConstants.GOODS_CODE_NOT_UNIQUE.equals(goodsService.checkGoodsNameUnique(goods)))
|
|
||||||
{
|
|
||||||
return error("新增商品'" + goods.getGoodsName() + "'失败,商品名称已存在");
|
return error("新增商品'" + goods.getGoodsName() + "'失败,商品名称已存在");
|
||||||
}
|
} else if (UserConstants.GOODS_CODE_NOT_UNIQUE.equals(goodsService.checkGoodsCodeUnique(goods))) {
|
||||||
else if (UserConstants.GOODS_CODE_NOT_UNIQUE.equals(goodsService.checkGoodsCodeUnique(goods)))
|
|
||||||
{
|
|
||||||
return error("新增商品'" + goods.getGoodsName() + "'失败,商品编码已存在");
|
return error("新增商品'" + goods.getGoodsName() + "'失败,商品编码已存在");
|
||||||
}
|
}
|
||||||
goods.setCreateBy(getLoginName());
|
goods.setCreateBy(getLoginName());
|
||||||
|
goods.setDeptId(getSysUser().getDeptId());
|
||||||
return toAjax(goodsService.insertGoods(goods));
|
return toAjax(goodsService.insertGoods(goods));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,10 +102,9 @@ public class GoodsController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("goods:goods:edit")
|
@RequiresPermissions("goods:goods:edit")
|
||||||
@GetMapping("/edit/{goodsId}")
|
@GetMapping("/edit/{goodsId}")
|
||||||
public String edit(@PathVariable("goodsId") Long goodsId, ModelMap mmap)
|
public String edit(@PathVariable("goodsId") Long goodsId, ModelMap mmap) {
|
||||||
{
|
|
||||||
mmap.put("goods", goodsService.selectById(goodsId));
|
mmap.put("goods", goodsService.selectById(goodsId));
|
||||||
return prefix + "/edit";
|
return PREFIX + "/edit";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -119,14 +114,10 @@ public class GoodsController extends BaseController {
|
||||||
@Log(title = "商品管理", businessType = BusinessType.UPDATE)
|
@Log(title = "商品管理", businessType = BusinessType.UPDATE)
|
||||||
@PostMapping("/edit")
|
@PostMapping("/edit")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult editSave(@Validated Goods goods)
|
public AjaxResult editSave(@Validated Goods goods) {
|
||||||
{
|
if (UserConstants.GOODS_NAME_NOT_UNIQUE.equals(goodsService.checkGoodsNameUnique(goods))) {
|
||||||
if (UserConstants.GOODS_NAME_NOT_UNIQUE.equals(goodsService.checkGoodsNameUnique(goods)))
|
|
||||||
{
|
|
||||||
return error("修改商品'" + goods.getGoodsName() + "'失败,商品名称已存在");
|
return error("修改商品'" + goods.getGoodsName() + "'失败,商品名称已存在");
|
||||||
}
|
} else if (UserConstants.GOODS_CODE_NOT_UNIQUE.equals(goodsService.checkGoodsCodeUnique(goods))) {
|
||||||
else if (UserConstants.GOODS_CODE_NOT_UNIQUE.equals(goodsService.checkGoodsCodeUnique(goods)))
|
|
||||||
{
|
|
||||||
return error("修改商品'" + goods.getGoodsCode() + "'失败,商品编码已存在");
|
return error("修改商品'" + goods.getGoodsCode() + "'失败,商品编码已存在");
|
||||||
}
|
}
|
||||||
goods.setUpdateBy(getLoginName());
|
goods.setUpdateBy(getLoginName());
|
||||||
|
|
@ -138,8 +129,7 @@ public class GoodsController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@PostMapping("/checkGoodsNameUnique")
|
@PostMapping("/checkGoodsNameUnique")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String checkGoodsNameUnique(Goods goods)
|
public String checkGoodsNameUnique(Goods goods) {
|
||||||
{
|
|
||||||
return goodsService.checkGoodsNameUnique(goods);
|
return goodsService.checkGoodsNameUnique(goods);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,8 +138,7 @@ public class GoodsController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@PostMapping("/checkGoodsCodeUnique")
|
@PostMapping("/checkGoodsCodeUnique")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String checkGoodsCodeUnique(Goods goods)
|
public String checkGoodsCodeUnique(Goods goods) {
|
||||||
{
|
|
||||||
return goodsService.checkGoodsCodeUnique(goods);
|
return goodsService.checkGoodsCodeUnique(goods);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,126 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
|
||||||
|
<head>
|
||||||
|
<th:block th:include="include :: header('新增商品')" />
|
||||||
|
<th:block th:include="include :: select2-css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="main-content">
|
||||||
|
<form id="form-goods-add" class="form-horizontal">
|
||||||
|
<h4 class="form-header h4">基本信息</h4>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label is-required">商品名称:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input name="goodsName" placeholder="请输入商品名称" class="form-control" type="text" maxlength="30" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label is-required">价格:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input name="goodsPrice" placeholder="请输入商品价格" class="form-control" type="text" maxlength="12" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label is-required">优惠价:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input name="discountsPrice" placeholder="请输入优惠价" class="form-control" type="text" maxlength="12" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label is-required">团购价:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input name="groupPrice" placeholder="请输入团购价" class="form-control" type="text" maxlength="12" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label">商品类别:</label>
|
||||||
|
<div class="col-xs-8">
|
||||||
|
<select name="deptGoodsCategoryId" class="form-control m-b" >
|
||||||
|
<option th:each="item : ${deptGoodsCategories}" th:text="${item.goodsCategoryName}" th:value="${item.deptGoodsCategoryId}"></option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label">状态:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<select name="status" class="form-control m-b" th:with="type=${@dict.getType('goods_status')}">
|
||||||
|
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label is-required">商品库存:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input name="goodsNumber" placeholder="请输入商品库存" class="form-control" type="text" maxlength="12" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h4 class="form-header h4">其他信息</h4>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-xs-2 control-label">备注:</label>
|
||||||
|
<div class="col-xs-10">
|
||||||
|
<textarea name="remark" maxlength="500" class="form-control" rows="3"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-offset-5 col-sm-10">
|
||||||
|
<button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>
|
||||||
|
<button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<th:block th:include="include :: footer" />
|
||||||
|
<th:block th:include="include :: select2-js" />
|
||||||
|
<script>
|
||||||
|
var prefix = ctx + "goods/goods";
|
||||||
|
|
||||||
|
$("#form-goods-add").validate({
|
||||||
|
onkeyup: false,
|
||||||
|
rules:{
|
||||||
|
|
||||||
|
},
|
||||||
|
messages: {
|
||||||
|
|
||||||
|
},
|
||||||
|
focusCleanup: true
|
||||||
|
});
|
||||||
|
|
||||||
|
function submitHandler() {
|
||||||
|
if ($.validate.form()) {
|
||||||
|
var data = $("#form-goods-add").serializeArray();
|
||||||
|
$.operate.saveTab(prefix + "/add", data);
|
||||||
|
$.modal.close(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,124 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
|
||||||
|
<head>
|
||||||
|
<th:block th:include="include :: header('商品列表')"/>
|
||||||
|
</head>
|
||||||
|
<body class="gray-bg">
|
||||||
|
<div class="container-div">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12 search-collapse">
|
||||||
|
<form id="dept-form">
|
||||||
|
<div class="select-list">
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
商品名称:<input type="text" name="goodsName"/>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
类目状态:<select name="status" th:with="type=${@dict.getType('goods_status')}">
|
||||||
|
<option value="">所有</option>
|
||||||
|
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" />
|
||||||
|
</select>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.treeTable.search()"><i
|
||||||
|
class="fa fa-search"></i> 搜索</a>
|
||||||
|
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
|
||||||
|
class="fa fa-refresh"></i> 重置</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="btn-group-sm" id="toolbar" role="group">
|
||||||
|
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="goods:goods:add">
|
||||||
|
<i class="fa fa-plus"></i> 新增
|
||||||
|
</a>
|
||||||
|
<!-- <a class="btn btn-primary" onclick="$.operate.edit()" shiro:hasPermission="goods:goods:edit">-->
|
||||||
|
<!-- <i class="fa fa-edit"></i> 修改-->
|
||||||
|
<!-- </a>-->
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-12 select-table table-striped">
|
||||||
|
<table id="bootstrap-table"></table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<th:block th:include="include :: footer"/>
|
||||||
|
|
||||||
|
<script th:inline="javascript">
|
||||||
|
var addFlag = [[${@permission.hasPermi('goods:goods:add')}]];
|
||||||
|
var editFlag = [[${@permission.hasPermi('goods:goods:edit')}]];
|
||||||
|
var removeFlag = [[${@permission.hasPermi('goods:goods:remove')}]];
|
||||||
|
var datas = [[${@dict.getType('sys_normal_disable')}]];
|
||||||
|
var prefix = ctx + "goods/goods"
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
var options = {
|
||||||
|
url: prefix + "/list",
|
||||||
|
createUrl: prefix + "/add/{id}",
|
||||||
|
updateUrl: prefix + "/edit/{id}",
|
||||||
|
removeUrl: prefix + "/remove/{id}",
|
||||||
|
modalName: "商品",
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
checkbox: true
|
||||||
|
}, {
|
||||||
|
field: 'goodsCode',
|
||||||
|
title: '商品编码',
|
||||||
|
align: "left"
|
||||||
|
}, {
|
||||||
|
field: 'goodsName',
|
||||||
|
title: '商品名称',
|
||||||
|
align: "left"
|
||||||
|
}, {
|
||||||
|
field: 'goodsPrice',
|
||||||
|
title: '价格',
|
||||||
|
align: "left"
|
||||||
|
}, {
|
||||||
|
field: 'discountsPrice',
|
||||||
|
title: '优惠价',
|
||||||
|
align: "left"
|
||||||
|
}, {
|
||||||
|
field: 'groupPrice',
|
||||||
|
title: '团购价',
|
||||||
|
align: "left"
|
||||||
|
}, {
|
||||||
|
field: 'goodsSort',
|
||||||
|
title: '排序',
|
||||||
|
align: "left"
|
||||||
|
}, {
|
||||||
|
field: 'status',
|
||||||
|
title: '状态',
|
||||||
|
align: "left",
|
||||||
|
formatter: function (value, item, index) {
|
||||||
|
return $.table.selectDictLabel(datas, item.status);
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
field: 'goodsImgUrl',
|
||||||
|
title: '图片',
|
||||||
|
align: "left"
|
||||||
|
}, {
|
||||||
|
field: 'goodsNumber',
|
||||||
|
title: '商品库存',
|
||||||
|
align: "left"
|
||||||
|
}, {
|
||||||
|
field: 'createTime',
|
||||||
|
title: '创建时间',
|
||||||
|
align: "left"
|
||||||
|
}, {
|
||||||
|
title: '操作',
|
||||||
|
align: 'left',
|
||||||
|
formatter: function (value, row, index) {
|
||||||
|
var actions = [];
|
||||||
|
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.goodsId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
||||||
|
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.goodsId + '\')"><i class="fa fa-trash"></i>删除</a>');
|
||||||
|
return actions.join('');
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
$.table.init(options);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -19,6 +19,12 @@ public class DeptGoodsCategory extends BaseEntity {
|
||||||
|
|
||||||
@Excel(name = "类别id", cellType = Excel.ColumnType.NUMERIC)
|
@Excel(name = "类别id", cellType = Excel.ColumnType.NUMERIC)
|
||||||
private Long goodsCategoryId;
|
private Long goodsCategoryId;
|
||||||
|
@Excel(name = "类别编码", cellType = Excel.ColumnType.STRING)
|
||||||
|
private String goodsCategoryCode;
|
||||||
|
@Excel(name = "类别名称", cellType = Excel.ColumnType.STRING)
|
||||||
|
private String goodsCategoryName;
|
||||||
|
@Excel(name = "类别类型. 1.服务类 2.商品类", cellType = Excel.ColumnType.STRING)
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
@Excel(name = "排序", cellType = Excel.ColumnType.STRING)
|
@Excel(name = "排序", cellType = Excel.ColumnType.STRING)
|
||||||
private Integer categorySort;
|
private Integer categorySort;
|
||||||
|
|
@ -31,4 +37,5 @@ public class DeptGoodsCategory extends BaseEntity {
|
||||||
|
|
||||||
@Excel(name = "三级分销扣点比例", cellType = Excel.ColumnType.STRING)
|
@Excel(name = "三级分销扣点比例", cellType = Excel.ColumnType.STRING)
|
||||||
private String threeRate;
|
private String threeRate;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ import lombok.Data;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品
|
* 商品
|
||||||
*
|
*
|
||||||
* @author clunt
|
* @author clunt
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class Goods extends BaseEntity {
|
public class Goods extends BaseEntity {
|
||||||
|
|
@ -30,23 +30,21 @@ public class Goods extends BaseEntity {
|
||||||
|
|
||||||
@Excel(name = "价格")
|
@Excel(name = "价格")
|
||||||
private BigDecimal goodsPrice;
|
private BigDecimal goodsPrice;
|
||||||
|
|
||||||
@Excel(name = "优惠价")
|
@Excel(name = "优惠价")
|
||||||
private BigDecimal discountsPrice;
|
private BigDecimal discountsPrice;
|
||||||
|
|
||||||
@Excel(name = "团购价")
|
@Excel(name = "团购价")
|
||||||
private BigDecimal groupPrice;
|
private BigDecimal groupPrice;
|
||||||
|
|
||||||
/** 岗位排序 */
|
/**
|
||||||
|
* 岗位排序
|
||||||
|
*/
|
||||||
@Excel(name = "商品排序", cellType = Excel.ColumnType.NUMERIC)
|
@Excel(name = "商品排序", cellType = Excel.ColumnType.NUMERIC)
|
||||||
private String goodsSort;
|
private Integer goodsSort;
|
||||||
|
|
||||||
/** 状态(0上架 1下架 2删除) */
|
|
||||||
@Excel(name = "状态", readConverterExp = "0=上架,1=下架,2删除")
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
@Excel(name = "类别id")
|
@Excel(name = "类别id")
|
||||||
private Long goodsCategoryId;
|
private Long deptGoodsCategoryId;
|
||||||
|
|
||||||
@Excel(name = "商品图片", cellType = Excel.ColumnType.IMAGE)
|
@Excel(name = "商品图片", cellType = Excel.ColumnType.IMAGE)
|
||||||
private String goodsImgUrl;
|
private String goodsImgUrl;
|
||||||
|
|
@ -57,4 +55,9 @@ public class Goods extends BaseEntity {
|
||||||
@Excel(name = "商品库存,-1则表示无限制", cellType = Excel.ColumnType.NUMERIC)
|
@Excel(name = "商品库存,-1则表示无限制", cellType = Excel.ColumnType.NUMERIC)
|
||||||
private Integer goodsNumber;
|
private Integer goodsNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态(0上架 1下架 2删除)
|
||||||
|
*/
|
||||||
|
@Excel(name = "状态", readConverterExp = "0=上架,1=下架,2删除")
|
||||||
|
private Integer status;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import com.ghy.common.core.domain.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品类别表
|
* 商品类别表
|
||||||
*
|
*
|
||||||
* @author clunt
|
* @author clunt
|
||||||
*/
|
*/
|
||||||
|
|
@ -34,7 +34,7 @@ public class GoodsCategory extends BaseEntity {
|
||||||
private Integer level;
|
private Integer level;
|
||||||
|
|
||||||
@Excel(name = "类别类型. 1.服务类 2.商品类", cellType = Excel.ColumnType.STRING)
|
@Excel(name = "类别类型. 1.服务类 2.商品类", cellType = Excel.ColumnType.STRING)
|
||||||
private String type;
|
private Integer type;
|
||||||
|
|
||||||
@Excel(name = "状态")
|
@Excel(name = "状态")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.ghy.goods.mapper;
|
||||||
|
|
||||||
import com.ghy.goods.domain.DeptGoodsCategory;
|
import com.ghy.goods.domain.DeptGoodsCategory;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -42,6 +43,6 @@ public interface DeptGoodsCategoryMapper {
|
||||||
* @param goodsCategoryId 需要删除的数据ID
|
* @param goodsCategoryId 需要删除的数据ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
int deleteDeptGoodsCategoryByIds(Long[] goodsCategoryId);
|
int deleteDeptGoodsCategoryByIds(Collection<Long> goodsCategoryId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.ghy.goods.mapper;
|
||||||
|
|
||||||
import com.ghy.goods.domain.GoodsCategory;
|
import com.ghy.goods.domain.GoodsCategory;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -55,4 +56,12 @@ public interface GoodsCategoryMapper {
|
||||||
* @return 商品信息
|
* @return 商品信息
|
||||||
*/
|
*/
|
||||||
GoodsCategory selectByGoodsCategoryCode(String goodsCategoryCode);
|
GoodsCategory selectByGoodsCategoryCode(String goodsCategoryCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过ID批量查询商品类别
|
||||||
|
*
|
||||||
|
* @param ids 商品类别ID
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<GoodsCategory> selectByIds(Collection<Long> ids);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,50 @@
|
||||||
package com.ghy.goods.service;
|
package com.ghy.goods.service;
|
||||||
|
|
||||||
|
import com.ghy.goods.domain.DeptGoodsCategory;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分公司使用类目
|
* 分公司使用类目
|
||||||
|
*
|
||||||
* @author clunt
|
* @author clunt
|
||||||
*/
|
*/
|
||||||
public interface DeptGoodsCategoryService {
|
public interface DeptGoodsCategoryService {
|
||||||
|
|
||||||
// 选择使用指定的公司类别
|
/**
|
||||||
|
* 用deptId查询出该公司的所有类目
|
||||||
|
*
|
||||||
|
* @param deptId 公司ID
|
||||||
|
*/
|
||||||
|
List<DeptGoodsCategory> list(Long deptId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增一条分公司类目
|
||||||
|
*
|
||||||
|
* @param deptGoodsCategory 分公司类目
|
||||||
|
*/
|
||||||
|
int add(DeptGoodsCategory deptGoodsCategory);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑分公司类目
|
||||||
|
*
|
||||||
|
* @param deptGoodsCategory 分公司类目
|
||||||
|
*/
|
||||||
|
int edit(DeptGoodsCategory deptGoodsCategory);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除
|
||||||
|
*
|
||||||
|
* @param ids 分公司类目ID
|
||||||
|
*/
|
||||||
|
int delete(Collection<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用ID获取一条DeptGoodsCategory
|
||||||
|
*
|
||||||
|
* @param id 分公司类目ID
|
||||||
|
* @return 分公司类目
|
||||||
|
*/
|
||||||
|
DeptGoodsCategory get(long id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,9 @@ import com.ghy.common.core.domain.Ztree;
|
||||||
import com.ghy.common.core.domain.entity.SysDept;
|
import com.ghy.common.core.domain.entity.SysDept;
|
||||||
import com.ghy.goods.domain.GoodsCategory;
|
import com.ghy.goods.domain.GoodsCategory;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author clunt
|
* @author clunt
|
||||||
|
|
@ -38,7 +40,7 @@ public interface GoodsCategoryService {
|
||||||
* @param goodsCategory 类目信息
|
* @param goodsCategory 类目信息
|
||||||
* @return 所有类目信息
|
* @return 所有类目信息
|
||||||
*/
|
*/
|
||||||
public List<Ztree> selectCategoryTree(GoodsCategory goodsCategory);
|
List<Ztree> selectCategoryTree(GoodsCategory goodsCategory);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param goodsCategoryId 商品类别id
|
* @param goodsCategoryId 商品类别id
|
||||||
|
|
@ -67,4 +69,12 @@ public interface GoodsCategoryService {
|
||||||
* @return 校验结果 true重复 false不重复
|
* @return 校验结果 true重复 false不重复
|
||||||
*/
|
*/
|
||||||
boolean checkGoodsCategoryCodeUnique(GoodsCategory goodsCategory);
|
boolean checkGoodsCategoryCodeUnique(GoodsCategory goodsCategory);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过ID批量查询商品类别
|
||||||
|
*
|
||||||
|
* @param ids 商品类别ID
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<GoodsCategory> selectByIds(Collection<Long> ids);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,17 @@
|
||||||
package com.ghy.goods.service.impl;
|
package com.ghy.goods.service.impl;
|
||||||
|
|
||||||
|
import com.ghy.goods.domain.DeptGoodsCategory;
|
||||||
|
import com.ghy.goods.domain.GoodsCategory;
|
||||||
|
import com.ghy.goods.mapper.DeptGoodsCategoryMapper;
|
||||||
import com.ghy.goods.service.DeptGoodsCategoryService;
|
import com.ghy.goods.service.DeptGoodsCategoryService;
|
||||||
|
import com.ghy.goods.service.GoodsCategoryService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author clunt
|
* @author clunt
|
||||||
* 分公司使用类目
|
* 分公司使用类目
|
||||||
|
|
@ -12,6 +20,49 @@ import org.springframework.stereotype.Service;
|
||||||
@Service
|
@Service
|
||||||
public class DeptGoodsCategoryServiceImpl implements DeptGoodsCategoryService {
|
public class DeptGoodsCategoryServiceImpl implements DeptGoodsCategoryService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
GoodsCategoryService goodsCategoryService;
|
||||||
|
@Resource
|
||||||
|
DeptGoodsCategoryMapper deptGoodsCategoryMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DeptGoodsCategory> list(Long deptId) {
|
||||||
|
DeptGoodsCategory query = new DeptGoodsCategory();
|
||||||
|
query.setDeptId(deptId);
|
||||||
|
List<DeptGoodsCategory> result = deptGoodsCategoryMapper.selectDeptGoodsCategoryList(query);
|
||||||
|
if (result.isEmpty())
|
||||||
|
return result;
|
||||||
|
Set<Long> goodsCategoryIdSet = result.stream().map(DeptGoodsCategory::getGoodsCategoryId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||||
|
List<GoodsCategory> goodsCategoryList = goodsCategoryService.selectByIds(goodsCategoryIdSet);
|
||||||
|
Map<Long, GoodsCategory> goodsCategoryMap = goodsCategoryList.stream().collect(Collectors.toMap(GoodsCategory::getGoodsCategoryId, x -> x));
|
||||||
|
result.forEach(x -> {
|
||||||
|
GoodsCategory goodsCategory = goodsCategoryMap.get(x.getGoodsCategoryId());
|
||||||
|
if (goodsCategory != null) {
|
||||||
|
x.setGoodsCategoryName(goodsCategory.getGoodsCategoryName());
|
||||||
|
x.setGoodsCategoryCode(goodsCategory.getGoodsCategoryCode());
|
||||||
|
x.setType(goodsCategory.getType());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int add(DeptGoodsCategory deptGoodsCategory) {
|
||||||
|
return deptGoodsCategoryMapper.insertDeptGoodsCategory(deptGoodsCategory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int edit(DeptGoodsCategory deptGoodsCategory) {
|
||||||
|
return deptGoodsCategoryMapper.updateDeptGoodsCategory(deptGoodsCategory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int delete(Collection<Long> ids) {
|
||||||
|
return deptGoodsCategoryMapper.deleteDeptGoodsCategoryByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DeptGoodsCategory get(long id) {
|
||||||
|
return deptGoodsCategoryMapper.selectById(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,7 @@ package com.ghy.goods.service.impl;
|
||||||
|
|
||||||
import com.ghy.common.constant.UserConstants;
|
import com.ghy.common.constant.UserConstants;
|
||||||
import com.ghy.common.core.domain.Ztree;
|
import com.ghy.common.core.domain.Ztree;
|
||||||
import com.ghy.common.core.domain.entity.SysDept;
|
|
||||||
import com.ghy.common.core.text.Convert;
|
import com.ghy.common.core.text.Convert;
|
||||||
import com.ghy.common.utils.StringUtils;
|
|
||||||
import com.ghy.goods.domain.Goods;
|
import com.ghy.goods.domain.Goods;
|
||||||
import com.ghy.goods.domain.GoodsCategory;
|
import com.ghy.goods.domain.GoodsCategory;
|
||||||
import com.ghy.goods.mapper.GoodsCategoryMapper;
|
import com.ghy.goods.mapper.GoodsCategoryMapper;
|
||||||
|
|
@ -15,6 +13,7 @@ import org.springframework.util.Assert;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -68,7 +67,7 @@ public class GoodsCategoryServiceImpl implements GoodsCategoryService {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkGoodsCategoryNameUnique(GoodsCategory goodsCategory) {
|
public boolean checkGoodsCategoryNameUnique(GoodsCategory goodsCategory) {
|
||||||
GoodsCategory category = goodsCategoryMapper.selectByGoodsCategoryName(goodsCategory.getGoodsCategoryName());
|
GoodsCategory category = goodsCategoryMapper.selectByGoodsCategoryName(goodsCategory.getGoodsCategoryName());
|
||||||
if (category == null){
|
if (category == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return category.getGoodsCategoryId().equals(goodsCategory.getGoodsCategoryId());
|
return category.getGoodsCategoryId().equals(goodsCategory.getGoodsCategoryId());
|
||||||
|
|
@ -77,20 +76,24 @@ public class GoodsCategoryServiceImpl implements GoodsCategoryService {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkGoodsCategoryCodeUnique(GoodsCategory goodsCategory) {
|
public boolean checkGoodsCategoryCodeUnique(GoodsCategory goodsCategory) {
|
||||||
GoodsCategory category = goodsCategoryMapper.selectByGoodsCategoryCode(goodsCategory.getGoodsCategoryCode());
|
GoodsCategory category = goodsCategoryMapper.selectByGoodsCategoryCode(goodsCategory.getGoodsCategoryCode());
|
||||||
if (category == null){
|
if (category == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return category.getGoodsCategoryId().equals(goodsCategory.getGoodsCategoryId());
|
return category.getGoodsCategoryId().equals(goodsCategory.getGoodsCategoryId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<GoodsCategory> selectByIds(Collection<Long> ids) {
|
||||||
|
return goodsCategoryMapper.selectByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对象转类目树
|
* 对象转类目树
|
||||||
*
|
*
|
||||||
* @param goodsCategoryList 类目列表
|
* @param goodsCategoryList 类目列表
|
||||||
* @return 树结构列表
|
* @return 树结构列表
|
||||||
*/
|
*/
|
||||||
public List<Ztree> initZtree(List<GoodsCategory> goodsCategoryList)
|
public List<Ztree> initZtree(List<GoodsCategory> goodsCategoryList) {
|
||||||
{
|
|
||||||
return initZtree(goodsCategoryList, null);
|
return initZtree(goodsCategoryList, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,17 +101,14 @@ public class GoodsCategoryServiceImpl implements GoodsCategoryService {
|
||||||
* 对象转部门树
|
* 对象转部门树
|
||||||
*
|
*
|
||||||
* @param goodsCategoryList 类目列表
|
* @param goodsCategoryList 类目列表
|
||||||
* @param roleDeptList 该列表无需校验
|
* @param roleDeptList 该列表无需校验
|
||||||
* @return 树结构列表
|
* @return 树结构列表
|
||||||
*/
|
*/
|
||||||
public List<Ztree> initZtree(List<GoodsCategory> goodsCategoryList, List<String> roleDeptList)
|
public List<Ztree> initZtree(List<GoodsCategory> goodsCategoryList, List<String> roleDeptList) {
|
||||||
{
|
|
||||||
|
|
||||||
List<Ztree> ztrees = new ArrayList<Ztree>();
|
List<Ztree> ztrees = new ArrayList<Ztree>();
|
||||||
for (GoodsCategory goodsCategory : goodsCategoryList)
|
for (GoodsCategory goodsCategory : goodsCategoryList) {
|
||||||
{
|
if (UserConstants.CATEGORY_NORMAL.equals(goodsCategory.getStatus())) {
|
||||||
if (UserConstants.CATEGORY_NORMAL.equals(goodsCategory.getStatus()))
|
|
||||||
{
|
|
||||||
Ztree ztree = new Ztree();
|
Ztree ztree = new Ztree();
|
||||||
ztree.setId(goodsCategory.getGoodsCategoryId());
|
ztree.setId(goodsCategory.getGoodsCategoryId());
|
||||||
ztree.setpId(goodsCategory.getParentCategoryId());
|
ztree.setpId(goodsCategory.getParentCategoryId());
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectDeptGoodsCategory">
|
<sql id="selectDeptGoodsCategory">
|
||||||
SELECT dept_goods_category_id, dept_id, dept_goods_category_id, category_sort,
|
SELECT dept_goods_category_id, dept_id, goods_category_id, category_sort,
|
||||||
one_rate, two_rate, three_rate, create_by, create_time, remark
|
one_rate, two_rate, three_rate, create_by, create_time, remark
|
||||||
FROM dept_goods_category
|
FROM dept_goods_category
|
||||||
</sql>
|
</sql>
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
<insert id="insertDeptGoodsCategory" parameterType="com.ghy.goods.domain.DeptGoodsCategory" useGeneratedKeys="true"
|
<insert id="insertDeptGoodsCategory" parameterType="com.ghy.goods.domain.DeptGoodsCategory" useGeneratedKeys="true"
|
||||||
keyProperty="goodsCategoryId">
|
keyProperty="goodsCategoryId">
|
||||||
insert into dept_goods_category(
|
insert into dept_goods_category(
|
||||||
<if test="deptId != null and goodsCategoryCode != ''">dept_id,</if>
|
<if test="deptId != null and deptId != ''">dept_id,</if>
|
||||||
<if test="goodsCategoryId != null">goods_category_id,</if>
|
<if test="goodsCategoryId != null">goods_category_id,</if>
|
||||||
<if test="categorySort != null">category_sort,</if>
|
<if test="categorySort != null">category_sort,</if>
|
||||||
<if test="oneRate != null and oneRate != ''">one_rate,</if>
|
<if test="oneRate != null and oneRate != ''">one_rate,</if>
|
||||||
|
|
|
||||||
|
|
@ -93,4 +93,12 @@
|
||||||
<include refid="selectGoodsCategory"/>
|
<include refid="selectGoodsCategory"/>
|
||||||
WHERE goods_category_code = #{goodsCategoryCode} LIMIT 1
|
WHERE goods_category_code = #{goodsCategoryCode} LIMIT 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectByIds" parameterType="Long" resultMap="GoodsCategoryResult">
|
||||||
|
<include refid="selectGoodsCategory"/>
|
||||||
|
WHERE goods_category_id IN
|
||||||
|
<foreach collection="collection" item="goodsCategoryId" open="(" separator="," close=")">
|
||||||
|
#{goodsCategoryId}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
@ -9,10 +9,10 @@
|
||||||
<result property="deptId" column="dept_id" />
|
<result property="deptId" column="dept_id" />
|
||||||
<result property="goodsName" column="goods_name" />
|
<result property="goodsName" column="goods_name" />
|
||||||
<result property="goodsPrice" column="goods_price" />
|
<result property="goodsPrice" column="goods_price" />
|
||||||
<result property="discountsPrice" column="discounts_price" />
|
<result property="discountsPrice" column="discounts_price" />
|
||||||
<result property="groupPrice" column="group_price" />
|
<result property="groupPrice" column="group_price" />
|
||||||
<result property="goodsSort" column="goods_sort"/>
|
<result property="goodsSort" column="goods_sort"/>
|
||||||
<result property="goodsCategoryId" column="goods_category_id"/>
|
<result property="deptGoodsCategoryId" column="dept_goods_category_id"/>
|
||||||
<result property="goodsImgUrl" column="goods_img_url"/>
|
<result property="goodsImgUrl" column="goods_img_url"/>
|
||||||
<result property="goodsVideoUrl" column="goods_video_url"/>
|
<result property="goodsVideoUrl" column="goods_video_url"/>
|
||||||
<result property="goodsNumber" column="goods_number"/>
|
<result property="goodsNumber" column="goods_number"/>
|
||||||
|
|
@ -25,11 +25,69 @@
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectGoods">
|
<sql id="selectGoods">
|
||||||
select goods_id, goods_code, dept_id, goods_name, goods_price, discounts_price, group_price, goods_sort, goods_category_id,
|
SELECT goods_id, goods_code, dept_id, goods_name, goods_price, discounts_price, group_price, goods_sort,
|
||||||
goods_img_url, goods_number, status, create_by, create_time, remark
|
dept_goods_category_id, goods_img_url, goods_video_url, goods_number, status, create_by, create_time, remark
|
||||||
from goods
|
FROM goods
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
<update id="updateGoods" parameterType="com.ghy.goods.domain.Goods">
|
||||||
|
UPDATE goods
|
||||||
|
<set>
|
||||||
|
<if test="goodsCode != null and goodsCode != ''">goods_code = #{goodsCode},</if>
|
||||||
|
<if test="deptId != null and deptId != ''">dept_id = #{deptId},</if>
|
||||||
|
<if test="goodsName != null and goodsName != ''">goods_name = #{goodsName},</if>
|
||||||
|
<if test="goodsPrice != null and goodsPrice != ''">goods_price = #{goodsPrice},</if>
|
||||||
|
<if test="discountsPrice != null and discountsPrice != ''">discounts_price = #{discountsPrice},</if>
|
||||||
|
<if test="groupPrice != null and groupPrice != ''">group_price = #{groupPrice},</if>
|
||||||
|
<if test="goodsSort != null and goodsSort != ''">goods_sort = #{goodsSort},</if>
|
||||||
|
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != ''">dept_goods_category_id = #{deptGoodsCategoryId},</if>
|
||||||
|
<if test="goodsImgUrl != null and goodsImgUrl != ''">goods_img_url = #{goodsImgUrl},</if>
|
||||||
|
<if test="goodsVideoUrl != null and goodsVideoUrl != ''">goods_video_url = #{goodsVideoUrl},</if>
|
||||||
|
<if test="goodsNumber != null and goodsNumber != ''">goods_number = #{goodsNumber},</if>
|
||||||
|
<if test="status != null and status != ''">`status` = #{status},</if>
|
||||||
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||||
|
update_time = sysdate()
|
||||||
|
</set>
|
||||||
|
WHERE goods_id = #{goodsId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<insert id="insertGoods" parameterType="com.ghy.goods.domain.Goods" useGeneratedKeys="true" keyProperty="goodsId">
|
||||||
|
insert into goods(
|
||||||
|
<if test="goodsCode != null and goodsCode != ''">goods_code,</if>
|
||||||
|
<if test="deptId != null and deptId != ''">dept_id,</if>
|
||||||
|
<if test="goodsName != null and goodsName != ''">goods_name,</if>
|
||||||
|
<if test="goodsPrice != null and goodsPrice != ''">goods_price,</if>
|
||||||
|
<if test="discountsPrice != null and discountsPrice != ''">discounts_price,</if>
|
||||||
|
<if test="groupPrice != null and groupPrice != ''">group_price,</if>
|
||||||
|
<if test="goodsSort != null and goodsSort != ''">goods_sort,</if>
|
||||||
|
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != 0">dept_goods_category_id,</if>
|
||||||
|
<if test="goodsImgUrl != null and goodsImgUrl != ''">goods_img_url,</if>
|
||||||
|
<if test="goodsVideoUrl != null and goodsVideoUrl != ''">goods_video_url,</if>
|
||||||
|
<if test="goodsNumber != null and goodsNumber != ''">goods_number,</if>
|
||||||
|
<if test="status != null and status != ''">status,</if>
|
||||||
|
<if test="remark != null and remark != ''">remark,</if>
|
||||||
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||||
|
create_time
|
||||||
|
)values(
|
||||||
|
<if test="goodsCode != null and goodsCode != ''">#{goodsCode},</if>
|
||||||
|
<if test="deptId != null and deptId != ''">#{deptId},</if>
|
||||||
|
<if test="goodsName != null and goodsName != ''">#{goodsName},</if>
|
||||||
|
<if test="goodsPrice != null and goodsPrice != ''">#{goodsPrice},</if>
|
||||||
|
<if test="discountsPrice != null and discountsPrice != ''">#{discountsPrice},</if>
|
||||||
|
<if test="groupPrice != null and groupPrice != ''">#{groupPrice},</if>
|
||||||
|
<if test="goodsSort != null and goodsSort != ''">#{goodsSort},</if>
|
||||||
|
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != 0">#{deptGoodsCategoryId},</if>
|
||||||
|
<if test="goodsImgUrl != null and goodsImgUrl != ''">#{goodsImgUrl},</if>
|
||||||
|
<if test="goodsVideoUrl != null and goodsVideoUrl != ''">#{goodsVideoUrl},</if>
|
||||||
|
<if test="goodsNumber != null and goodsNumber != ''">#{goodsNumber},</if>
|
||||||
|
<if test="status != null and status != ''">#{status},</if>
|
||||||
|
<if test="remark != null and remark != ''">#{remark},</if>
|
||||||
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||||
|
sysdate()
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
<select id="selectGoodsList" parameterType="com.ghy.goods.domain.Goods" resultMap="GoodsResult">
|
<select id="selectGoodsList" parameterType="com.ghy.goods.domain.Goods" resultMap="GoodsResult">
|
||||||
<include refid="selectGoods" />
|
<include refid="selectGoods" />
|
||||||
<where>
|
<where>
|
||||||
|
|
@ -38,7 +96,7 @@
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectById" parameterType="long" resultMap="GoodsResult">
|
<select id="selectById" parameterType="long" resultMap="GoodsResult">
|
||||||
<include refid="selectGoods"/>
|
<include refid="selectGoods"/>
|
||||||
<where>
|
<where>
|
||||||
|
|
@ -55,42 +113,6 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<update id="updateGoods" parameterType="com.ghy.goods.domain.Goods">
|
|
||||||
update goods
|
|
||||||
<set>
|
|
||||||
<if test="goodsCode != null and goodsCode != ''">goods_code = #{goodsCode},</if>
|
|
||||||
<if test="goodsName != null and goodsName != ''">goods_name = #{goodsName},</if>
|
|
||||||
<if test="goodsSort != null and goodsSort != ''">goods_sort = #{goodsSort},</if>
|
|
||||||
<if test="status != null and status != ''">status = #{status},</if>
|
|
||||||
<if test="remark != null">remark = #{remark},</if>
|
|
||||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
|
||||||
update_time = sysdate()
|
|
||||||
</set>
|
|
||||||
where goods_id = #{goodsId}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<insert id="insertGoods" parameterType="com.ghy.goods.domain.Goods" useGeneratedKeys="true" keyProperty="goodsId">
|
|
||||||
insert into goods(
|
|
||||||
<if test="goodsId != null and goodsId != 0">goods_id,</if>
|
|
||||||
<if test="goodsCode != null and goodsCode != ''">goods_code,</if>
|
|
||||||
<if test="goodsName != null and goodsName != ''">goods_name,</if>
|
|
||||||
<if test="goodsSort != null and goodsSort != ''">goods_sort,</if>
|
|
||||||
<if test="status != null and status != ''">status,</if>
|
|
||||||
<if test="remark != null and remark != ''">remark,</if>
|
|
||||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
|
||||||
create_time
|
|
||||||
)values(
|
|
||||||
<if test="goodsId != null and goodsId != 0">#{goodsId},</if>
|
|
||||||
<if test="goodsCode != null and goodsCode != ''">#{goodsCode},</if>
|
|
||||||
<if test="goodsName != null and goodsName != ''">#{goodsName},</if>
|
|
||||||
<if test="goodsSort != null and goodsSort != ''">#{goodsSort},</if>
|
|
||||||
<if test="status != null and status != ''">#{status},</if>
|
|
||||||
<if test="remark != null and remark != ''">#{remark},</if>
|
|
||||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
|
||||||
sysdate()
|
|
||||||
)
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<select id="checkGoodsNameUnique" parameterType="String" resultMap="GoodsResult">
|
<select id="checkGoodsNameUnique" parameterType="String" resultMap="GoodsResult">
|
||||||
<include refid="selectGoods"/>
|
<include refid="selectGoods"/>
|
||||||
where goods_name=#{goodsName} limit 1
|
where goods_name=#{goodsName} limit 1
|
||||||
|
|
@ -103,7 +125,7 @@
|
||||||
|
|
||||||
<select id="selectOneByGoodsCategoryId" parameterType="String" resultMap="GoodsResult">
|
<select id="selectOneByGoodsCategoryId" parameterType="String" resultMap="GoodsResult">
|
||||||
<include refid="selectGoods"/>
|
<include refid="selectGoods"/>
|
||||||
WHERE goods_category_id = #{goodsCategoryId} LIMIT 1
|
WHERE dept_goods_category_id = #{deptGoodsCategoryId} LIMIT 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue