فهرست منبع

商品管理 提交

qxp192083 5 سال پیش
والد
کامیت
a681f8fb1b
21فایلهای تغییر یافته به همراه1079 افزوده شده و 97 حذف شده
  1. 1 0
      dgtly-admin/pom.xml
  2. 0 1
      dgtly-admin/src/main/resources/templates/companyext/examine/approve.html
  3. 31 12
      dgtly-goods/dgtly-goods-admin/src/main/java/com/dgtly/goods/controller/GoodsInfoController.java
  4. 16 6
      dgtly-goods/dgtly-goods-admin/src/main/java/com/dgtly/goods/controller/GoodsTypeController.java
  5. 279 32
      dgtly-goods/dgtly-goods-admin/src/main/resources/templates/goods/info/add.html
  6. 1 1
      dgtly-goods/dgtly-goods-admin/src/main/resources/templates/goods/info/edit.html
  7. 56 13
      dgtly-goods/dgtly-goods-admin/src/main/resources/templates/goods/info/info.html
  8. 4 0
      dgtly-goods/dgtly-goods-common/pom.xml
  9. 105 0
      dgtly-goods/dgtly-goods-common/src/main/java/com/dgtly/goods/domain/GoodsAttribute.java
  10. 66 0
      dgtly-goods/dgtly-goods-common/src/main/java/com/dgtly/goods/domain/GoodsColor.java
  11. 61 6
      dgtly-goods/dgtly-goods-common/src/main/java/com/dgtly/goods/domain/GoodsInfo.java
  12. 67 0
      dgtly-goods/dgtly-goods-common/src/main/java/com/dgtly/goods/domain/GoodsSize.java
  13. 49 0
      dgtly-goods/dgtly-goods-common/src/main/java/com/dgtly/goods/mapper/GoodsAttributeMapper.java
  14. 33 0
      dgtly-goods/dgtly-goods-common/src/main/java/com/dgtly/goods/mapper/GoodsColorMapper.java
  15. 32 0
      dgtly-goods/dgtly-goods-common/src/main/java/com/dgtly/goods/mapper/GoodsSizeMapper.java
  16. 41 2
      dgtly-goods/dgtly-goods-common/src/main/java/com/dgtly/goods/service/impl/GoodsInfoServiceImpl.java
  17. 67 0
      dgtly-goods/dgtly-goods-common/src/main/resources/mapper/goods/GoodsAttributeMapper.xml
  18. 56 0
      dgtly-goods/dgtly-goods-common/src/main/resources/mapper/goods/GoodsColorMapper.xml
  19. 68 23
      dgtly-goods/dgtly-goods-common/src/main/resources/mapper/goods/GoodsInfoMapper.xml
  20. 45 0
      dgtly-goods/dgtly-goods-common/src/main/resources/mapper/goods/GoodsSizeMapper.xml
  21. 1 1
      dgtly-goods/dgtly-goods-common/src/main/resources/mapper/goods/GoodsTypeAttributeMapper.xml

+ 1 - 0
dgtly-admin/pom.xml

@@ -85,6 +85,7 @@
             <version>4.0.0</version>
         </dependency>
 
+
     </dependencies>
 
     <build>

+ 0 - 1
dgtly-admin/src/main/resources/templates/companyext/examine/approve.html

@@ -123,7 +123,6 @@
         function submitHandler() {
             var status = $('input[name="status"]:checked').val();
             var rejectReason = $("textarea[name='rejectReason']").val();
-            debugger;
             if(status == 2 ){
                 if(rejectReason==null || rejectReason.trim()==0){
                     $.modal.alertWarning("请填写驳回理由!");

+ 31 - 12
dgtly-goods/dgtly-goods-admin/src/main/java/com/dgtly/goods/controller/GoodsInfoController.java

@@ -1,6 +1,9 @@
 package com.dgtly.goods.controller;
 
 import java.util.List;
+
+import com.dgtly.common.utils.StringUtils;
+import com.dgtly.common.utils.file.FileUploadUtils;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -18,6 +21,7 @@ import com.dgtly.common.core.controller.BaseController;
 import com.dgtly.common.core.domain.AjaxResult;
 import com.dgtly.common.utils.poi.ExcelUtil;
 import com.dgtly.common.core.page.TableDataInfo;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * 商品基础详情Controller
@@ -54,18 +58,7 @@ public class GoodsInfoController extends BaseController
         return getDataTable(list);
     }
 
-    /**
-     * 导出商品基础详情列表
-     */
-    @RequiresPermissions("goods:info:export")
-    @PostMapping("/export")
-    @ResponseBody
-    public AjaxResult export(GoodsInfo goodsInfo)
-    {
-        List<GoodsInfo> list = goodsInfoService.selectGoodsInfoList(goodsInfo);
-        ExcelUtil<GoodsInfo> util = new ExcelUtil<GoodsInfo>(GoodsInfo.class);
-        return util.exportExcel(list, "info");
-    }
+
 
     /**
      * 新增商品基础详情
@@ -85,6 +78,17 @@ public class GoodsInfoController extends BaseController
     @ResponseBody
     public AjaxResult addSave(GoodsInfo goodsInfo)
     {
+
+        if(StringUtils.isNotEmpty(goodsInfo.getCover())){
+            //获取base64文件后缀
+            String houzhui = goodsInfo.getCover().split(";")[0].split("\\/")[1];
+            //获取base64值
+            String base64 = goodsInfo.getCover().substring( goodsInfo.getCover().indexOf(",") + 1);
+
+            //base64转文件 并返回展示url
+            String fileUrl = FileUploadUtils.base64ToFile(base64,FileUploadUtils.getDefaultBaseDir()+"/content",System.currentTimeMillis()+"."+houzhui);
+            goodsInfo.setCover(fileUrl);
+        }
         return toAjax(goodsInfoService.insertGoodsInfo(goodsInfo));
     }
 
@@ -122,4 +126,19 @@ public class GoodsInfoController extends BaseController
     {
         return toAjax(goodsInfoService.deleteGoodsInfoByIds(ids));
     }
+
+    /**
+     * 商品上下架
+     */
+    @RequiresPermissions("goods:info:putaway")
+    @PostMapping("/putaway")
+    @ResponseBody
+    public Object putaway(Long id,String putawayFlag)
+    {
+        GoodsInfo goodsInfo = new GoodsInfo();
+        goodsInfo.setId(id);
+        goodsInfo.setPutawayFlag(putawayFlag);
+        int i =  goodsInfoService.updateGoodsInfo(goodsInfo);
+        return toAjax(i);
+    }
 }

+ 16 - 6
dgtly-goods/dgtly-goods-admin/src/main/java/com/dgtly/goods/controller/GoodsTypeController.java

@@ -14,11 +14,8 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.ModelMap;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.HttpRequestHandler;
+import org.springframework.web.bind.annotation.*;
 import com.dgtly.common.annotation.Log;
 import com.dgtly.common.enums.BusinessType;
 import com.dgtly.goods.domain.GoodsType;
@@ -28,6 +25,8 @@ import com.dgtly.common.core.domain.AjaxResult;
 import com.dgtly.common.utils.poi.ExcelUtil;
 import com.dgtly.common.core.page.TableDataInfo;
 
+import javax.servlet.http.HttpServletRequest;
+
 /**
  * 商品分类列Controller
  * 
@@ -106,7 +105,7 @@ public class GoodsTypeController extends BaseController
         {
             type = new GoodsType();
             type.setId(0L);
-            type.setName("根目录目录");
+            type.setName("根目录");
         }
         mmap.put("type", type);
         return prefix + "/add";
@@ -135,6 +134,17 @@ public class GoodsTypeController extends BaseController
         return prefix + "/edit";
     }
 
+    /**
+     * 修改商品分类列
+     */
+    @PostMapping("/getInfo/{id}")
+    @ResponseBody
+    public Object getInfo(@PathVariable("id") Long id)
+    {
+        GoodsType goodsType = goodsTypeService.selectGoodsTypeById(id);
+        return AjaxResult.success(goodsType);
+    }
+
     /**
      * 修改保存商品分类列
      */

+ 279 - 32
dgtly-goods/dgtly-goods-admin/src/main/resources/templates/goods/info/add.html

@@ -5,28 +5,46 @@
     <th:block th:include="include :: summernote-css" />
     <th:block th:include="include :: datetimepicker-css" />
     <th:block th:include="include :: jasny-bootstrap-css" />
+    <style type="text/css">
+        .slideshow_span{
+            max-width: 200px; max-height: 200px; float: left;margin-right: 10px;
+        }
+    </style>
+
 </head>
 <body class="white-bg">
     <div class="wrapper wrapper-content animated fadeInRight ibox-content">
         <form class="form-horizontal m" id="form-info-add">
             <div class="row">
-                <div class="form-group">
-                    <label class="col-sm-1 control-label"><span style="color: red; ">*</span>商品名称:</label>
-                    <div class="col-sm-4">
-                        <input name="name" class="form-control" type="text" required>
+                <div class="col-sm-6">
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label"><span style="color: red; ">*</span>商品名称:</label>
+                        <div class="col-sm-8">
+                            <input name="name" class="form-control required" type="text" required>
+                        </div>
+                    </div>
+                </div>
+                <div class="col-sm-6">
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label"><span style="color: red; ">*</span>一口价:</label>
+                        <div class="col-sm-8">
+                            <input name="price" class="form-control number" type="text" required>
+                        </div>
                     </div>
                 </div>
             </div>
+            <!--封面和轮播图-->
             <div class="row">
+                <div class="col-sm-3">
                     <div class="form-group">
-                        <input id="fmzFile" name="fmzFile" type="hidden"/>
-                        <label class="col-sm-1 control-label"><span style="color: red; ">*</span>封面图:</label>
-                        <div class="col-sm-10">
+                        <input id="input_cover" name="cover" type="hidden"/>
+                        <label class="col-sm-4 control-label"><span style="color: red; ">*</span>封面图:</label>
+                        <div class="col-sm-8">
                             <div class="fileinput fileinput-new" data-provides="fileinput">
                                 <div class="fileinput-new thumbnail" style="width: 140px; height: 140px;">
-                                    <img th:src="@{/img/profile.jpg}">
+                                    <!--<img th:src="@{/img/profile.jpg}">-->
                                 </div>
-                                <div id="fmz" class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;">
+                                <div id="fmz" class="fileinput-preview fileinput-exists thumbnail" style="max-width: 400px; max-height: 300px;">
 
                                 </div>
                                 <div>
@@ -36,8 +54,23 @@
                             </div>
                         </div>
                     </div>
-            </div>
+                </div>
+                <div class="col-sm-8">
+                    <div class="form-group">
+                        <input id="input_slideshow" name="slideshow" type="hidden"/>
+                        <label class="col-sm-1 control-label">轮播图:</label>
+                        <div class="col-sm-11">
+                            <div id="div-slideshow-list">
 
+                            </div>
+                            <input type="file" id="input-slideshow-add" style="display: none;" onchange="upload_slideshow()"/>
+                            <div class="thumbnail slideshow_span" style="width:70px; font-size: 40px;color: black; text-align: center" id="btn-slideshow-add" >
+                                <i class="fa fa-plus"></i>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
             <div class="row">
                 <div class="col-sm-6">
                     <div class="form-group">
@@ -45,8 +78,8 @@
                         <label class="col-sm-2 control-label"><span style="color: red; ">*</span>所属分类:</label>
                         <div class="col-sm-8">
                             <div class="input-group">
-                                <input name="typeName" onclick="selectTypeTree()" id="input_typeTreeName" type="text" placeholder="请选择所属分类" class="form-control"
-                                       readonly="readonly" required>
+                                <input name="typeName" onclick="selectTypeTree()" id="input_typeTreeName" type="text" placeholder="请选择所属分类"
+                                       class="form-control required" readonly="readonly" required>
                                 <span class="input-group-addon"><i class="fa fa-search"></i></span>
                             </div>
                         </div>
@@ -58,8 +91,8 @@
                         <label class="col-sm-2 control-label"><span style="color: red; ">*</span>所属公司:</label>
                         <div class="col-sm-8">
                             <div class="input-group">
-                                <input name="companyName" onclick="selectCompanyList()" id="input_companyTreeName" type="text" placeholder="请选择所属公司" class="form-control"
-                                       readonly="readonly" required>
+                                <input name="companyName" onclick="selectCompanyList()" id="input_companyTreeName" type="text" placeholder="请选择所属公司"
+                                       class="form-control required" readonly="readonly" required>
                                 <span class="input-group-addon"><i class="fa fa-search"></i></span>
                             </div>
                         </div>
@@ -71,7 +104,7 @@
                     <div class="form-group">
                         <label class="col-sm-2 control-label"><span style="color: red; ">*</span>生产地点:</label>
                         <div class="col-sm-8">
-                            <textarea name="producedAddress" class="form-control"></textarea>
+                            <textarea name="producedAddress" class="form-control required" required></textarea>
                         </div>
                     </div>
                 </div>
@@ -79,7 +112,7 @@
                     <div class="form-group">
                         <label class="col-sm-2 control-label"><span style="color: red; ">*</span>仓库地址:</label>
                         <div class="col-sm-8">
-                            <textarea name="warehouseAddress" class="form-control"></textarea>
+                            <textarea name="warehouseAddress" class="form-control required" required></textarea>
                         </div>
                     </div>
                 </div>
@@ -91,7 +124,7 @@
                         <div class="col-sm-8">
                             <div class="input-group date">
                                 <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
-                                <input name="producedTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
+                                <input name="producedTime" class="form-control required" placeholder="yyyy-MM-dd" type="text" required>
                             </div>
                         </div>
                     </div>
@@ -100,7 +133,7 @@
                     <div class="form-group">
                         <label class="col-sm-2 control-label"><span style="color: red; ">*</span>配送方式:</label>
                         <div class="col-sm-8">
-                            <input name="delivery"  class="form-control" placeholder="请输入配送方式" type="text">
+                            <input name="delivery"  class="form-control required" placeholder="请输入配送方式" type="text" required>
                         </div>
                     </div>
                 </div>
@@ -110,7 +143,10 @@
                     <div class="form-group ">
                         <label class="col-sm-2 control-label"><span style="color: red; ">*</span>上架标志:</label>
                         <div class="col-sm-8">
-                            <input name="putawayFlag" class="form-control" type="text" required>
+                            <div class="radio-box" th:each="dict : ${@dict.getType('goods_putaway')}">
+                                <input type="radio" th:id="${dict.dictCode}" name="putawayFlag" th:value="${dict.dictValue}" th:checked="${dict.default}">
+                                <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
+                            </div>
                         </div>
                     </div>
                 </div>
@@ -118,21 +154,84 @@
                     <div class="form-group">
                         <label class="col-sm-2 control-label"><span style="color: red; ">*</span>单重:</label>
                         <div class="col-sm-8">
-                            <input name="weight" class="form-control" type="text">
+                            <input name="weight" class="form-control" type="text" required>
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <!--规格和颜色-->
+            <div class="row">
+                <div class="col-sm-6">
+                    <div class="form-group ">
+                        <label class="col-sm-2 control-label"></label>
+                        <div class="col-sm-6">
+                            <table class="table table-bordered table-striped">
+                                <thead>
+                                <tr style="background-color: #1ab394;color: white;">
+                                    <th >规格</th>
+                                </tr>
+                                </thead>
+                                <tbody id="tbody-size">
+                                </tbody>
+                            </table>
+                        </div>
+                        <div class="col-sm-2">
+                            <a class="btn btn-white btn-bitbucket" id="btn-size-add">
+                                <i class="fa fa-plus"></i>
+                            </a>
+                        </div>
+                    </div>
+                </div>
+                <div class="col-sm-6">
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label"></label>
+                        <div class="col-sm-6">
+                            <table class="table table-bordered table-striped">
+                                <thead>
+                                <tr style="background-color: #1ab394;color: white;">
+                                    <th >颜色</th>
+                                </tr>
+                                </thead>
+                                <tbody id="tbody-color">
+                                </tbody>
+                            </table>
+                        </div>
+                        <div class="col-sm-2">
+                            <a class="btn btn-white btn-bitbucket" id="btn-color-add">
+                                <i class="fa fa-plus"></i>
+                            </a>
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <!--动态属性-->
+            <div class="row" >
+                <div class="form-group">
+                    <label class="col-sm-1 control-label"><span style="color: red; ">*</span>属性:</label>
+                    <div class="col-sm-10">
+                        <div class="panel panel-primary">
+                            <div class="panel-heading">
+                                <h5>动态属性列表(选择分类后加载)</h5>
+                            </div>
+                            <div class="panel-body">
+                                <div class="row" id="div_area">
+
+                                </div>
+                            </div>
                         </div>
                     </div>
                 </div>
             </div>
+            <br/>
             <div class="row">
                 <div class="form-group">
                     <label class="col-sm-1 control-label"><span style="color: red; ">*</span>描述:</label>
                     <div class="col-sm-10">
-                        <input id="input_describe" name="describe" type="hidden">
+                        <input id="input_des" name="des" type="hidden" required>
                         <div class="summernote"></div>
                     </div>
                 </div>
             </div>
-
         </form>
     </div>
     <th:block th:include="include :: footer" />
@@ -141,7 +240,8 @@
     <th:block th:include="include :: jasny-bootstrap-js" />
     <script type="text/javascript">
         var prefix = ctx + "goods/info"
-
+        var sizeIndex=0;
+        var colorIndex=0;
         $('.summernote').summernote({
             placeholder: '请输入内容',
             height : 192,
@@ -171,7 +271,7 @@
                 dataType: 'json',
                 success: function(result) {
                     if (result.code == web_status.SUCCESS) {
-                        $(obj).summernote('editor.insertImage', result.url, result.fileName);
+                        $(obj).summernote('editor.insertImage', result.data.url, result.data.fileName);
                     } else {
                         $.modal.alertError(result.msg);
                     }
@@ -181,10 +281,77 @@
                 }
             });
         }
+        /*****表单校验***********/
+        $("#form-user-edit").validate({
+            onkeyup: false,
+            rules:{
+
+                price:{
+                    required:true,
+                    isPhone:true,
+                    remote: {
+                        url: ctx + "system/user/checkPhoneUnique",
+                        type: "post",
+                        dataType: "json",
+                        data: {
+                            "userId": function() {
+                                return $("#userId").val();
+                            },
+                            "phonenumber": function() {
+                                return $.common.trim($("#phonenumber").val());
+                            }
+                        },
+                        dataFilter: function (data, type) {
+                            return $.validate.unique(data);
+                        }
+                    }
+                },
+            },
+            messages: {
+                "userName": {
+                    required: "请输入用户名称",
+                },
+                "email": {
+                    required: "请输入邮箱",
+                    remote: "Email已经存在"
+                },
+                "phonenumber":{
+                    required: "请输入手机号码",
+                    remote: "手机号码已经存在"
+                }
+            },
+            focusCleanup: true
+        });
         /*********************提交*********************************/
         function submitHandler() {
+
             if ($.validate.form()) {
+                /*遍历轮播图*/
+                var obj = $("img[class='img-slideshow']")
+                var srcStr ='';
+                if(obj.length>0){
+                    for(var i =0;i<obj.length;i++){
+                        srcStr += $(obj[i]).attr('src');
+                        srcStr += ',';
+                    }
+                    srcStr =  srcStr.substr(0,srcStr.length-1)
+                    $("#input_slideshow").val(srcStr);
+                }
+                var sHTML = $('.summernote').summernote('code');
+                $("#input_des").val(sHTML);
+                if(sHTML==undefined||sHTML==''){
+                    $.modal.alertWarning("请添加商品描述");
+                    return;
+                }
+                var file = $('#fmz').find('img').attr('src');
+                if(file == undefined){
+                    $.modal.alertWarning("请上传图片");
+                    return;
+                }
+                $('#input_cover').val(file);
                 $.operate.save(prefix + "/add", $('#form-info-add').serialize());
+            }else{
+                $.modal.alertError("表单填写有误,请重新填写后提交");
             }
         }
 
@@ -214,27 +381,47 @@
             getTypyAttributu($("#input_typeId").val());
             layer.close(index);
         }
+        /**********************获取分类信息****************************/
         function getTypyAttributu(id){
+            console.log(id)
             $.ajax({
                 type: "POST",
-                url: ctx + "common/upload",
-                data: data,
-                cache: false,
+                url: ctx + "goods/type/getInfo/"+id,
                 contentType: false,
-                processData: false,
+                cache: false,
                 dataType: 'json',
                 success: function(result) {
                     if (result.code == web_status.SUCCESS) {
-                        $(obj).summernote('editor.insertImage', result.url, result.fileName);
+                        resolverType(result.data)
                     } else {
                         $.modal.alertError(result.msg);
                     }
                 },
                 error: function(error) {
-                    $.modal.alertWarning("图片上传失败。");
+                    $.modal.alertWarning("获取分类属性失败!");
                 }
             });
         }
+        /************************解析分类属性类表***************************/
+        function resolverType(goodsType){
+            $("#div_area").html("");
+            var objs = goodsType.goodsTypeAttributes;
+            var len= objs.length;
+            var str ="";
+            for (i = 0; i < len; i++) {
+                 str += ' <div class="col-sm-6">' +
+                    '                    <div class="form-group">' +
+                    '                        <label class="col-sm-2 control-label"><span style="color: red; ">*</span>'+objs[i].attributeName+':</label>' +
+                    '                        <div class="col-sm-8">' +
+                    '                            <input name="goodsAttributes['+i+'].attributeId" class="form-control" type="hidden" value="'+objs[i].id+'" >' +
+                    '                            <input name="goodsAttributes['+i+'].attributeName" class="form-control" type="hidden" value="'+objs[i].attributeName+'" >' +
+                    '                            <input name="goodsAttributes['+i+'].value" class="form-control required" type="text" required>' +
+                    '                        </div>' +
+                    '                    </div>' +
+                    '                </div>'
+            }
+            $("#div_area").html(str);
+        }
 
         /******************选择公司列表**********************************/
         function selectCompanyList() {
@@ -248,13 +435,73 @@
             $.modal.openOptions(options2);
         }
         function selectCompany(index, layero){
-            debugger
-            var tree = layero.find("iframe")[0].contentWindow.$._tree;
             var body = layer.getChildFrame('body', index);
             $("#input_companyId").val(body.find('#treeId').val());
             $("#input_companyTreeName").val(body.find('#treeName').val());
             layer.close(index);
         }
+
+        /*******************规格表格动态添加值*********************************************/
+        $("#btn-size-add").click(function(){
+            var htmlStr='';
+            htmlStr+='<tr><td class="input-group" style="padding: 0">';
+            htmlStr+='  <input name="goodsSizes['+sizeIndex+'].size" class="form-control required" type="text" required>'
+            htmlStr+='<span class="input-group-addon"><i class="fa fa-remove remove"></i></span>'
+            htmlStr+='</td></tr>';
+            sizeIndex++
+            $("#tbody-size").append(htmlStr)
+            $('.remove').on('click',function(){
+                $(this).parent().parent().parent('tr').remove();
+            });
+        })
+        /*******************颜色表格动态添加值*********************************************/
+        $("#btn-color-add").click(function(){
+            var htmlStr='';
+            htmlStr+='<tr><td class="input-group" style="padding: 0">';
+            htmlStr+='  <input name="goodsColors['+colorIndex+'].color" class="form-control required" type="text" required>'
+            htmlStr+='  <span class="input-group-addon"><i class="fa fa-remove remove"></i></span>'
+            htmlStr+='</td></tr>';
+            colorIndex++
+            $("#tbody-color").append(htmlStr);
+            $('.remove').on('click',function(){
+                $(this).parent().parent().parent('tr').remove();
+            });
+        })
+
+        /*******************轮播图添加图片************************/
+        $("#btn-slideshow-add").click(function(){
+
+            $("#input-slideshow-add").click();
+        })
+        function  upload_slideshow(){
+            if ($("#input-slideshow-add").val() == '') {
+                return;
+            }var data = new FormData();
+            data.append('file', document.getElementById('input-slideshow-add').files[0]);
+            $.ajax({
+                url:ctx+"common/upload",
+                type:"post",
+                data: data,
+                cache: false,
+                contentType: false,
+                processData: false,
+                dataType: 'json',
+                success: function(result) {
+                    if (result.code == web_status.SUCCESS) {
+                        var htmlStr='';
+                        htmlStr+='<div class="thumbnail slideshow_span" >'+
+                            '   <img class="img-slideshow" src="'+result.data.fileName+'">' +
+                            '</div>'
+                        $("#div-slideshow-list").append(htmlStr);
+                    } else {
+                        $.modal.alertError(result.msg);
+                    }
+                },
+                error:function(result) {
+                    alert("上传失败")
+                }
+            });
+        }
     </script>
 </body>
 </html>

+ 1 - 1
dgtly-goods/dgtly-goods-admin/src/main/resources/templates/goods/info/edit.html

@@ -47,7 +47,7 @@
             <div class="form-group">
                 <label class="col-sm-3 control-label">编辑器生成的详细描述html:</label>
                 <div class="col-sm-8">
-                    <textarea name="describe" class="form-control" required>[[*{describe}]]</textarea>
+                    <textarea name="des" class="form-control" required>[[*{des}]]</textarea>
                 </div>
             </div>
             <div class="form-group">

+ 56 - 13
dgtly-goods/dgtly-goods-admin/src/main/resources/templates/goods/info/info.html

@@ -35,15 +35,10 @@
                 <a class="btn btn-success" onclick="$.operate.addFull()" shiro:hasPermission="goods:info:add">
                     <i class="fa fa-plus"></i> 添加
                 </a>
-                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="goods:info:edit">
-                    <i class="fa fa-edit"></i> 修改
-                </a>
                 <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="goods:info:remove">
                     <i class="fa fa-remove"></i> 删除
                 </a>
-                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="goods:info:export">
-                    <i class="fa fa-download"></i> 导出
-                 </a>
+
             </div>
             <div class="col-sm-12 select-table table-striped">
                 <table id="bootstrap-table"></table>
@@ -53,7 +48,9 @@
     <th:block th:include="include :: footer" />
     <script th:inline="javascript">
         var editFlag = [[${@permission.hasPermi('goods:info:edit')}]];
+        var putawayFlag = [[${@permission.hasPermi('goods:info:putaway')}]];
         var removeFlag = [[${@permission.hasPermi('goods:info:remove')}]];
+        var putawayDict = [[${@dict.getType('goods_putaway')}]];
         var prefix = ctx + "goods/info";
 
         $(function() {
@@ -77,12 +74,21 @@
                     title : '商品名称'
                 },
                 {
-                    field : 'companyId', 
-                    title : '所属公司id'
+                    field : 'companyId',
+                    visible: false
+                },
+                {
+                    field : 'companyName',
+                    title : '所属公司'
+                },
+                {
+                    field : 'typeName',
+                    title : '所属类型',
                 },
                 {
                     field : 'typeId', 
-                    title : '所属类型id'
+                    title : '所属类型id',
+                    visible: false
                 },
                 {
                     field : 'price', 
@@ -90,7 +96,12 @@
                 },
                 {
                     field : 'cover', 
-                    title : '封面图片'
+                    title : '封面图片',
+                    formatter: function(value, row, index) {
+                        // 图片预览(注意:如存储在本地直接获取数据库路径,如有配置context-path需要使用ctx+路径)
+                        // 如:/profile/upload/2019/08/08/3b7a839aced67397bac694d77611ce72.png
+                        return $.table.imageView(value,250,250);
+                    }
                 },
                 {
                     field : 'producedTime', 
@@ -101,22 +112,54 @@
                     title : '单重'
                 },
                 {
-                    field : 'putawayFlag', 
-                    title : '上架标志'
+                    field : 'putawayFlag',
+                    title: '上架标志',
+                    width: '10%',
+                    align: "left",
+                    formatter: function(value, row, index) {
+                        return $.table.selectDictLabel(putawayDict, value);
+                    }
                 },
                 {
                     title: '操作',
                     align: 'center',
                     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.id + '\')"><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.id + '\')"><i class="fa fa-remove"></i>删除</a>');
+                        if(row.putawayFlag=="0"){
+                            actions.push('<a class="btn btn-primary btn-xs ' + putawayFlag + '" onclick="putaway('+row.id+',1)" shiro:hasPermission="goods:info:putaway"><i class="fa fa-edit"></i> 上架</a>');
+                        }else if(row.putawayFlag=="1"){
+                            actions.push('<a class="btn btn-warning btn-xs ' + putawayFlag + '" onclick="putaway('+row.id+',0)" shiro:hasPermission="goods:info:putaway"><i class="fa fa-download"></i> 下架</a>');
+                        }
                         return actions.join('');
                     }
                 }]
             };
             $.table.init(options);
         });
+
+        function putaway(id,putaway){
+            var data = new FormData();
+            data.append("id", id);
+            data.append("putawayFlag", putaway);
+            $.ajax({
+                type: "POST",
+                url: prefix + "/putaway",
+                data: data,
+                cache: false,
+                contentType: false,
+                processData: false,
+                dataType: 'json',
+                success: function (result) {
+                    if (result.code == web_status.SUCCESS) {
+                        $.table.refresh()
+                    } else {
+                        $.modal.alertError(result.msg);
+                    }
+                }
+            })
+        }
+
     </script>
 </body>
 </html>

+ 4 - 0
dgtly-goods/dgtly-goods-common/pom.xml

@@ -15,6 +15,10 @@
             <groupId>com.dgtly</groupId>
             <artifactId>dgtly-common</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.dgtly</groupId>
+            <artifactId>dgtly-system</artifactId>
+        </dependency>
     </dependencies>
 
 </project>

+ 105 - 0
dgtly-goods/dgtly-goods-common/src/main/java/com/dgtly/goods/domain/GoodsAttribute.java

@@ -0,0 +1,105 @@
+package com.dgtly.goods.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.dgtly.common.annotation.Excel;
+import com.dgtly.common.core.domain.BaseEntity;
+
+/**
+ * 商品属性对象 goods_attribute
+ * 
+ * @author dgtly
+ * @date 2020-02-13
+ */
+public class GoodsAttribute
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 所属分类属性id */
+    private Long id;
+
+    /** 所属商品id */
+    @Excel(name = "所属商品id")
+    private Long goodsId;
+
+    /** $column.columnComment */
+    @Excel(name = "所属商品id")
+    private Long attributeId;
+
+    /** 取值 */
+    @Excel(name = "取值")
+    private String value;
+
+
+    /** 属性名称 */
+    @Excel(name = "取值")
+    private String attributeName;
+
+    /**排序值*/
+    private String Sort;
+
+
+    public void setId(Long id) 
+    {
+        this.id = id;
+    }
+
+    public Long getId() 
+    {
+        return id;
+    }
+    public void setGoodsId(Long goodsId) 
+    {
+        this.goodsId = goodsId;
+    }
+
+    public Long getGoodsId() 
+    {
+        return goodsId;
+    }
+    public void setAttributeId(Long attributeId) 
+    {
+        this.attributeId = attributeId;
+    }
+
+    public Long getAttributeId() 
+    {
+        return attributeId;
+    }
+    public void setValue(String value) 
+    {
+        this.value = value;
+    }
+
+    public String getValue() 
+    {
+        return value;
+    }
+
+    public String getAttributeName() {
+        return attributeName;
+    }
+
+    public void setAttributeName(String attributeName) {
+        this.attributeName = attributeName;
+    }
+
+    public String getSort() {
+        return Sort;
+    }
+
+    public void setSort(String sort) {
+        Sort = sort;
+    }
+
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("goodsId", getGoodsId())
+            .append("attributeId", getAttributeId())
+            .append("value", getValue())
+            .toString();
+    }
+}

+ 66 - 0
dgtly-goods/dgtly-goods-common/src/main/java/com/dgtly/goods/domain/GoodsColor.java

@@ -0,0 +1,66 @@
+package com.dgtly.goods.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.dgtly.common.annotation.Excel;
+import com.dgtly.common.core.domain.BaseEntity;
+
+/**
+ * 商品颜色对象 goods_color
+ * 
+ * @author dgtly
+ * @date 2020-02-13
+ */
+public class GoodsColor
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 所属分类属性id */
+    private Long id;
+
+    /** 所属商品id */
+    @Excel(name = "所属商品id")
+    private Long goodsId;
+
+    /** 颜色 */
+    @Excel(name = "颜色")
+    private String color;
+
+
+    public void setId(Long id) 
+    {
+        this.id = id;
+    }
+
+    public Long getId() 
+    {
+        return id;
+    }
+    public void setGoodsId(Long goodsId) 
+    {
+        this.goodsId = goodsId;
+    }
+
+    public Long getGoodsId() 
+    {
+        return goodsId;
+    }
+    public void setColor(String color) 
+    {
+        this.color = color;
+    }
+
+    public String getColor() 
+    {
+        return color;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("goodsId", getGoodsId())
+            .append("color", getColor())
+            .toString();
+    }
+}

+ 61 - 6
dgtly-goods/dgtly-goods-common/src/main/java/com/dgtly/goods/domain/GoodsInfo.java

@@ -1,10 +1,12 @@
 package com.dgtly.goods.domain;
 
+import com.dgtly.system.domain.SysCompany;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import com.dgtly.common.annotation.Excel;
 import com.dgtly.common.core.domain.BaseEntity;
 import java.util.Date;
+import java.util.List;
 
 /**
  * 商品基础详情对象 goods_info
@@ -45,7 +47,7 @@ public class GoodsInfo extends BaseEntity
 
     /** 编辑器生成的详细描述html */
     @Excel(name = "编辑器生成的详细描述html")
-    private String describe;
+    private String des;
 
     /** 配送方式 */
     @Excel(name = "配送方式")
@@ -74,6 +76,18 @@ public class GoodsInfo extends BaseEntity
     /** '删除标志(0代表存在 2代表删除) */
     private String delFlag;
 
+    /** 属性列表*/
+    private List<GoodsAttribute> goodsAttributes;
+
+    private List<GoodsColor> goodsColors;
+    private List<GoodsSize> goodsSizes;
+
+    private String companyName;
+
+    private String typeName;
+
+
+
     public void setId(Long id) 
     {
         this.id = id;
@@ -137,14 +151,14 @@ public class GoodsInfo extends BaseEntity
     {
         return slideshow;
     }
-    public void setDescribe(String describe) 
+    public void setDes(String des)
     {
-        this.describe = describe;
+        this.des = des;
     }
 
-    public String getDescribe() 
+    public String getDes()
     {
-        return describe;
+        return des;
     }
     public void setDelivery(String delivery) 
     {
@@ -210,6 +224,47 @@ public class GoodsInfo extends BaseEntity
         return delFlag;
     }
 
+
+    public List<GoodsAttribute> getGoodsAttributes() {
+        return goodsAttributes;
+    }
+
+    public void setGoodsAttributes(List<GoodsAttribute> goodsAttributes) {
+        this.goodsAttributes = goodsAttributes;
+    }
+
+    public List<GoodsColor> getGoodsColors() {
+        return goodsColors;
+    }
+
+    public void setGoodsColors(List<GoodsColor> goodsColors) {
+        this.goodsColors = goodsColors;
+    }
+
+    public List<GoodsSize> getGoodsSizes() {
+        return goodsSizes;
+    }
+
+    public void setGoodsSizes(List<GoodsSize> goodsSizes) {
+        this.goodsSizes = goodsSizes;
+    }
+
+    public String getCompanyName() {
+        return companyName;
+    }
+
+    public void setCompanyName(String companyName) {
+        this.companyName = companyName;
+    }
+
+    public String getTypeName() {
+        return typeName;
+    }
+
+    public void setTypeName(String typeName) {
+        this.typeName = typeName;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@@ -220,7 +275,7 @@ public class GoodsInfo extends BaseEntity
             .append("price", getPrice())
             .append("cover", getCover())
             .append("slideshow", getSlideshow())
-            .append("describe", getDescribe())
+            .append("des", getDes())
             .append("delivery", getDelivery())
             .append("producedTime", getProducedTime())
             .append("producedAddress", getProducedAddress())

+ 67 - 0
dgtly-goods/dgtly-goods-common/src/main/java/com/dgtly/goods/domain/GoodsSize.java

@@ -0,0 +1,67 @@
+package com.dgtly.goods.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.dgtly.common.annotation.Excel;
+import com.dgtly.common.core.domain.BaseEntity;
+
+/**
+ * 商品规格对象 goods_size
+ * 
+ * @author dgtly
+ * @date 2020-02-13
+ */
+public class GoodsSize
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 所属分类属性id */
+    private Long id;
+
+    /** 所属商品id */
+    @Excel(name = "所属商品id")
+    private Long goodsId;
+
+    /** 规格 */
+    @Excel(name = "规格")
+    private String size;
+
+
+    public void setId(Long id) 
+    {
+        this.id = id;
+    }
+
+    public Long getId() 
+    {
+        return id;
+    }
+    public void setGoodsId(Long goodsId) 
+    {
+        this.goodsId = goodsId;
+    }
+
+    public Long getGoodsId() 
+    {
+        return goodsId;
+    }
+    public void setSize(String size) 
+    {
+        this.size = size;
+    }
+
+    public String getSize() 
+    {
+        return size;
+    }
+
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("goodsId", getGoodsId())
+            .append("size", getSize())
+            .toString();
+    }
+}

+ 49 - 0
dgtly-goods/dgtly-goods-common/src/main/java/com/dgtly/goods/mapper/GoodsAttributeMapper.java

@@ -0,0 +1,49 @@
+package com.dgtly.goods.mapper;
+
+import com.dgtly.goods.domain.GoodsAttribute;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 商品属性Mapper接口
+ * 
+ * @author dgtly
+ * @date 2020-02-13
+ */
+public interface GoodsAttributeMapper 
+{
+
+
+    /**
+     * 新增商品属性
+     * 
+     * @param goodsAttribute 商品属性
+     * @return 结果
+     */
+    public int insertGoodsAttribute(GoodsAttribute goodsAttribute);
+
+
+    /**
+     * 删除商品属性
+     * 
+     * @param id 商品属性ID
+     * @return 结果
+     */
+    public int deleteGoodsAttributeById(Long id);
+
+    /**
+     * 批量删除商品属性
+     * 
+     * @param ids 需要删除的数据ID
+     * @return 结果
+     */
+    public int deleteGoodsAttributeByIds(String[] ids);
+
+    /**
+     * 批量添加商品属性
+     * @param goodsAttributeList
+     * @return
+     */
+    public int insertGoodsAttributeList(@Param("list") List<GoodsAttribute> list, @Param("goodsId") Long goodsId);
+}

+ 33 - 0
dgtly-goods/dgtly-goods-common/src/main/java/com/dgtly/goods/mapper/GoodsColorMapper.java

@@ -0,0 +1,33 @@
+package com.dgtly.goods.mapper;
+
+import com.dgtly.goods.domain.GoodsAttribute;
+import com.dgtly.goods.domain.GoodsColor;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 商品颜色Mapper接口
+ * 
+ * @author dgtly
+ * @date 2020-02-13
+ */
+public interface GoodsColorMapper 
+{
+
+    /**
+     * 新增商品颜色
+     * 
+     * @param goodsColor 商品颜色
+     * @return 结果
+     */
+    public int insertGoodsColor(GoodsColor goodsColor);
+
+    /**
+     * 批量新增商品颜色
+     *
+     * @param list 商品颜色
+     * @return 结果
+     */
+    public int insertGoodsColorList(@Param("list") List<GoodsColor> list, @Param("goodsId") Long goodsId);
+}

+ 32 - 0
dgtly-goods/dgtly-goods-common/src/main/java/com/dgtly/goods/mapper/GoodsSizeMapper.java

@@ -0,0 +1,32 @@
+package com.dgtly.goods.mapper;
+
+import com.dgtly.goods.domain.GoodsColor;
+import com.dgtly.goods.domain.GoodsSize;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 商品规格Mapper接口
+ * 
+ * @author dgtly
+ * @date 2020-02-13
+ */
+public interface GoodsSizeMapper 
+{
+
+    /**
+     * 新增商品规格
+     * 
+     * @param goodsSize 商品规格
+     * @return 结果
+     */
+    public int insertGoodsSize(GoodsSize goodsSize);
+    /**
+     * 批量新增商品规格
+     *
+     * @param list 商品规格
+     * @return 结果
+     */
+    public int insertGoodsSizeList(@Param("list") List<GoodsSize> list, @Param("goodsId") Long goodsId);
+}

+ 41 - 2
dgtly-goods/dgtly-goods-common/src/main/java/com/dgtly/goods/service/impl/GoodsInfoServiceImpl.java

@@ -2,13 +2,17 @@ package com.dgtly.goods.service.impl;
 
 import java.util.List;
 import com.dgtly.common.utils.DateUtils;
-import com.dgtly.goods.mapper.GoodsInfoMapper;
+import com.dgtly.goods.domain.GoodsAttribute;
+import com.dgtly.goods.domain.GoodsColor;
+import com.dgtly.goods.domain.GoodsSize;
+import com.dgtly.goods.mapper.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.dgtly.goods.mapper.GoodsInfoMapper;
 import com.dgtly.goods.domain.GoodsInfo;
 import com.dgtly.goods.service.IGoodsInfoService;
 import com.dgtly.common.core.text.Convert;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 商品基础详情Service业务层处理
@@ -22,6 +26,15 @@ public class GoodsInfoServiceImpl implements IGoodsInfoService
     @Autowired
     private GoodsInfoMapper goodsInfoMapper;
 
+    @Autowired
+    private GoodsAttributeMapper goodsAttributeMapper;
+
+    @Autowired
+    private GoodsColorMapper goodsColorMapper;
+
+    @Autowired
+    private GoodsSizeMapper goodsSizeMapper;
+
     /**
      * 查询商品基础详情
      * 
@@ -53,10 +66,36 @@ public class GoodsInfoServiceImpl implements IGoodsInfoService
      * @return 结果
      */
     @Override
+    @Transactional
     public int insertGoodsInfo(GoodsInfo goodsInfo)
     {
         goodsInfo.setCreateTime(DateUtils.getNowDate());
-        return goodsInfoMapper.insertGoodsInfo(goodsInfo);
+        int num = goodsInfoMapper.insertGoodsInfo(goodsInfo);
+        if(goodsInfo.getGoodsAttributes()!=null&&goodsInfo.getGoodsAttributes().size()>0)
+        {
+            List<GoodsAttribute> goodsAttributeList = goodsInfo.getGoodsAttributes();
+            int i = goodsAttributeMapper.insertGoodsAttributeList(goodsAttributeList,goodsInfo.getId());
+            if (i!=goodsAttributeList.size()){
+                throw  new RuntimeException("插入商品属性数量不符");
+            }
+        }
+        if(goodsInfo.getGoodsColors()!=null&&goodsInfo.getGoodsColors().size()>0)
+        {
+            List<GoodsColor> goodsColorList = goodsInfo.getGoodsColors();
+            int i = goodsColorMapper.insertGoodsColorList(goodsColorList,goodsInfo.getId());
+            if (i!=goodsColorList.size()){
+                throw  new RuntimeException("插入商品颜色数量不符");
+            }
+        }
+        if(goodsInfo.getGoodsSizes()!=null&&goodsInfo.getGoodsSizes().size()>0)
+        {
+            List<GoodsSize> goodsSizeList = goodsInfo.getGoodsSizes();
+            int i = goodsSizeMapper.insertGoodsSizeList(goodsSizeList,goodsInfo.getId());
+            if (i!=goodsSizeList.size()){
+                throw  new RuntimeException("插入商品规格数量不符");
+            }
+        }
+        return num;
     }
 
     /**

+ 67 - 0
dgtly-goods/dgtly-goods-common/src/main/resources/mapper/goods/GoodsAttributeMapper.xml

@@ -0,0 +1,67 @@
+<?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="com.dgtly.goods.mapper.GoodsAttributeMapper">
+    
+    <resultMap type="GoodsAttribute" id="GoodsAttributeResult">
+        <result property="id"    column="id"    />
+        <result property="goodsId"    column="goods_id"    />
+        <result property="attributeId"    column="attribute_id"    />
+        <result property="value"    column="value"    />
+    </resultMap>
+
+    <sql id="selectGoodsAttributeVo">
+        select id, goods_id, attribute_id, value, create_time, create_by, update_time, update_by, remark from goods_attribute
+    </sql>
+
+    <select id="selectGoodsAttributeList" parameterType="GoodsAttribute" resultMap="GoodsAttributeResult">
+        <include refid="selectGoodsAttributeVo"/>
+        <where>  
+            <if test="goodsId != null "> and goods_id = #{goodsId}</if>
+            <if test="attributeId != null "> and attribute_id = #{attributeId}</if>
+            <if test="value != null  and value != ''"> and value = #{value}</if>
+        </where>
+    </select>
+
+        
+    <insert id="insertGoodsAttribute" parameterType="GoodsAttribute">
+        insert into goods_attribute
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null ">id,</if>
+            <if test="goodsId != null ">goods_id,</if>
+            <if test="attributeId != null ">attribute_id,</if>
+            <if test="value != null  and value != ''">value,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null ">#{id},</if>
+            <if test="goodsId != null ">#{goodsId},</if>
+            <if test="attributeId != null ">#{attributeId},</if>
+            <if test="value != null  and value != ''">#{value},</if>
+         </trim>
+    </insert>
+
+    <insert id="insertGoodsAttributeList" >
+        insert into goods_attribute (goods_id,attribute_id,value) values
+        <foreach collection="list" item="item" index="index"
+                 separator=",">
+            (
+            #{goodsId},
+            #{item.attributeId},
+            #{item.value}
+            )
+        </foreach>
+    </insert>
+
+    <delete id="deleteGoodsAttributeById" parameterType="Long">
+        delete from goods_attribute where id = #{id}
+    </delete>
+
+    <delete id="deleteGoodsAttributeByIds" parameterType="String">
+        delete from goods_attribute where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+    
+</mapper>

+ 56 - 0
dgtly-goods/dgtly-goods-common/src/main/resources/mapper/goods/GoodsColorMapper.xml

@@ -0,0 +1,56 @@
+<?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="com.dgtly.goods.mapper.GoodsColorMapper">
+    
+    <resultMap type="GoodsColor" id="GoodsColorResult">
+        <result property="id"    column="id"    />
+        <result property="goodsId"    column="goods_id"    />
+        <result property="color"    column="color"    />
+    </resultMap>
+
+    <sql id="selectGoodsColorVo">
+        select id, goods_id, color from goods_color
+    </sql>
+
+    <select id="selectGoodsColorList" parameterType="GoodsColor" resultMap="GoodsColorResult">
+        <include refid="selectGoodsColorVo"/>
+        <where>  
+            <if test="goodsId != null "> and goods_id = #{goodsId}</if>
+            <if test="color != null  and color != ''"> and color = #{color}</if>
+        </where>
+    </select>
+    
+    <select id="selectGoodsColorById" parameterType="Long" resultMap="GoodsColorResult">
+        <include refid="selectGoodsColorVo"/>
+        where id = #{id}
+    </select>
+        
+    <insert id="insertGoodsColor" parameterType="GoodsColor">
+        insert into goods_color
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null ">id,</if>
+            <if test="goodsId != null ">goods_id,</if>
+            <if test="color != null  and color != ''">color,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null ">#{id},</if>
+            <if test="goodsId != null ">#{goodsId},</if>
+            <if test="color != null  and color != ''">#{color},</if>
+         </trim>
+    </insert>
+
+    <insert id="insertGoodsColorList" >
+        insert into goods_color (goods_id,color) values
+        <foreach collection="list" item="item" index="index"
+                 separator=",">
+            (
+            #{goodsId},
+            #{item.color}
+            )
+        </foreach>
+    </insert>
+
+
+</mapper>

+ 68 - 23
dgtly-goods/dgtly-goods-common/src/main/resources/mapper/goods/GoodsInfoMapper.xml

@@ -12,7 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="price"    column="price"    />
         <result property="cover"    column="cover"    />
         <result property="slideshow"    column="slideshow"    />
-        <result property="describe"    column="describe"    />
+        <result property="des"    column="des"    />
         <result property="delivery"    column="delivery"    />
         <result property="producedTime"    column="produced_time"    />
         <result property="producedAddress"    column="produced_address"    />
@@ -25,37 +25,82 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateTime"    column="update_time"    />
         <result property="updateBy"    column="update_by"    />
         <result property="remark"    column="remark"    />
+        <result property="companyName"    column="companyName"    />
+        <result property="typeName"    column="typeName"    />
+        <collection  property="goodsAttributes"   javaType="java.util.List"       resultMap="GoodsAttributeResult" />
+        <collection  property="goodsSizes"   javaType="java.util.List"       resultMap="GoodsSizeResult" />
+        <collection  property="goodsColors"   javaType="java.util.List"       resultMap="GoodsColorResult" />
+    </resultMap>
+
+    <resultMap type="GoodsAttribute" id="GoodsAttributeResult">
+        <result property="id"    column="id"    />
+        <result property="goodsId"    column="goods_id"    />
+        <result property="attributeId"    column="attribute_id"    />
+        <result property="attributeName"    column="attributeName"    />
+        <result property="sort"    column="sort"    />
+        <result property="value"    column="value"    />
+    </resultMap>
+    <resultMap type="GoodsColor" id="GoodsColorResult">
+        <result property="id"    column="id"    />
+        <result property="goodsId"    column="goods_id"    />
+        <result property="color"    column="color"    />
+    </resultMap>
+    <resultMap type="GoodsSize" id="GoodsSizeResult">
+        <result property="id"    column="id"    />
+        <result property="goodsId"    column="goods_id"    />
+        <result property="size"    column="size"    />
     </resultMap>
 
     <sql id="selectGoodsInfoVo">
-        select id, name, company_id, type_id, price, cover, slideshow, describe, delivery, produced_time, produced_address, warehouse_address, weight, putaway_flag, del_flag, create_time, create_by, update_time, update_by, remark from goods_info
+        select gi.id, gi.name, gi.company_id, gi.type_id, gi.price, gi.cover, gi.slideshow, gi.des, gi.delivery, gi.produced_time, gi.produced_address,
+         gi.warehouse_address, gi.weight,gi.putaway_flag, gi.del_flag, gi.create_time, gi.create_by, gi.update_time, gi.update_by, gi.remark,
+         gt.name typeName,sc.company_name companyName,
+         ga.attribute_id,ga.value,gs.size,gc.color,
+         gta.attribute_name attributeName,gta.sort
+        from goods_info gi
+        left join goods_type gt on gt.id =gi.type_id
+        left join sys_company sc on sc.id =gi.company_id
+        left join goods_attribute ga on ga.goods_id = gi.id
+        left join goods_type_attribute gta on gta.id = ga.attribute_id
+        left join goods_size gs on gs.goods_id = gi.id
+        left join goods_color gc on gc.goods_id = gi.id
     </sql>
 
     <select id="selectGoodsInfoList" parameterType="GoodsInfo" resultMap="GoodsInfoResult">
-        <include refid="selectGoodsInfoVo"/>
-        <where>  
-            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
-            <if test="companyId != null "> and company_id = #{companyId}</if>
-            <if test="typeId != null "> and type_id = #{typeId}</if>
-            <if test="price != null "> and price = #{price}</if>
-            <if test="cover != null  and cover != ''"> and cover = #{cover}</if>
-            <if test="slideshow != null  and slideshow != ''"> and slideshow = #{slideshow}</if>
-            <if test="describe != null  and describe != ''"> and describe = #{describe}</if>
-            <if test="delivery != null  and delivery != ''"> and delivery = #{delivery}</if>
-            <if test="producedTime != null "> and produced_time = #{producedTime}</if>
-            <if test="producedAddress != null  and producedAddress != ''"> and produced_address = #{producedAddress}</if>
-            <if test="warehouseAddress != null  and warehouseAddress != ''"> and warehouse_address = #{warehouseAddress}</if>
-            <if test="weight != null  and weight != ''"> and weight = #{weight}</if>
-            <if test="putawayFlag != null  and putawayFlag != ''"> and putaway_flag = #{putawayFlag}</if>
+        select gi.id, gi.name, gi.company_id, gi.type_id, gi.price, gi.cover, gi.slideshow, gi.des, gi.delivery, gi.produced_time, gi.produced_address,
+        gi.warehouse_address, gi.weight,gi.putaway_flag, gi.del_flag, gi.create_time, gi.create_by, gi.update_time, gi.update_by, gi.remark,
+        gt.name typeName,sc.company_name companyName
+        from goods_info gi
+        left join goods_type gt on gt.id =gi.type_id
+        left join sys_company sc on sc.id =gi.company_id
+        <where>
+            gi.del_flag = "0"
+            <if test="name != null  and name != ''"> and gi.name like concat('%', #{name}, '%')</if>
+            <if test="companyId != null "> and gi.company_id = #{companyId}</if>
+            <if test="typeId != null "> and gi.type_id = #{typeId}</if>
+            <if test="price != null "> and gi.price = #{price}</if>
+            <if test="cover != null  and cover != ''"> and gi.cover = #{cover}</if>
+            <if test="slideshow != null  and slideshow != ''"> and gi.slideshow = #{slideshow}</if>
+            <if test="des != null  and des != ''"> and gi.des = #{des}</if>
+            <if test="delivery != null  and delivery != ''"> and gi.delivery = #{delivery}</if>
+            <if test="producedTime != null "> and gi.produced_time = #{producedTime}</if>
+            <if test="producedAddress != null  and producedAddress != ''"> and gi.produced_address = #{producedAddress}</if>
+            <if test="warehouseAddress != null  and warehouseAddress != ''"> and gi.warehouse_address = #{warehouseAddress}</if>
+            <if test="weight != null  and weight != ''"> and gi.weight = #{weight}</if>
+            <if test="putawayFlag != null  and putawayFlag != ''"> and gi.putaway_flag = #{putawayFlag}</if>
         </where>
+        order by gi.putaway_flag ,gi.create_time
     </select>
     
     <select id="selectGoodsInfoById" parameterType="Long" resultMap="GoodsInfoResult">
         <include refid="selectGoodsInfoVo"/>
-        where id = #{id}
+        where gi.id = #{id}
     </select>
         
     <insert id="insertGoodsInfo" parameterType="GoodsInfo" useGeneratedKeys="true" keyProperty="id">
+        <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
+            select LAST_INSERT_ID();
+        </selectKey>
         insert into goods_info
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="name != null  and name != ''">name,</if>
@@ -64,7 +109,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="price != null ">price,</if>
             <if test="cover != null  and cover != ''">cover,</if>
             <if test="slideshow != null  and slideshow != ''">slideshow,</if>
-            <if test="describe != null  and describe != ''">describe,</if>
+            <if test="des != null  and des != ''">des,</if>
             <if test="delivery != null  and delivery != ''">delivery,</if>
             <if test="producedTime != null ">produced_time,</if>
             <if test="producedAddress != null  and producedAddress != ''">produced_address,</if>
@@ -85,7 +130,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="price != null ">#{price},</if>
             <if test="cover != null  and cover != ''">#{cover},</if>
             <if test="slideshow != null  and slideshow != ''">#{slideshow},</if>
-            <if test="describe != null  and describe != ''">#{describe},</if>
+            <if test="des != null  and des != ''">#{des},</if>
             <if test="delivery != null  and delivery != ''">#{delivery},</if>
             <if test="producedTime != null ">#{producedTime},</if>
             <if test="producedAddress != null  and producedAddress != ''">#{producedAddress},</if>
@@ -110,7 +155,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="price != null ">price = #{price},</if>
             <if test="cover != null  and cover != ''">cover = #{cover},</if>
             <if test="slideshow != null  and slideshow != ''">slideshow = #{slideshow},</if>
-            <if test="describe != null  and describe != ''">describe = #{describe},</if>
+            <if test="des != null  and des != ''">des = #{des},</if>
             <if test="delivery != null  and delivery != ''">delivery = #{delivery},</if>
             <if test="producedTime != null ">produced_time = #{producedTime},</if>
             <if test="producedAddress != null  and producedAddress != ''">produced_address = #{producedAddress},</if>
@@ -128,11 +173,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </update>
 
     <delete id="deleteGoodsInfoById" parameterType="Long">
-        delete from goods_info where id = #{id}
+        update goods_info set  del_flag = '2' where  id = #{id}
     </delete>
 
     <delete id="deleteGoodsInfoByIds" parameterType="String">
-        delete from goods_info where id in 
+        update goods_info set  del_flag = '2' where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>

+ 45 - 0
dgtly-goods/dgtly-goods-common/src/main/resources/mapper/goods/GoodsSizeMapper.xml

@@ -0,0 +1,45 @@
+<?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="com.dgtly.goods.mapper.GoodsSizeMapper">
+    
+    <resultMap type="GoodsSize" id="GoodsSizeResult">
+        <result property="id"    column="id"    />
+        <result property="goodsId"    column="goods_id"    />
+        <result property="size"    column="size"    />
+    </resultMap>
+
+    <sql id="selectGoodsSizeVo">
+        select id, goods_id, size from goods_size
+    </sql>
+
+
+    <insert id="insertGoodsSize" parameterType="GoodsSize">
+        insert into goods_size
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null ">id,</if>
+            <if test="goodsId != null ">goods_id,</if>
+            <if test="size != null  and size != ''">size,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null ">#{id},</if>
+            <if test="goodsId != null ">#{goodsId},</if>
+            <if test="size != null  and size != ''">#{size},</if>
+         </trim>
+    </insert>
+
+    <insert id="insertGoodsSizeList" >
+        insert into goods_size (goods_id,size) values
+        <foreach collection="list" item="item" index="index"
+                 separator=",">
+            (
+            #{goodsId},
+            #{item.size}
+            )
+
+        </foreach>
+    </insert>
+
+    
+</mapper>

+ 1 - 1
dgtly-goods/dgtly-goods-common/src/main/resources/mapper/goods/GoodsTypeAttributeMapper.xml

@@ -60,7 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteGoodsTypeAttributeByIds" parameterType="String">
-        delete from goods_type_attribute where id in 
+        delete from goods_type_attribute where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>