dept category

This commit is contained in:
HH 2022-05-08 17:02:30 +08:00
parent 097965d7a0
commit 20f8f204b2
7 changed files with 344 additions and 8 deletions

View File

@ -0,0 +1,48 @@
package com.ghy.web.controller.goods;
import com.ghy.common.core.controller.BaseController;
import com.ghy.common.core.domain.Ztree;
import com.ghy.goods.service.GoodsCategoryService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.List;
@Controller
@RequestMapping("goods/deptcategory")
public class GoodsDeptCategoryController extends BaseController {
private static final String PREFIX = "goods/deptcategory";
@Resource
GoodsCategoryService goodsCategoryService;
// @Resource
// GoodsDeptCategoryService goodsDeptCategoryService;
@RequiresPermissions("goods:deptcategory:view")
@GetMapping()
public String goodsCategory() {
return PREFIX + "/deptcategory";
}
@RequiresPermissions("goods:deptcategory:add")
@GetMapping("/add")
public String edit(ModelMap mmap) {
return PREFIX + "/add";
}
@GetMapping("/tree")
@ResponseBody
public List<Ztree> goodsDeptCategoryTree() {
// Long parentId = ShiroUtils.getSysUser().getParentId();
// List<Ztree> ztrees = goodsDeptCategoryService.tree(parentId);
return goodsCategoryService.selectCategoryTree(null);
}
}

View File

@ -0,0 +1,64 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('修改角色')" />
<th:block th:include="include :: ztree-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-role-edit">
<div class="form-group">
<label class="col-sm-3 control-label">菜单权限:</label>
<div class="col-sm-8">
<label class="check-box">
<input type="checkbox" value="1">展开/折叠</label>
<label class="check-box">
<input type="checkbox" value="2">全选/全不选</label>
<label class="check-box">
<input type="checkbox" value="3" checked>父子联动</label>
<div id="menuTrees" class="ztree ztree-border"></div>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: ztree-js" />
<script type="text/javascript">
$(function() {
var url = ctx + "goods/deptcategory/tree";
var options = {
id: "menuTrees",
url: url,
check: { enable: true },
expandLevel: 0
};
$.tree.init(options);
});
function edit() {
var menuIds = $.tree.getCheckedNodes();
$.ajax({
cache : true,
type : "POST",
url : ctx + "system/role/edit",
data : {
"menuIds": menuIds
},
async : false,
error : function(request) {
$.modal.alertError("系统错误");
},
success : function(data) {
$.operate.successCallback(data);
}
});
}
function submitHandler() {
if ($.validate.form()) {
add();
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,113 @@
<!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="goodsCategoryName"/>
</li>
<li>
类目状态:<select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">
<option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}"
th:value="${dict.dictValue}"></option>
</select>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.treeTable.search()"><i
class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-primary" onclick="$.operate.edit(1)" shiro:hasPermission="goods:category:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-info" id="expandAllBtn">
<i class="fa fa-exchange"></i> 展开/折叠
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-tree-table"></table>
</div>
</div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
var addFlag = [[${@permission.hasPermi('goods:category:add')}]];
var editFlag = [[${@permission.hasPermi('goods:category:edit')}]];
var removeFlag = [[${@permission.hasPermi('goods:category:remove')}]];
var datas = [[${@dict.getType('sys_normal_disable')}]];
var prefix = ctx + "goods/category"
$(function() {
var options = {
code: "goodsCategoryId",
parentCode: "parentCategoryId",
uniqueId: "goodsCategoryId",
url: prefix + "/list",
createUrl: prefix + "/add/{id}",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove/{id}",
modalName: "类目",
columns: [{
field: 'selectItem',
radio: true
},
{
field: 'goodsCategoryName',
title: '类目名称',
align: "left"
},
{
field: 'categorySort',
title: '排序',
align: "left"
},
{
field: 'status',
title: '状态',
align: "left",
formatter: function(value, item, index) {
return $.table.selectDictLabel(datas, item.status);
}
},
{
field: 'createTime',
title: '创建时间',
align: "left"
},
{
title: '操作',
align: 'left',
formatter: function(value, row, index) {
if (row.parentId != 0) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.goodsCategoryId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-info btn-xs ' + addFlag + '" href="javascript:void(0)" onclick="$.operate.add(\'' + row.goodsCategoryId + '\')"><i class="fa fa-plus"></i>新增</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.goodsCategoryId + '\')"><i class="fa fa-trash"></i>删除</a>');
return actions.join('');
} else {
return "";
}
}
}]
};
$.treeTable.init(options);
});
</script>
</body>
</html>

View File

@ -21,7 +21,7 @@ public class DeptGoodsCategory extends BaseEntity {
private Long goodsCategoryId;
@Excel(name = "排序", cellType = Excel.ColumnType.STRING)
private String categorySort;
private Integer categorySort;
@Excel(name = "一级分销扣点比例", cellType = Excel.ColumnType.STRING)
private String oneRate;

View File

@ -1,11 +1,47 @@
package com.ghy.goods.mapper;
import com.ghy.goods.domain.DeptGoodsCategory;
import java.util.List;
/**
* 分公司使用类目mapper
*
* @author clunt
*/
public interface DeptGoodsCategoryMapper {
/**
* @param category 商品属性
* @return 成功条数
*/
int insertDeptGoodsCategory(DeptGoodsCategory category);
/**
* @param category 商品属性
* @return 成功条数
*/
int updateDeptGoodsCategory(DeptGoodsCategory category);
/**
* @param category 商品入参
* @return 商品集合
*/
List<DeptGoodsCategory> selectDeptGoodsCategoryList(DeptGoodsCategory category);
/**
* @param goodsCategoryId 商品id
* @return 商品
*/
DeptGoodsCategory selectById(Long goodsCategoryId);
/**
* 批量删除商品信息
*
* @param goodsCategoryId 需要删除的数据ID
* @return 结果
*/
int deleteDeptGoodsCategoryByIds(Long[] goodsCategoryId);
}

View File

@ -0,0 +1,11 @@
package com.ghy.goods.service;
import com.ghy.common.core.domain.Ztree;
import java.util.List;
public interface GoodsDeptCategoryService {
List<Ztree> tree(Long parentId);
}

View File

@ -3,19 +3,83 @@
<mapper namespace="com.ghy.goods.mapper.DeptGoodsCategoryMapper">
<resultMap id="DeptGoodsCategoryResult" type="com.ghy.goods.domain.DeptGoodsCategory">
<result property="deptGoodsCategoryId" column="dept_goods_category_id"/>
<result property="deptId" column="dept_id"/>
<result property="goodsCategoryId" column="goods_category_id"/>
<result property="categorySort" column="category_sort"/>
<result property="oneRate" column="one_rate"/>
<result property="twoRate" column="two_rate"/>
<result property="threeRate" column="three_rate"/>
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
</resultMap>
<sql id="selectDeptGoodsCategory">
SELECT create_by, create_time, remark
SELECT dept_goods_category_id, dept_id, dept_goods_category_id, category_sort,
one_rate, two_rate, three_rate, create_by, create_time, remark
FROM dept_goods_category
</sql>
<update id="updateDeptGoodsCategory" parameterType="com.ghy.goods.domain.DeptGoodsCategory">
UPDATE dept_goods_category
<set>
<if test="deptId != null and goodsCategoryCode != ''">dept_id = #{deptId},</if>
<if test="goodsCategoryId != null">goods_category_id = #{goodsCategoryId},</if>
<if test="categorySort != null">category_sort = #{categorySort},</if>
<if test="oneRate != null and oneRate != ''">one_rate = #{oneRate},</if>
<if test="twoRate != null and twoRate != ''">two_rate = #{twoRate},</if>
<if test="threeRate != null and threeRate != ''">three_rate = #{threeRate},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
WHERE dept_goods_category_id = #{goodsCategoryId}
</update>
<delete id="deleteDeptGoodsCategoryByIds" parameterType="Long">
DELETE FROM dept_goods_category WHERE dept_goods_category_id IN
<foreach collection="array" item="goodsCategoryId" open="(" separator="," close=")">
#{goodsCategoryId}
</foreach>
</delete>
</mapper>
<insert id="insertDeptGoodsCategory" parameterType="com.ghy.goods.domain.DeptGoodsCategory" useGeneratedKeys="true"
keyProperty="goodsCategoryId">
insert into dept_goods_category(
<if test="deptId != null and goodsCategoryCode != ''">dept_id,</if>
<if test="goodsCategoryId != null">goods_category_id,</if>
<if test="categorySort != null">category_sort,</if>
<if test="oneRate != null and oneRate != ''">one_rate,</if>
<if test="twoRate != null and twoRate != ''">two_rate,</if>
<if test="threeRate != null and threeRate != ''">three_rate,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="deptId != null and goodsCategoryCode != ''">#{deptId},</if>
<if test="goodsCategoryId != null">#{goodsCategoryId},</if>
<if test="categorySort != null">#{categorySort},</if>
<if test="oneRate != null and oneRate != ''">#{oneRate},</if>
<if test="twoRate != null and twoRate != ''">#{twoRate},</if>
<if test="threeRate != null and threeRate != ''">#{threeRate},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
</insert>
<select id="selectDeptGoodsCategoryList" parameterType="com.ghy.goods.domain.DeptGoodsCategory" resultMap="DeptGoodsCategoryResult">
<include refid="selectDeptGoodsCategory" />
<where>
<if test="deptId != null">
AND dept_id = #{deptId}
</if>
</where>
</select>
<select id="selectById" parameterType="long" resultMap="DeptGoodsCategoryResult">
<include refid="selectDeptGoodsCategory"/>
WHERE dept_goods_category_id = #{deptGoodsCategoryId}
</select>
</mapper>