(1)tree属性扩展,支持新增节点

(2)特定服务增加一列标记新增节点
This commit is contained in:
wangxin
2018-08-24 11:54:21 +08:00
parent 295d92fe79
commit 063fa03a94
15 changed files with 328 additions and 21 deletions

View File

@@ -31,7 +31,14 @@ public class SpecificServiceCfg extends BaseEntity<SpecificServiceCfg>{
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;
}

View File

@@ -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 默认值

View File

@@ -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";
}

View File

@@ -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<String, Object> 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<String,Object> 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<String, Object> 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;
}
}

View File

@@ -50,5 +50,6 @@ public interface SpecificServiceCfgDao extends CrudDao<SpecificServiceCfg> {
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);
}

View File

@@ -12,6 +12,7 @@
<result column="is_leaf" property="isLeaf" jdbcType="INTEGER" />
<result column="group_id" property="groupId" jdbcType="INTEGER" />
<result column="cfg_type" property="cfgType" jdbcType="INTEGER" />
<result column="add_flag" property="addFlag" jdbcType="INTEGER" />
<result column="business_type" property="businessType" jdbcType="VARCHAR" />
<!-- 父id -->
<association property="parent" javaType="com.nis.domain.specific.SpecificServiceCfg">
@@ -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
</sql>
@@ -152,6 +154,9 @@
<if test="specificServiceCfg.endDate != null" >
AND op_time &lt; #{specificServiceCfg.endDate}
</if>
<if test="specificServiceCfg.addFlag != null and specificServiceCfg.addFlag != '' ">
AND add_flag = #{specificServiceCfg.addFlag}
</if>
<choose>
<when test="orderBy != null and orderBy != '' ">
ORDER BY ${orderBy}
@@ -161,11 +166,23 @@
</otherwise>
</choose>
</select>
<select id="getMaxServiceCode" resultType="java.lang.Integer" >
SELECT MAX(spec_service_code) FROM specific_service_cfg WHERE is_valid=1 AND spec_service_code &lt; #{maxCode}
<if test="cfgType != null and cfgType != '' ">
AND cfg_type = #{cfgType}
</if>
<if test="addFlag != null and addFlag != '' ">
AND add_flag = #{addFlag}
</if>
</select>
<!-- 新增 -->
<insert id="insert" parameterType="com.nis.domain.specific.SpecificServiceCfg" useGeneratedKeys="true">
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})
<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="specServiceId">
SELECT LAST_INSERT_ID()
</selectKey>
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})
</insert>
<!-- 修改 -->

View File

@@ -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<Constants.APP_SPEC_SERVICE_CODE_MIN_VAL) {
serviceCode=Constants.APP_SPEC_SERVICE_CODE_MIN_VAL;
}
specificServiceCfg.setSpecServiceCode(serviceCode.intValue()+1);
}
specificServiceCfgDao.insert(specificServiceCfg);
}else{//修改
if(specificServiceCfg.getIsLeaf()==null){
@@ -145,5 +161,8 @@ public class SpecificServiceCfgService extends BaseService{
public SpecificServiceCfg getRepeat (Integer code,Integer cfgType,Integer parentId) {
return specificServiceCfgDao.getRepeat(code,cfgType,parentId);
}
public Integer getMaxServiceCode (Integer code, Integer cfgType,Integer addFlag) {
return specificServiceCfgDao.getMaxServiceCode(code,cfgType,addFlag);
}
}