New file |
| | |
| | | package cc.mrbird.febs.mall.controller; |
| | | |
| | | import cc.mrbird.febs.common.annotation.ControllerEndpoint; |
| | | import cc.mrbird.febs.common.controller.BaseController; |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | | import cc.mrbird.febs.mall.entity.MallGoodsCategory; |
| | | import cc.mrbird.febs.mall.entity.MallMember; |
| | | import cc.mrbird.febs.mall.service.IAdminMallGoodsCategoryService; |
| | | import cc.mrbird.febs.system.entity.Role; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.Map; |
| | | |
| | | @Slf4j |
| | | @Validated |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @RequestMapping(value = "/admin/goodsCategory") |
| | | public class AdminMallGoodsCategoryController extends BaseController { |
| | | |
| | | private final IAdminMallGoodsCategoryService goodsCategoryService; |
| | | |
| | | /** |
| | | * 商品分类列表 |
| | | * @param mallGoodsCategory |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @GetMapping("categoryList") |
| | | public FebsResponse getCategoryList(MallGoodsCategory mallGoodsCategory, QueryRequest request) { |
| | | Map<String, Object> data = getDataTable(goodsCategoryService.getCategoryList(mallGoodsCategory, request)); |
| | | return new FebsResponse().success().data(data); |
| | | } |
| | | |
| | | @GetMapping("categorys") |
| | | public FebsResponse getCategorys(MallGoodsCategory mallGoodsCategory) { |
| | | return new FebsResponse().success().data(goodsCategoryService.getCategorys(mallGoodsCategory)); |
| | | } |
| | | |
| | | /** |
| | | * 商品分类-新增 |
| | | */ |
| | | @PostMapping("addCategory") |
| | | @ControllerEndpoint(operation = " 商品分类-新增", exceptionMessage = "新增失败") |
| | | public FebsResponse addCategory(@Valid MallGoodsCategory mallGoodsCategory) { |
| | | return goodsCategoryService.addCategory(mallGoodsCategory); |
| | | } |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.controller; |
| | | |
| | | import cc.mrbird.febs.common.controller.BaseController; |
| | | import cc.mrbird.febs.common.entity.FebsConstant; |
| | | import cc.mrbird.febs.common.utils.FebsUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | @Controller("categoryView") |
| | | @RequestMapping(FebsConstant.VIEW_PREFIX + "modules/product") |
| | | @RequiredArgsConstructor |
| | | public class ViewMallGoodsCategoryController extends BaseController { |
| | | |
| | | /** |
| | | * 商品分类列表 |
| | | * @return |
| | | */ |
| | | @GetMapping("categoryList") |
| | | @RequiresPermissions("categoryList:view") |
| | | public String categoryList() { |
| | | return FebsUtil.view("modules/product/categoryList"); |
| | | } |
| | | |
| | | |
| | | @GetMapping("categoryAdd") |
| | | @RequiresPermissions("categoryAdd:add") |
| | | public String helpCenterAdd() { |
| | | return FebsUtil.view("modules/product/categoryAdd"); |
| | | } |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.entity; |
| | | |
| | | import cc.mrbird.febs.common.entity.BaseEntity; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @TableName("mall_goods_category") |
| | | public class MallGoodsCategory extends BaseEntity { |
| | | |
| | | private String name; |
| | | |
| | | private Long parentId; |
| | | |
| | | private String parentIds; |
| | | |
| | | @TableField(exist = false) |
| | | private String parentName; |
| | | |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.mapper; |
| | | |
| | | import cc.mrbird.febs.mall.entity.MallGoodsCategory; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface MallGoodsCategoryMapper extends BaseMapper<MallGoodsCategory> { |
| | | |
| | | IPage<MallGoodsCategory> selectCategoryList(Page<MallGoodsCategory> page, @Param("record")MallGoodsCategory mallGoodsCategory); |
| | | |
| | | List<MallGoodsCategory> selectCategoryByName(@Param("name")String name); |
| | | |
| | | List<MallGoodsCategory> getCategorys(); |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.service; |
| | | |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | | import cc.mrbird.febs.mall.entity.MallGoodsCategory; |
| | | import cc.mrbird.febs.system.entity.Role; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface IAdminMallGoodsCategoryService extends IService<MallGoodsCategory> { |
| | | |
| | | IPage<MallGoodsCategory> getCategoryList(MallGoodsCategory mallGoodsCategory, QueryRequest request); |
| | | |
| | | FebsResponse addCategory(MallGoodsCategory mallGoodsCategory); |
| | | |
| | | List<MallGoodsCategory> getCategorys(MallGoodsCategory mallGoodsCategory); |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.service.impl; |
| | | |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | | import cc.mrbird.febs.mall.entity.MallGoodsCategory; |
| | | import cc.mrbird.febs.mall.mapper.MallGoodsCategoryMapper; |
| | | import cc.mrbird.febs.mall.service.IAdminMallGoodsCategoryService; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class AdminMallGoodsCategoryService extends ServiceImpl<MallGoodsCategoryMapper, MallGoodsCategory> implements IAdminMallGoodsCategoryService { |
| | | |
| | | private final MallGoodsCategoryMapper mallGoodsCategoryMapper; |
| | | |
| | | @Override |
| | | public IPage<MallGoodsCategory> getCategoryList(MallGoodsCategory mallGoodsCategory, QueryRequest request) { |
| | | Page<MallGoodsCategory> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | IPage<MallGoodsCategory> mallGoodsCategorys = this.baseMapper.selectCategoryList(page, mallGoodsCategory); |
| | | return mallGoodsCategorys; |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse addCategory(MallGoodsCategory mallGoodsCategory) { |
| | | String name = mallGoodsCategory.getName(); |
| | | if(StrUtil.isEmpty(name)){ |
| | | return new FebsResponse().fail().message("分类名称不能为空"); |
| | | } |
| | | List<MallGoodsCategory> categorys = mallGoodsCategoryMapper.selectCategoryByName(name); |
| | | if(CollUtil.isNotEmpty(categorys)){ |
| | | return new FebsResponse().fail().message("分类名称不能重复"); |
| | | } |
| | | |
| | | MallGoodsCategory goodsCategory = new MallGoodsCategory(); |
| | | goodsCategory.setName(name); |
| | | if(ObjectUtil.isNotEmpty(mallGoodsCategory.getParentId())){ |
| | | Long parentId = mallGoodsCategory.getParentId(); |
| | | MallGoodsCategory mallGoodsCategoryParent = mallGoodsCategoryMapper.selectById(parentId); |
| | | goodsCategory.setParentId(mallGoodsCategory.getParentId()); |
| | | // goodsCategory.setParentIds(mallGoodsCategoryParent.getParentIds()+mallGoodsCategory.getParentId()+","); |
| | | } |
| | | mallGoodsCategoryMapper.insert(goodsCategory); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @Override |
| | | public List<MallGoodsCategory> getCategorys(MallGoodsCategory mallGoodsCategory) { |
| | | List<MallGoodsCategory> mallGoodsCategorys = mallGoodsCategoryMapper.getCategorys(); |
| | | return mallGoodsCategorys; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cc.mrbird.febs.mall.mapper.MallGoodsCategoryMapper"> |
| | | |
| | | <select id="selectCategoryList" resultType="cc.mrbird.febs.mall.entity.MallGoodsCategory"> |
| | | SELECT m.name,b.name |
| | | FROM mall_goods_category m |
| | | left join mall_goods_category b on m.parent_id = b.id |
| | | <where> |
| | | <if test="record != null" > |
| | | <if test="record.name!=null and record.name!=''"> |
| | | and m.name like concat('%', #{record.name},'%') |
| | | </if> |
| | | </if> |
| | | </where> |
| | | order by m.CREATED_TIME desc |
| | | </select> |
| | | |
| | | <select id="selectCategoryByName" resultType="cc.mrbird.febs.mall.entity.MallGoodsCategory"> |
| | | SELECT * FROM mall_goods_category m where m.name = #{name} |
| | | </select> |
| | | |
| | | <select id="getCategorys" resultType="cc.mrbird.febs.mall.entity.MallGoodsCategory"> |
| | | SELECT * FROM mall_goods_category m where m.parent_id is null |
| | | </select> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <style> |
| | | #user-add { |
| | | padding: 20px 25px 25px 0; |
| | | } |
| | | |
| | | #user-add .layui-treeSelect .ztree li a, .ztree li span { |
| | | margin: 0 0 2px 3px !important; |
| | | } |
| | | #user-add #data-permission-tree-block { |
| | | border: 1px solid #eee; |
| | | border-radius: 2px; |
| | | padding: 3px 0; |
| | | } |
| | | #user-add .layui-treeSelect .ztree li span.button.switch { |
| | | top: 1px; |
| | | left: 3px; |
| | | } |
| | | |
| | | </style> |
| | | <div class="layui-fluid" id="user-add"> |
| | | <form class="layui-form" action="" lay-filter="user-add-form"> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label febs-form-item-require">名称:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="name" |
| | | lay-verify="name" autocomplete="off" class="layui-input" > |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label ">父类:</label> |
| | | <div class="layui-input-block"> |
| | | <select name="parentId" |
| | | xm-select-direction="down" |
| | | xm-select="user-update-category" |
| | | xm-select-skin="default"> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item febs-hide"> |
| | | <button class="layui-btn" lay-submit="" lay-filter="categary-add-form-submit" id="submit"></button> |
| | | </div> |
| | | </form> |
| | | </div> |
| | | |
| | | <script data-th-inline="javascript"> |
| | | layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect', 'eleTree', 'laydate'], function () { |
| | | var $ = layui.$, |
| | | febs = layui.febs, |
| | | layer = layui.layer, |
| | | formSelects = layui.formSelects, |
| | | treeSelect = layui.treeSelect, |
| | | form = layui.form, |
| | | laydate = layui.laydate, |
| | | eleTree = layui.eleTree, |
| | | member = [[${member}]], |
| | | $view = $('#user-add'), |
| | | validate = layui.validate; |
| | | |
| | | form.render(); |
| | | laydate.render({ |
| | | elem: '#febs-form-group-date' |
| | | }); |
| | | |
| | | formSelects.render(); |
| | | |
| | | formSelects.config('user-update-category', { |
| | | searchUrl: ctx + 'admin/goodsCategory/categorys', |
| | | response: { |
| | | statusCode: 200 |
| | | }, |
| | | beforeSuccess: function (id, url, searchVal, result) { |
| | | var data = result.data; |
| | | var tranData = []; |
| | | for (var i = 0; i < data.length; i++) { |
| | | tranData.push({ |
| | | name: data[i].name, |
| | | value: data[i].id |
| | | }) |
| | | } |
| | | result.data = tranData; |
| | | return result; |
| | | }, |
| | | success: function () { |
| | | formSelects.value('user-update-category', user.id.split(',')); |
| | | }, |
| | | error: function (id, url, searchVal, err) { |
| | | console.error(err); |
| | | febs.alert.error('获取分类列表失败'); |
| | | } |
| | | }); |
| | | |
| | | form.on('submit(categary-add-form-submit)', function (data) { |
| | | febs.post(ctx + 'admin/goodsCategory/addCategory', data.field, function () { |
| | | layer.closeAll(); |
| | | febs.alert.success('新增成功'); |
| | | $('#febs-user').find('#reset').click(); |
| | | }); |
| | | return false; |
| | | }); |
| | | }); |
| | | </script> |
New file |
| | |
| | | <div class="layui-fluid layui-anim febs-anim" id="febs-user" lay-title="商品分类"> |
| | | <div class="layui-row febs-container"> |
| | | <div class="layui-col-md12"> |
| | | <div class="layui-card"> |
| | | <div class="layui-card-body febs-table-full"> |
| | | <form class="layui-form layui-table-form" lay-filter="user-table-form"> |
| | | <div class="layui-row"> |
| | | <div class="layui-col-md10"> |
| | | <div class="layui-form-item"> |
| | | <div class="layui-inline"> |
| | | <div class="layui-input-inline"> |
| | | <input type="text" placeholder="名称" name="name" autocomplete="off" class="layui-input"> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="layui-col-md2 layui-col-sm12 layui-col-xs12 table-action-area"> |
| | | <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="add"> |
| | | 新增 |
| | | </div> |
| | | <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain table-action" id="query"> |
| | | <i class="layui-icon"></i> |
| | | </div> |
| | | <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="reset"> |
| | | <i class="layui-icon"></i> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </form> |
| | | <table lay-filter="userTable" lay-data="{id: 'userTable'}"></table> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <!-- 表格操作栏 start --> |
| | | <script type="text/html" id="user-option"> |
| | | <span shiro:lacksPermission="user:view,user:update,user:delete"> |
| | | <span class="layui-badge-dot febs-bg-orange"></span> 无权限 |
| | | </span> |
| | | <a lay-event="edit" shiro:hasPermission="user:update"><i |
| | | class="layui-icon febs-edit-area febs-blue"></i></a> |
| | | </script> |
| | | <!-- 表格操作栏 end --> |
| | | <script data-th-inline="none" type="text/javascript"> |
| | | // 引入组件并初始化 |
| | | layui.use([ 'jquery', 'form', 'table', 'febs'], function () { |
| | | var $ = layui.jquery, |
| | | febs = layui.febs, |
| | | form = layui.form, |
| | | table = layui.table, |
| | | $view = $('#febs-user'), |
| | | $query = $view.find('#query'), |
| | | $add = $view.find('#add'), |
| | | $reset = $view.find('#reset'), |
| | | $searchForm = $view.find('form'), |
| | | sortObject = {field: 'phone', type: null}, |
| | | tableIns; |
| | | |
| | | form.render(); |
| | | |
| | | // 表格初始化 |
| | | initTable(); |
| | | |
| | | // 初始化表格操作栏各个按钮功能 |
| | | table.on('tool(userTable)', function (obj) { |
| | | var data = obj.data, |
| | | layEvent = obj.event; |
| | | if (layEvent === 'close') { |
| | | febs.modal.confirm('禁用', '确认禁用该账号?', function () { |
| | | closeAccount(data.id); |
| | | }); |
| | | } |
| | | if (layEvent === 'open') { |
| | | febs.modal.confirm('开启', '确认开启该账号?', function () { |
| | | openAccount(data.id); |
| | | }); |
| | | } |
| | | |
| | | if (layEvent === 'edit') { |
| | | febs.modal.open('身份认证', 'modules/member/memberDetail/' + data.id, { |
| | | btn: ['提交', '取消'], |
| | | yes: function (index, layero) { |
| | | $('#user-update').find('#submit').trigger('click'); |
| | | }, |
| | | btn2: function () { |
| | | layer.closeAll(); |
| | | } |
| | | }); |
| | | } |
| | | if (layEvent === 'see') { |
| | | febs.modal.open( '个人信息', 'modules/mallMember/detail/' + data.id, { |
| | | maxmin: true, |
| | | }); |
| | | } |
| | | }); |
| | | function closeAccount(id) { |
| | | febs.get(ctx + 'admin/mallMember/closeAccount/' + id, null, function () { |
| | | febs.alert.success('禁用成功'); |
| | | $query.click(); |
| | | }); |
| | | } |
| | | function openAccount(id) { |
| | | febs.get(ctx + 'admin/mallMember/openAccount/' + id, null, function () { |
| | | febs.alert.success('开启成功'); |
| | | $query.click(); |
| | | }); |
| | | } |
| | | |
| | | |
| | | // 查询按钮 |
| | | $query.on('click', function () { |
| | | var params = $.extend(getQueryParams(), {field: sortObject.field, order: sortObject.type}); |
| | | tableIns.reload({where: params, page: {curr: 1}}); |
| | | }); |
| | | |
| | | // 刷新按钮 |
| | | $reset.on('click', function () { |
| | | $searchForm[0].reset(); |
| | | sortObject.type = 'null'; |
| | | tableIns.reload({where: getQueryParams(), page: {curr: 1}, initSort: sortObject}); |
| | | }); |
| | | |
| | | $add.on('click', function () { |
| | | febs.modal.open('新增', 'modules/product/categoryAdd/', { |
| | | btn: ['提交', '取消'], |
| | | yes: function (index, layero) { |
| | | $('#user-add').find('#submit').trigger('click'); |
| | | }, |
| | | btn2: function () { |
| | | layer.closeAll(); |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | function initTable() { |
| | | tableIns = febs.table.init({ |
| | | elem: $view.find('table'), |
| | | id: 'userTable', |
| | | url: ctx + 'admin/goodsCategory/categoryList', |
| | | cols: [[ |
| | | {field: 'name', title: '名称', minWidth: 150,align:'left'}, |
| | | {field: 'parentName', title: '父级名称', minWidth: 150,align:'left'}, |
| | | // {title: '操作', |
| | | // templet: function (d) { |
| | | // if (d.accountStatus === 1) { |
| | | // return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="see" shiro:hasPermission="user:update">详情</button>' |
| | | // +'<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="close" shiro:hasPermission="user:update">禁用</button>' |
| | | // |
| | | // }else{ |
| | | // return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="see" shiro:hasPermission="user:update">详情</button>' |
| | | // +'<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="open" shiro:hasPermission="user:update">启用</button>' |
| | | // |
| | | // } |
| | | // },minWidth: 300,align:'center'} |
| | | ]] |
| | | }); |
| | | } |
| | | |
| | | // 获取查询参数 |
| | | function getQueryParams() { |
| | | return { |
| | | name: $searchForm.find('input[name="name"]').val().trim(), |
| | | }; |
| | | } |
| | | |
| | | }) |
| | | </script> |