Browse Source

添加字典

PLF 5 years ago
parent
commit
a70f55a55c

+ 9 - 1
src/main/java/com/caimei/modules/products/controller/CmMallProductsClassifyController.java

@@ -105,7 +105,15 @@ public class CmMallProductsClassifyController {
     @ResponseBody
     @RequestMapping(value = "switchClassify")
     public JsonModel switchClassify(Integer id) {
+        JsonModel jsonModel = JsonModel.newInstance();
         CmMallProductsClassify mallProductsClassify = cmMallProductsClassifyService.get(id);
+        CmMallOrganizeProducts cmMallOrganizeProducts = new CmMallOrganizeProducts();
+        cmMallOrganizeProducts.setOrganizeID(mallProductsClassify.getOrganizeID());
+        cmMallOrganizeProducts.setClassifyID(String.valueOf(id));
+        List<CmMallOrganizeProducts> list = cmMallOrganizeProductsService.findList(cmMallOrganizeProducts);
+        if (CollectionUtils.isNotEmpty(list)) {
+            return jsonModel.error("该分类中还存在商品,请把该分类的商品转移到别的分类后,再停用该分类");
+        }
         if (mallProductsClassify.getStatus().equals("1")) {
             mallProductsClassify.setStatus("2");//1启用,2停用
         } else {
@@ -113,7 +121,7 @@ public class CmMallProductsClassifyController {
         }
         mallProductsClassify.setUpdateTime(new Date());
         cmMallProductsClassifyService.updateStatus(mallProductsClassify);//更新会所表数据
-        return JsonModel.newInstance().success();
+        return jsonModel.success();
     }
 
     /**

+ 10 - 0
src/main/java/com/caimei/modules/shiro/controller/HomePageController.java

@@ -1,6 +1,7 @@
 package com.caimei.modules.shiro.controller;
 
 import com.caimei.modules.order.entity.NewOrderProduct;
+import com.caimei.modules.shiro.entity.SysDict;
 import com.caimei.modules.shiro.service.HomePageService;
 import com.caimei.utils.JsonModel;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -51,4 +52,13 @@ public class HomePageController {
         List<NewOrderProduct> orderProduct = homePageService.commodity(endTime, startTime, organizeID);
         return JsonModel.newInstance().success(orderProduct);
     }
+
+    /**
+     * 字典工具使用
+     */
+    @RequestMapping("dictionaries")
+    public List<SysDict> dictionaries(SysDict sysDict) {
+        List<SysDict> sysDictList = homePageService.dictionaries(sysDict);
+        return sysDictList;
+    }
 }

+ 3 - 0
src/main/java/com/caimei/modules/shiro/dao/HomePageDao.java

@@ -1,6 +1,7 @@
 package com.caimei.modules.shiro.dao;
 
 import com.caimei.modules.order.entity.NewOrderProduct;
+import com.caimei.modules.shiro.entity.SysDict;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -18,4 +19,6 @@ public interface HomePageDao {
     Integer orderQuantity(@Param("endTime") String endTime, @Param("startTime") String startTime, @Param("receiptStatus") String receiptStatus, @Param("organizeID") Integer organizeID);
 
     List<NewOrderProduct> commodity(@Param("endTime") String endTime, @Param("startTime") String startTime, @Param("organizeID") Integer organizeID);
+
+    List<SysDict> dictionaries(SysDict sysDict);
 }

+ 70 - 0
src/main/java/com/caimei/modules/shiro/entity/SysDict.java

@@ -0,0 +1,70 @@
+package com.caimei.modules.shiro.entity;
+
+import java.io.Serializable;
+
+public class SysDict implements Serializable {
+    private static final long serialVersionUID = 1L;
+    private Integer id;
+    private String value;    // 数据值
+    private String label;    // 标签名
+    private String type;    // 类型
+    private String description;// 描述
+    private Integer sort;    // 排序
+    private String parentId;//父Id
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public String getLabel() {
+        return label;
+    }
+
+    public void setLabel(String label) {
+        this.label = label;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public Integer getSort() {
+        return sort;
+    }
+
+    public void setSort(Integer sort) {
+        this.sort = sort;
+    }
+
+    public String getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(String parentId) {
+        this.parentId = parentId;
+    }
+}

+ 3 - 0
src/main/java/com/caimei/modules/shiro/service/HomePageService.java

@@ -1,6 +1,7 @@
 package com.caimei.modules.shiro.service;
 
 import com.caimei.modules.order.entity.NewOrderProduct;
+import com.caimei.modules.shiro.entity.SysDict;
 
 import java.util.List;
 import java.util.Map;
@@ -13,4 +14,6 @@ public interface HomePageService {
     Map<String, Object> sale(Integer organizeID);
 
     List<NewOrderProduct> commodity(String endTime, String startTime, Integer organizeID);
+
+    List<SysDict> dictionaries(SysDict sysDict);
 }

+ 6 - 0
src/main/java/com/caimei/modules/shiro/service/impl/HomePageServiceImpl.java

@@ -2,6 +2,7 @@ package com.caimei.modules.shiro.service.impl;
 
 import com.caimei.modules.order.entity.NewOrderProduct;
 import com.caimei.modules.shiro.dao.HomePageDao;
+import com.caimei.modules.shiro.entity.SysDict;
 import com.caimei.modules.shiro.service.HomePageService;
 import com.caimei.utils.AppUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -105,6 +106,11 @@ public class HomePageServiceImpl implements HomePageService {
         return commodity;
     }
 
+    @Override
+    public List<SysDict> dictionaries(SysDict sysDict) {
+        return homePageDao.dictionaries(sysDict);
+    }
+
     public Map<String, String> CalendarUtils(Integer money) {
         Map<String, String> map = new HashMap();
         //2、获取本月第一天凌晨开始时间00:00:00和最后一天的最后一刻时间23:59:59

+ 0 - 1
src/main/java/com/caimei/utils/ImageUploadUtils.java

@@ -8,7 +8,6 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Controller;
-import org.springframework.util.ClassUtils;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;

+ 22 - 0
src/main/resources/mapper/HomePageMapper.xml

@@ -101,4 +101,26 @@
         LIMIT
           10
     </select>
+
+    <select id="dictionaries" resultType="com.caimei.modules.shiro.entity.SysDict">
+        SELECT
+          id,
+          value,
+          label,
+          type,
+          description,
+          sort,
+          parent_id AS parentId
+        FROM
+          sys_dict
+        <where>
+            <if test="type != null and type != ''">
+              AND type = #{type}
+            </if>
+            <if test="value != null and value != ''">
+                AND value = #{value}
+            </if>
+        </where>
+        ORDER BY sort ASC
+    </select>
 </mapper>