From 063fa03a94b1a690e401fa59bbf91299a05db2d5 Mon Sep 17 00:00:00 2001 From: wangxin Date: Fri, 24 Aug 2018 11:54:21 +0800 Subject: [PATCH] =?UTF-8?q?(1)tree=E5=B1=9E=E6=80=A7=E6=89=A9=E5=B1=95?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E6=8C=81=E6=96=B0=E5=A2=9E=E8=8A=82=E7=82=B9?= =?UTF-8?q?=20(2)=E7=89=B9=E5=AE=9A=E6=9C=8D=E5=8A=A1=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=B8=80=E5=88=97=E6=A0=87=E8=AE=B0=E6=96=B0=E5=A2=9E=E8=8A=82?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/specific/SpecificServiceCfg.java | 7 + src/main/java/com/nis/util/Constants.java | 2 + .../com/nis/web/controller/TagController.java | 6 +- .../SpecificServiceCfgController.java | 83 +++++++- .../dao/specific/SpecificServiceCfgDao.java | 1 + .../dao/specific/SpecificServiceCfgDao.xml | 25 ++- .../specific/SpecificServiceCfgService.java | 19 ++ .../resources/messages/message_en.properties | 6 +- .../messages/message_zh_CN.properties | 6 +- src/main/resources/nis.properties | 5 +- src/main/resources/sql/add_spec_add_flag.sql | 1 + .../webapp/WEB-INF/tags/sys/treeselect.tag | 4 +- .../WEB-INF/views/cfg/app/appByteCfgForm.jsp | 2 +- .../WEB-INF/views/cfg/app/appIpCfgForm.jsp | 2 +- .../WEB-INF/views/sys/tagTreeselect.jsp | 180 +++++++++++++++++- 15 files changed, 328 insertions(+), 21 deletions(-) create mode 100644 src/main/resources/sql/add_spec_add_flag.sql diff --git a/src/main/java/com/nis/domain/specific/SpecificServiceCfg.java b/src/main/java/com/nis/domain/specific/SpecificServiceCfg.java index 703842e88..d930b4496 100644 --- a/src/main/java/com/nis/domain/specific/SpecificServiceCfg.java +++ b/src/main/java/com/nis/domain/specific/SpecificServiceCfg.java @@ -31,7 +31,14 @@ public class SpecificServiceCfg extends BaseEntity{ private Date endDate; // 结束日期 private String showSequence; //显示序号 private String businessType; + private Integer addFlag;//app界面添加标记 + public Integer getAddFlag() { + return addFlag; + } + public void setAddFlag(Integer addFlag) { + this.addFlag = addFlag; + } public String getBusinessType() { return businessType; } diff --git a/src/main/java/com/nis/util/Constants.java b/src/main/java/com/nis/util/Constants.java index 4c2ff5e96..e45aef8a4 100644 --- a/src/main/java/com/nis/util/Constants.java +++ b/src/main/java/com/nis/util/Constants.java @@ -7,6 +7,8 @@ import java.util.Map; import com.google.gson.GsonBuilder; public final class Constants { + public static Integer APP_SPEC_SERVICE_CODE_MIN_VAL=Configurations.getIntProperty("app_spec_service_code_min_val", 300001); + public static Integer APP_SPEC_SERVICE_CODE_MAX_VAL=Configurations.getIntProperty("app_spec_service_code_max_val", 268435455); public static String APP_CFG_USERREGION_SPLITOR=Configurations.getStringProperty("app_cfg_userregion_splitor", "&"); /** * MaatConfig 默认值 diff --git a/src/main/java/com/nis/web/controller/TagController.java b/src/main/java/com/nis/web/controller/TagController.java index ebedf03a1..049960d7c 100644 --- a/src/main/java/com/nis/web/controller/TagController.java +++ b/src/main/java/com/nis/web/controller/TagController.java @@ -7,6 +7,8 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; +import com.nis.web.security.UserUtils; + @Controller @RequestMapping("${adminPath}/tag") @@ -26,7 +28,9 @@ public class TagController extends BaseController { model.addAttribute("selectIds", request.getParameter("selectIds")); // 指定默认选中的ID model.addAttribute("isAll", request.getParameter("isAll")); // 是否读取全部数据,不进行权限过滤 model.addAttribute("module", request.getParameter("module")); // 过滤栏目模型(仅针对CMS的Category树) - model.addAttribute("title", request.getParameter("title")); + model.addAttribute("title", request.getParameter("title"));//根节点替换文本 + model.addAttribute("enableAddBtn", request.getParameter("enableAddBtn"));//节点是否可编辑 + model.addAttribute("userId", UserUtils.getUser().getId());//如果启用了addBtn,则使用userId判断是否是用户自己创建的,用户自己创建的节点可删除 return "/sys/tagTreeselect"; } diff --git a/src/main/java/com/nis/web/controller/specific/SpecificServiceCfgController.java b/src/main/java/com/nis/web/controller/specific/SpecificServiceCfgController.java index 7d1d980a3..4335b9050 100644 --- a/src/main/java/com/nis/web/controller/specific/SpecificServiceCfgController.java +++ b/src/main/java/com/nis/web/controller/specific/SpecificServiceCfgController.java @@ -1,6 +1,5 @@ package com.nis.web.controller.specific; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Properties; @@ -13,6 +12,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.mvc.support.RedirectAttributes; @@ -22,6 +22,8 @@ import com.google.common.collect.Maps; import com.nis.domain.Page; import com.nis.domain.SysDataDictionaryItem; import com.nis.domain.specific.SpecificServiceCfg; +import com.nis.exceptions.MaatConvertException; +import com.nis.util.Constants; import com.nis.util.DictUtils; import com.nis.util.StringUtils; import com.nis.web.controller.BaseController; @@ -201,8 +203,9 @@ public class SpecificServiceCfgController extends BaseController { Map map2 = Maps.newHashMap(); map2.put("id", 0); map2.put("pId", 0); - map2.put("type",0); + map2.put("serviceType",0); map2.put("business",-2); + map2.put("groupId",0); map2.put("name","root_node"); //map2.put("placeholder","0"); mapList.add(map2); @@ -222,6 +225,7 @@ public class SpecificServiceCfgController extends BaseController { map.put("name",props.getProperty(dict.getItemValue(), dict.getItemValue())); map.put("serviceType",cfgType); map.put("businessType","-1"); + map.put("groupId",0); businessList.add(map); } mapList.addAll(businessList); @@ -242,7 +246,12 @@ public class SpecificServiceCfgController extends BaseController { map.put("pId", "businessType"+business.getItemCode()); map.put("name",specificServiceCfg.getSpecServiceName()); map.put("serviceType",specificServiceCfg.getCfgType()); + map.put("serviceCode",specificServiceCfg.getSpecServiceCode()); map.put("businessType",specificServiceCfg.getBusinessType()); + map.put("groupId",specificServiceCfg.getGroupId()); + if(specificServiceCfg.getAddFlag()!=null) { + map.put("user",specificServiceCfg.getAddFlag()); + } mapList.add(map); break; } @@ -253,6 +262,7 @@ public class SpecificServiceCfgController extends BaseController { map.put("pId", specificServiceCfg.getParent().getSpecServiceId()); map.put("name",specificServiceCfg.getSpecServiceName()); map.put("serviceType",specificServiceCfg.getCfgType()); + map.put("groupId",specificServiceCfg.getGroupId()); mapList.add(map); } } @@ -272,6 +282,10 @@ public class SpecificServiceCfgController extends BaseController { map.put("pId", specificServiceCfg.getParent().getSpecServiceId()); map.put("name",specificServiceCfg.getSpecServiceName()); map.put("type",specificServiceCfg.getCfgType()); + map.put("groupId",specificServiceCfg.getGroupId()); + if(specificServiceCfg.getAddFlag()!=null) { + map.put("user",specificServiceCfg.getAddFlag()); + } mapList.add(map); } } @@ -380,5 +394,70 @@ public class SpecificServiceCfgController extends BaseController { } return false; } + @ResponseBody + @RequestMapping(value = "ajaxSaveOrUpdateApp",method=RequestMethod.POST ) + public Map ajaxSaveOrUpdateApp(@RequestParam(required=true,value="specServiceId")String specServiceId,@RequestParam(required=false,value="specServiceCode")String specServiceCode,@RequestParam(required=true,value="specServiceName") String specServiceName, + @RequestParam(required=true,value="cfgType") String cfgType, @RequestParam(required=true,value="businessType")String businessType,@RequestParam(required=false,value="addFlag")String addFlag, + @RequestParam(required=false,value="groupId")String groupId){ + Map map = Maps.newHashMap(); + //校验是真ID还是假ID,假的Id以manual开头无法转换成数字 + boolean isTrueId=false; + try { + Long.parseLong(specServiceId); + isTrueId=true; + }catch (Exception e) { + // TODO: handle exception + } + try{ + SpecificServiceCfg cfg=new SpecificServiceCfg(); + if(isTrueId) { + cfg.setSpecServiceId(Integer.parseInt(specServiceId)); + } + if(StringUtils.isNotBlank(specServiceCode)) { + cfg.setSpecServiceCode(Integer.parseInt(specServiceCode)); + } + cfg.setAddFlag(Integer.parseInt(addFlag)); + cfg.setSpecServiceName(specServiceName); + cfg.setBusinessType(businessType); + cfg.setCfgType(Integer.parseInt(cfgType)); + cfg.setIsValid(Constants.VALID_YES); + if(StringUtils.isNotBlank(groupId)) { + cfg.setGroupId(Integer.parseInt(groupId)); + } + + SpecificServiceCfg parent=new SpecificServiceCfg(); + parent.setSpecServiceId(0); + cfg.setParent(parent); + specificServiceCfgService.saveOrUpdate(cfg); + cfg=specificServiceCfgService.getBySpecServiceId(cfg.getSpecServiceId()); + map.put("id", cfg.getSpecServiceId()); + map.put("pId", "businessType"+cfg.getBusinessType()); + map.put("name",cfg.getSpecServiceName()); + map.put("serviceType",cfg.getCfgType()); + map.put("businessType",cfg.getBusinessType()); + map.put("groupId",cfg.getGroupId()); + return map; + }catch (Exception e) { + e.printStackTrace(); + if(e instanceof MaatConvertException) { + map.put("errTip", "request_service_failed"); + }else { + map.put("errTip", "save_failed"); + } + } + + return map; + } + @ResponseBody + @RequestMapping(value = "ajaxRemoveApp",method=RequestMethod.POST ) + public boolean ajaxRemoveApp(@RequestParam(required=true,value="specServiceId")Integer specServiceId){ + try{ + specificServiceCfgService.delete(String.valueOf(specServiceId)); + return true; + }catch (Exception e) { + e.printStackTrace(); + } + return false; + } } diff --git a/src/main/java/com/nis/web/dao/specific/SpecificServiceCfgDao.java b/src/main/java/com/nis/web/dao/specific/SpecificServiceCfgDao.java index 2360e1d46..44d828b53 100644 --- a/src/main/java/com/nis/web/dao/specific/SpecificServiceCfgDao.java +++ b/src/main/java/com/nis/web/dao/specific/SpecificServiceCfgDao.java @@ -50,5 +50,6 @@ public interface SpecificServiceCfgDao extends CrudDao { Integer getParentType(Integer specServiceId); Integer getParentCode(Integer specServiceId); SpecificServiceCfg getRepeat(@Param("specServiceCode")Integer code, @Param("cfgType")Integer cfgType,@Param("parentId")Integer parentId); + Integer getMaxServiceCode(@Param("maxCode")Integer code, @Param("cfgType")Integer cfgType,@Param("addFlag")Integer addFlag); } \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/specific/SpecificServiceCfgDao.xml b/src/main/java/com/nis/web/dao/specific/SpecificServiceCfgDao.xml index f24e7ac07..782502ca3 100644 --- a/src/main/java/com/nis/web/dao/specific/SpecificServiceCfgDao.xml +++ b/src/main/java/com/nis/web/dao/specific/SpecificServiceCfgDao.xml @@ -12,6 +12,7 @@ + @@ -30,7 +31,8 @@ s.is_leaf AS isLeaf, s.group_id AS groupId, s.cfg_type AS cfgType, - s.business_type AS businessType + s.business_type AS businessType, + s.add_flag AS addFlag @@ -152,6 +154,9 @@ AND op_time < #{specificServiceCfg.endDate} + + AND add_flag = #{specificServiceCfg.addFlag} + ORDER BY ${orderBy} @@ -161,11 +166,23 @@ - + - insert into specific_service_cfg (spec_service_code,spec_service_name,spec_service_desc,is_valid, op_time, parent_id,is_leaf,group_id,cfg_type,business_type) - values(#{specServiceCode},#{specServiceName},#{specServiceDesc},#{isValid},#{opTime},#{parent.specServiceId},#{isLeaf},#{groupId},#{cfgType},#{businessType}) + + SELECT LAST_INSERT_ID() + + insert into specific_service_cfg (spec_service_code,spec_service_name,spec_service_desc,is_valid, op_time, parent_id,is_leaf,group_id,cfg_type,business_type,add_flag) + values(#{specServiceCode},#{specServiceName},#{specServiceDesc},#{isValid},#{opTime},#{parent.specServiceId},#{isLeaf},#{groupId},#{cfgType}, + #{businessType},#{addFlag}) diff --git a/src/main/java/com/nis/web/service/specific/SpecificServiceCfgService.java b/src/main/java/com/nis/web/service/specific/SpecificServiceCfgService.java index 7d2815985..b66c34826 100644 --- a/src/main/java/com/nis/web/service/specific/SpecificServiceCfgService.java +++ b/src/main/java/com/nis/web/service/specific/SpecificServiceCfgService.java @@ -12,6 +12,7 @@ import com.nis.domain.Page; import com.nis.domain.specific.ConfigGroupInfo; import com.nis.domain.specific.SpecificServiceCfg; import com.nis.util.ConfigServiceUtil; +import com.nis.util.Constants; import com.nis.web.dao.specific.SpecificServiceCfgDao; import com.nis.web.service.BaseService; @@ -89,6 +90,21 @@ public class SpecificServiceCfgService extends BaseService{ specificServiceCfg.setIsValid(1); specificServiceCfg.setOpTime(new Date()); + //用户添加的需要自增 + if(specificServiceCfg.getAddFlag()!=null) { + Integer serviceCode=specificServiceCfgDao.getMaxServiceCode(Constants.APP_SPEC_SERVICE_CODE_MAX_VAL,specificServiceCfg.getCfgType(),specificServiceCfg.getAddFlag()); + if(serviceCode==null) {//用户没有添加标签,获取最大的 + serviceCode=specificServiceCfgDao.getMaxServiceCode(Constants.APP_SPEC_SERVICE_CODE_MAX_VAL,specificServiceCfg.getCfgType(),null); + } + if(serviceCode==null) {//没有标签,取开始值 + serviceCode=Constants.APP_SPEC_SERVICE_CODE_MIN_VAL; + }else if(serviceCode>Constants.APP_SPEC_SERVICE_CODE_MAX_VAL){ + throw new RuntimeException("Get specific service code failed,specific service code is beyond the scope of application"); + }else if(serviceCode <%@ attribute name="checkedPS" type="java.lang.String" required="false" description="复选框选中时是否关联父子节点,ps关联父子,p关联父,s关联子,都不关联为空"%> <%@ attribute name="unCheckedPS" type="java.lang.String" required="false" description="复选框取消选中时是否关联父子节点,ps关联父子,p关联父,s关联子,都不关联为空"%> +<%@ attribute name="enableAddBtn" type="java.lang.Boolean" required="false" description="节点是否可编辑"%>
" data-msg-required="${dataMsgRequired}" placeholder="${empty value?labelValue:value}" @@ -45,7 +46,7 @@ return true; } // 正常打开 - top.$.jBox.open("iframe:${ctx}/tag/treeselect?url="+encodeURIComponent("${url}")+"&selectIds="+$("#${id}Id").val()+"&module=${module}&checked=${checked}&extId=${extId}&isAll=${isAll}&title=${title}", " ", 320, 420, { + top.$.jBox.open("iframe:${ctx}/tag/treeselect?url="+encodeURIComponent("${url}")+"&selectIds="+$("#${id}Id").val()+"&module=${module}&checked=${checked}&extId=${extId}&isAll=${isAll}&title=${title}&enableAddBtn=${enableAddBtn}", " ", 320, 420, { ajaxData:{selectIds: $("#${id}Id").val()},buttons:{"":"ok", "":"clear","":true}, submit:function(v, h, f){ if (v == "ok"){ var tree = h.find("iframe")[0].contentWindow.tree;//h.find("iframe").contents(); @@ -57,6 +58,7 @@ } //wx提示,c:if标签前加了//注释,c:if标签的判断条件仍会生效 for(var i=0; i if (nodes[i].isParent && "${checkedPS}"!=''){ continue; // 如果为复选框选择,并且父子节点有关联,则过滤掉父节点 diff --git a/src/main/webapp/WEB-INF/views/cfg/app/appByteCfgForm.jsp b/src/main/webapp/WEB-INF/views/cfg/app/appByteCfgForm.jsp index e2d27aa66..c821be4ff 100644 --- a/src/main/webapp/WEB-INF/views/cfg/app/appByteCfgForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/app/appByteCfgForm.jsp @@ -82,7 +82,7 @@ $(function(){
diff --git a/src/main/webapp/WEB-INF/views/cfg/app/appIpCfgForm.jsp b/src/main/webapp/WEB-INF/views/cfg/app/appIpCfgForm.jsp index c3b62f4f6..a57657c74 100644 --- a/src/main/webapp/WEB-INF/views/cfg/app/appIpCfgForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/app/appIpCfgForm.jsp @@ -78,7 +78,7 @@ $(function(){
diff --git a/src/main/webapp/WEB-INF/views/sys/tagTreeselect.jsp b/src/main/webapp/WEB-INF/views/sys/tagTreeselect.jsp index 079944d8a..7abd40592 100644 --- a/src/main/webapp/WEB-INF/views/sys/tagTreeselect.jsp +++ b/src/main/webapp/WEB-INF/views/sys/tagTreeselect.jsp @@ -6,12 +6,33 @@ 数据选择 + <%--解决ztree add小图标丢失 --%> +