Procházet zdrojové kódy

优化 菜单目录和 组关系功能

java110 před 4 roky
rodič
revize
8e22c2ce9b

+ 34 - 18
java110-bean/src/main/java/com/java110/dto/menuGroupCatalog/MenuGroupCatalogDto.java

@@ -1,6 +1,7 @@
 package com.java110.dto.menuGroupCatalog;
 
 import com.java110.dto.PageDto;
+
 import java.io.Serializable;
 import java.util.Date;
 
@@ -15,10 +16,18 @@ import java.util.Date;
 public class MenuGroupCatalogDto extends PageDto implements Serializable {
 
     private String storeType;
-private String gId;
-private String gcId;
-private String caId;
+    private String gId;
+    private String gcId;
+    private String caId;
+    private String mgName;
 
+    public String getGcId() {
+        return gcId;
+    }
+
+    public void setGcId(String gcId) {
+        this.gcId = gcId;
+    }
 
     private Date createTime;
 
@@ -28,25 +37,16 @@ private String caId;
     public String getStoreType() {
         return storeType;
     }
-public void setStoreType(String storeType) {
+
+    public void setStoreType(String storeType) {
         this.storeType = storeType;
     }
-public String getGId() {
-        return gId;
-    }
-public void setGId(String gId) {
-        this.gId = gId;
-    }
-public String getGcId() {
-        return gcId;
-    }
-public void setGcId(String gcId) {
-        this.gcId = gcId;
-    }
-public String getCaId() {
+
+    public String getCaId() {
         return caId;
     }
-public void setCaId(String caId) {
+
+    public void setCaId(String caId) {
         this.caId = caId;
     }
 
@@ -66,4 +66,20 @@ public void setCaId(String caId) {
     public void setStatusCd(String statusCd) {
         this.statusCd = statusCd;
     }
+
+    public String getgId() {
+        return gId;
+    }
+
+    public void setgId(String gId) {
+        this.gId = gId;
+    }
+
+    public String getMgName() {
+        return mgName;
+    }
+
+    public void setMgName(String mgName) {
+        this.mgName = mgName;
+    }
 }

+ 91 - 95
java110-db/src/main/resources/mapper/user/MenuCatalogV1ServiceDaoImplMapper.xml

@@ -5,120 +5,116 @@
 <mapper namespace="menuCatalogV1ServiceDaoImpl">
 
 
-
-
-
     <!-- 保存菜单目录信息 add by wuxw 2018-07-03 -->
     <insert id="saveMenuCatalogInfo" parameterType="Map">
         insert into m_menu_catalog(
-store_type,ca_id,name,icon,seq,url,is_show
-) values (
-#{storeType},#{caId},#{name},#{icon},#{seq},#{url},#{isShow}
-)
+        store_type,ca_id,name,icon,seq,url,is_show
+        ) values (
+        #{storeType},#{caId},#{name},#{icon},#{seq},#{url},#{isShow}
+        )
     </insert>
 
 
-
     <!-- 查询菜单目录信息 add by wuxw 2018-07-03 -->
     <select id="getMenuCatalogInfo" parameterType="Map" resultType="Map">
-        select  t.store_type,t.store_type storeType,t.ca_id,t.ca_id caId,t.name,t.icon,t.status_cd,t.status_cd statusCd,t.seq,t.url,t.is_show,t.is_show isShow 
-from m_menu_catalog t 
-where 1 =1 
-<if test="storeType !=null and storeType != ''">
-   and t.store_type= #{storeType}
-</if> 
-<if test="caId !=null and caId != ''">
-   and t.ca_id= #{caId}
-</if> 
-<if test="name !=null and name != ''">
-   and t.name= #{name}
-</if> 
-<if test="icon !=null and icon != ''">
-   and t.icon= #{icon}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="seq !=null and seq != ''">
-   and t.seq= #{seq}
-</if> 
-<if test="url !=null and url != ''">
-   and t.url= #{url}
-</if> 
-<if test="isShow !=null and isShow != ''">
-   and t.is_show= #{isShow}
-</if> 
-order by t.create_time desc
-<if test="page != -1 and page != null ">
-   limit #{page}, #{row}
-</if> 
+        select t.store_type,t.store_type storeType,t.ca_id,t.ca_id caId,t.name,t.icon,t.status_cd,t.status_cd
+        statusCd,t.seq,t.url,t.is_show,t.is_show isShow
+        from m_menu_catalog t
+        where 1 =1
+        <if test="storeType !=null and storeType != ''">
+            and t.store_type= #{storeType}
+        </if>
+        <if test="caId !=null and caId != ''">
+            and t.ca_id= #{caId}
+        </if>
+        <if test="name !=null and name != ''">
+            and t.name= #{name}
+        </if>
+        <if test="icon !=null and icon != ''">
+            and t.icon= #{icon}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="seq !=null and seq != ''">
+            and t.seq= #{seq}
+        </if>
+        <if test="url !=null and url != ''">
+            and t.url= #{url}
+        </if>
+        <if test="isShow !=null and isShow != ''">
+            and t.is_show= #{isShow}
+        </if>
+        order by t.seq
+        <if test="page != -1 and page != null ">
+            limit #{page}, #{row}
+        </if>
 
     </select>
 
 
-
-
     <!-- 修改菜单目录信息 add by wuxw 2018-07-03 -->
     <update id="updateMenuCatalogInfo" parameterType="Map">
-        update  m_menu_catalog t set t.status_cd = #{statusCd}
-<if test="newBId != null and newBId != ''">
-,t.b_id = #{newBId}
-</if> 
-<if test="storeType !=null and storeType != ''">
-, t.store_type= #{storeType}
-</if> 
-<if test="name !=null and name != ''">
-, t.name= #{name}
-</if> 
-<if test="icon !=null and icon != ''">
-, t.icon= #{icon}
-</if> 
-<if test="seq !=null and seq != ''">
-, t.seq= #{seq}
-</if> 
-<if test="url !=null and url != ''">
-, t.url= #{url}
-</if> 
-<if test="isShow !=null and isShow != ''">
-, t.is_show= #{isShow}
-</if> 
- where 1=1 <if test="caId !=null and caId != ''">
-and t.ca_id= #{caId}
-</if> 
+        update m_menu_catalog t set t.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,t.b_id = #{newBId}
+        </if>
+        <if test="storeType !=null and storeType != ''">
+            , t.store_type= #{storeType}
+        </if>
+        <if test="name !=null and name != ''">
+            , t.name= #{name}
+        </if>
+        <if test="icon !=null and icon != ''">
+            , t.icon= #{icon}
+        </if>
+        <if test="seq !=null and seq != ''">
+            , t.seq= #{seq}
+        </if>
+        <if test="url !=null and url != ''">
+            , t.url= #{url}
+        </if>
+        <if test="isShow !=null and isShow != ''">
+            , t.is_show= #{isShow}
+        </if>
+        where 1=1
+        <if test="caId !=null and caId != ''">
+            and t.ca_id= #{caId}
+        </if>
 
     </update>
 
     <!-- 查询菜单目录数量 add by wuxw 2018-07-03 -->
-     <select id="queryMenuCatalogsCount" parameterType="Map" resultType="Map">
-        select  count(1) count 
-from m_menu_catalog t 
-where 1 =1 
-<if test="storeType !=null and storeType != ''">
-   and t.store_type= #{storeType}
-</if> 
-<if test="caId !=null and caId != ''">
-   and t.ca_id= #{caId}
-</if> 
-<if test="name !=null and name != ''">
-   and t.name= #{name}
-</if> 
-<if test="icon !=null and icon != ''">
-   and t.icon= #{icon}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="seq !=null and seq != ''">
-   and t.seq= #{seq}
-</if> 
-<if test="url !=null and url != ''">
-   and t.url= #{url}
-</if> 
-<if test="isShow !=null and isShow != ''">
-   and t.is_show= #{isShow}
-</if> 
+    <select id="queryMenuCatalogsCount" parameterType="Map" resultType="Map">
+        select count(1) count
+        from m_menu_catalog t
+        where 1 =1
+        <if test="storeType !=null and storeType != ''">
+            and t.store_type= #{storeType}
+        </if>
+        <if test="caId !=null and caId != ''">
+            and t.ca_id= #{caId}
+        </if>
+        <if test="name !=null and name != ''">
+            and t.name= #{name}
+        </if>
+        <if test="icon !=null and icon != ''">
+            and t.icon= #{icon}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="seq !=null and seq != ''">
+            and t.seq= #{seq}
+        </if>
+        <if test="url !=null and url != ''">
+            and t.url= #{url}
+        </if>
+        <if test="isShow !=null and isShow != ''">
+            and t.is_show= #{isShow}
+        </if>
 
 
-     </select>
+    </select>
 
 </mapper>

+ 65 - 68
java110-db/src/main/resources/mapper/user/MenuGroupCatalogV1ServiceDaoImplMapper.xml

@@ -5,93 +5,90 @@
 <mapper namespace="menuGroupCatalogV1ServiceDaoImpl">
 
 
-
-
-
     <!-- 保存菜单目录组信息 add by wuxw 2018-07-03 -->
     <insert id="saveMenuGroupCatalogInfo" parameterType="Map">
         insert into m_menu_group_catalog(
-store_type,g_id,gc_id,ca_id
-) values (
-#{storeType},#{gId},#{gcId},#{caId}
-)
+        store_type,g_id,gc_id,ca_id
+        ) values (
+        #{storeType},#{gId},#{gcId},#{caId}
+        )
     </insert>
 
 
-
     <!-- 查询菜单目录组信息 add by wuxw 2018-07-03 -->
     <select id="getMenuGroupCatalogInfo" parameterType="Map" resultType="Map">
-        select  t.store_type,t.store_type storeType,t.g_id,t.g_id gId,t.gc_id,t.gc_id gcId,t.ca_id,t.ca_id caId,t.status_cd,t.status_cd statusCd 
-from m_menu_group_catalog t 
-where 1 =1 
-<if test="storeType !=null and storeType != ''">
-   and t.store_type= #{storeType}
-</if> 
-<if test="gId !=null and gId != ''">
-   and t.g_id= #{gId}
-</if> 
-<if test="gcId !=null and gcId != ''">
-   and t.gc_id= #{gcId}
-</if> 
-<if test="caId !=null and caId != ''">
-   and t.ca_id= #{caId}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-order by t.create_time desc
-<if test="page != -1 and page != null ">
-   limit #{page}, #{row}
-</if> 
+        select t.store_type,t.store_type storeType,t.g_id,t.g_id gId,t.gc_id,t.gc_id gcId,t.ca_id,t.ca_id
+        caId,t.status_cd,t.status_cd statusCd,mg.`name` mgName
+        from m_menu_group_catalog t
+        left join m_menu_group mg on t.g_id = mg.g_id and t.store_type = mg.store_type and mg.status_cd = '0'
+        where 1 =1
+        <if test="storeType !=null and storeType != ''">
+            and t.store_type= #{storeType}
+        </if>
+        <if test="gId !=null and gId != ''">
+            and t.g_id= #{gId}
+        </if>
+        <if test="gcId !=null and gcId != ''">
+            and t.gc_id= #{gcId}
+        </if>
+        <if test="caId !=null and caId != ''">
+            and t.ca_id= #{caId}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        order by t.create_time desc
+        <if test="page != -1 and page != null ">
+            limit #{page}, #{row}
+        </if>
 
     </select>
 
 
-
-
     <!-- 修改菜单目录组信息 add by wuxw 2018-07-03 -->
     <update id="updateMenuGroupCatalogInfo" parameterType="Map">
-        update  m_menu_group_catalog t set t.status_cd = #{statusCd}
-<if test="newBId != null and newBId != ''">
-,t.b_id = #{newBId}
-</if> 
-<if test="storeType !=null and storeType != ''">
-, t.store_type= #{storeType}
-</if> 
-<if test="gId !=null and gId != ''">
-, t.g_id= #{gId}
-</if> 
-<if test="caId !=null and caId != ''">
-, t.ca_id= #{caId}
-</if> 
- where 1=1 <if test="gcId !=null and gcId != ''">
-and t.gc_id= #{gcId}
-</if> 
+        update m_menu_group_catalog t set t.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,t.b_id = #{newBId}
+        </if>
+        <if test="storeType !=null and storeType != ''">
+            , t.store_type= #{storeType}
+        </if>
+        <if test="gId !=null and gId != ''">
+            , t.g_id= #{gId}
+        </if>
+        <if test="caId !=null and caId != ''">
+            , t.ca_id= #{caId}
+        </if>
+        where 1=1
+        <if test="gcId !=null and gcId != ''">
+            and t.gc_id= #{gcId}
+        </if>
 
     </update>
 
     <!-- 查询菜单目录组数量 add by wuxw 2018-07-03 -->
-     <select id="queryMenuGroupCatalogsCount" parameterType="Map" resultType="Map">
-        select  count(1) count 
-from m_menu_group_catalog t 
-where 1 =1 
-<if test="storeType !=null and storeType != ''">
-   and t.store_type= #{storeType}
-</if> 
-<if test="gId !=null and gId != ''">
-   and t.g_id= #{gId}
-</if> 
-<if test="gcId !=null and gcId != ''">
-   and t.gc_id= #{gcId}
-</if> 
-<if test="caId !=null and caId != ''">
-   and t.ca_id= #{caId}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
+    <select id="queryMenuGroupCatalogsCount" parameterType="Map" resultType="Map">
+        select count(1) count
+        from m_menu_group_catalog t
+        where 1 =1
+        <if test="storeType !=null and storeType != ''">
+            and t.store_type= #{storeType}
+        </if>
+        <if test="gId !=null and gId != ''">
+            and t.g_id= #{gId}
+        </if>
+        <if test="gcId !=null and gcId != ''">
+            and t.gc_id= #{gcId}
+        </if>
+        <if test="caId !=null and caId != ''">
+            and t.ca_id= #{caId}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
 
 
-     </select>
+    </select>
 
 </mapper>

+ 10 - 11
java110-generator/src/main/java/com/java110/code/TableToJsonWeb.java

@@ -7,21 +7,20 @@ import com.java110.utils.util.StringUtil;
 public class TableToJsonWeb {
 
     //show create table c_orders  用这个语句获取
-    public static final String createTableSql = "CREATE TABLE business_images(\n" +
-            "    `id` varchar(64) PRIMARY KEY  NOT NULL comment '编号',\n" +
-            "    `name` varchar(64) NOT NULL comment '镜像名称',\n" +
-            "     images_type varchar(12) not null comment '镜像类型',\n" +
-            "     type_url varchar(512) not null comment '镜像url',\n" +
-            "     images_flag varchar(12) not null comment '镜像标识'\n" +
+    public static final String createTableSql = "CREATE TABLE `m_menu_group_catalog` (\n" +
+            "  `gc_id` varchar(30) NOT NULL COMMENT '目录名称',\n" +
+            "  `ca_id` varchar(30) NOT NULL COMMENT '目录ID',\n" +
+            "  `g_id` varchar(30) NOT NULL COMMENT '菜单组ID',\n" +
+            "  `store_type` varchar(12) DEFAULT NULL COMMENT '商户类型'\n" +
             ")";
     public static void main(String[] args) {
-        String templateName = "镜像"; //业务名称
-        String templateCode = "businessImages"; //表名大写
-        String templateKey = "id"; //表主键
+        String templateName = "目录组"; //业务名称
+        String templateCode = "menuGroupCatalog"; //表名大写
+        String templateKey = "gcId"; //表主键
         String templateKeyName = "编号";//主键说明
-        String searchCode = "id"; //分片字段
+        String searchCode = "gcId"; //分片字段
         String searchName = "编号"; //分片字段说明
-        String directories = "admin"; //前端生成到那个目录下
+        String directories = "dev"; //前端生成到那个目录下
         // templateName 业务名称 业务编码名称生成后文件名 templateCode 主键 templateKey
         // 业务主键名称 templateKeyName=templateName+ID 主机驼峰 searchCode 主键名称 searchName
         // directories 放在前端那个目录下

+ 15 - 63
java110-generator/src/main/resources/web/template_1.json

@@ -1,85 +1,37 @@
 {
   "templateKeyName": "编号",
-  "templateName": "镜像",
+  "templateName": "目录组",
   "columns": [
     {
       "hasDefaultValue": false,
-      "limitParam": "64",
-      "code": "name",
-      "limitErrInfo": "镜像名称不能超过64",
-      "cnCode": "镜像名称",
+      "limitParam": "30",
+      "code": "gId",
+      "limitErrInfo": "菜单组ID不能超过30",
+      "cnCode": "菜单组ID",
       "limit": "maxLength",
       "show": true,
       "inputType": "input",
       "required": true,
-      "desc": "必填,name"
-    },
-    {
-      "hasDefaultValue": false,
-      "limitParam": "12",
-      "code": "imagesType",
-      "limitErrInfo": "镜像类型不能超过12",
-      "cnCode": "镜像类型",
-      "limit": "maxLength",
-      "show": true,
-      "inputType": "input",
-      "required": true,
-      "desc": "必填,imagesType"
-    },
-    {
-      "hasDefaultValue": false,
-      "limitParam": "512",
-      "code": "typeUrl",
-      "limitErrInfo": "类型地址不能超过512",
-      "cnCode": "类型地址",
-      "limit": "maxLength",
-      "show": true,
-      "inputType": "input",
-      "required": true,
-      "desc": "必填,typeUrl"
-    },
-    {
-      "hasDefaultValue": false,
-      "limitParam": "12",
-      "code": "imagesFlag",
-      "limitErrInfo": "镜像标识不能超过12",
-      "cnCode": "镜像标识",
-      "limit": "maxLength",
-      "show": true,
-      "inputType": "input",
-      "required": true,
-      "desc": "必填,imagesFlag"
+      "desc": "必填,菜单组ID"
     }
   ],
   "searchName": "编号",
-  "directories": "admin",
-  "searchCode": "id",
-  "templateCode": "businessImages",
+  "directories": "dev",
+  "searchCode": "gcId",
+  "templateCode": "menuGroupCatalog",
   "conditions": [
     {
       "whereCondition": "equal",
-      "code": "id",
-      "name": "id",
-      "inputType": "input"
-    },
-    {
-      "whereCondition": "equal",
-      "code": "name",
-      "name": "name",
-      "inputType": "input"
-    },
-    {
-      "whereCondition": "equal",
-      "code": "imagesType",
-      "name": "imagesType",
+      "code": "caId",
+      "name": "目录ID",
       "inputType": "input"
     },
     {
       "whereCondition": "equal",
-      "code": "imagesFlag",
-      "name": "imagesFlag",
+      "code": "gId",
+      "name": "菜单组编号",
       "inputType": "input"
     }
   ],
-  "templateKey": "id"
-}
+  "templateKey": "gcId"
+}

+ 15 - 0
service-dev/src/main/java/com/java110/dev/cmd/menuGroupCatalog/SaveMenuGroupCatalogCmd.java

@@ -22,6 +22,8 @@ import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.AbstractServiceCmdListener;
 import com.java110.core.event.cmd.CmdEvent;
 import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.dto.menuCatalog.MenuCatalogDto;
+import com.java110.intf.user.IMenuCatalogV1InnerServiceSMO;
 import com.java110.intf.user.IMenuGroupCatalogV1InnerServiceSMO;
 import com.java110.po.menuGroupCatalog.MenuGroupCatalogPo;
 import com.java110.utils.exception.CmdException;
@@ -32,6 +34,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.util.List;
+
 /**
  * 类表述:保存
  * 服务编码:menuGroupCatalog.saveMenuGroupCatalog
@@ -52,6 +56,9 @@ public class SaveMenuGroupCatalogCmd extends AbstractServiceCmdListener {
     @Autowired
     private IMenuGroupCatalogV1InnerServiceSMO menuGroupCatalogV1InnerServiceSMOImpl;
 
+    @Autowired
+    private IMenuCatalogV1InnerServiceSMO menuCatalogV1InnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         Assert.hasKeyAndValue(reqJson, "caId", "请求报文中未包含caId");
@@ -63,8 +70,16 @@ public class SaveMenuGroupCatalogCmd extends AbstractServiceCmdListener {
     @Java110Transactional
     public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
 
+        //查询 catalog
+        MenuCatalogDto menuCatalogDto = new MenuCatalogDto();
+        menuCatalogDto.setCaId(reqJson.getString("caId"));
+        List<MenuCatalogDto> menuCatalogDtos = menuCatalogV1InnerServiceSMOImpl.queryMenuCatalogs(menuCatalogDto);
+
+        Assert.listOnlyOne(menuCatalogDtos, "菜单目录不存在");
+
         MenuGroupCatalogPo menuGroupCatalogPo = BeanConvertUtil.covertBean(reqJson, MenuGroupCatalogPo.class);
         menuGroupCatalogPo.setGcId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
+        menuGroupCatalogPo.setStoreType(menuCatalogDtos.get(0).getStoreType());
         int flag = menuGroupCatalogV1InnerServiceSMOImpl.saveMenuGroupCatalog(menuGroupCatalogPo);
 
         if (flag < 1) {