①修复新增,修改,列表展示配置时分类性质标签展示的问题

②列表展示时采用遍历分类性质标签的方法展示,减少数据库查询时的压力
③取掉了一些不需要展示的列
④新增Maat转换的bean
⑤采用gson的方式对在bean上做注解做转换,禁止了htmlescape
This commit is contained in:
wangxin
2018-03-05 16:30:16 +08:00
parent 363544a443
commit 848087dbef
33 changed files with 797 additions and 218 deletions

View File

@@ -3,6 +3,7 @@
*/
package com.nis.web.service;
import java.util.ArrayList;
import java.util.List;
import org.apache.ibatis.session.ExecutorType;
@@ -10,8 +11,17 @@ import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.nis.domain.BaseEntity;
import com.nis.domain.Page;
import com.nis.domain.configuration.AreaIpCfg;
import com.nis.domain.configuration.BaseCfg;
import com.nis.domain.configuration.BaseIpCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.ComplexkeywordCfg;
import com.nis.domain.maat.MaatCfg;
import com.nis.domain.maat.ToMaatBean;
import com.nis.web.dao.CrudDao;
/**
@@ -174,5 +184,82 @@ public abstract class CrudService<D extends CrudDao<T>, T extends BaseEntity<T>>
}
}
}
/**
*
* sendToMaatConvertor(转换配置为Maat格式)
* (所有的配置需拥有一样的编译IDaction,serviceId,等属性)
* @param cfg
* @return
*boolean
* @exception
* @since 1.0.0
*/
public boolean sendToMaatConvertor(AreaIpCfg[] areaCfg,T ... cfg){
if(cfg==null){
throw new RuntimeException("转换出错,配置为空");
}
long compileId=0l;
ToMaatBean toMaatBean=new ToMaatBean();
MaatCfg maatCfg=new MaatCfg();
if(cfg[0] instanceof BaseIpCfg){
maatCfg.setIpCfg((BaseIpCfg[])cfg);
compileId=((BaseIpCfg)cfg[0]).getCompileId();
}else if(cfg[0] instanceof BaseStringCfg){
maatCfg.setStrCfg((BaseStringCfg[])cfg);
compileId=((BaseStringCfg)cfg[0]).getCompileId();
}else if(cfg[0] instanceof ComplexkeywordCfg){
maatCfg.setComplexStrCfg((ComplexkeywordCfg[])cfg);
compileId=((ComplexkeywordCfg)cfg[0]).getCompileId();
}
if(areaCfg!=null){
AreaIpCfg[] cfgArray=new AreaIpCfg[1];
}
List<MaatCfg> serviceCfg=new ArrayList<>();
serviceCfg.add(maatCfg);
BaseCfg baseCfg=(BaseCfg)cfg[0];
if(compileId==0l){
throw new RuntimeException("转换出错,未获取到正确的compileId");
}else{
toMaatBean.setCompileId(compileId);
}
if(baseCfg.getAction()==null){
throw new RuntimeException("转换出错,未获取到正确的action");
}else{
toMaatBean.setAction(baseCfg.getAction());
}
if(baseCfg.getIsAreaEffective()==null){
throw new RuntimeException("转换出错,未获取到正确的isAreaEffective");
}else{
toMaatBean.setIsAreaEffective(baseCfg.getIsAreaEffective());
}
if(baseCfg.getIsValid()==null){
throw new RuntimeException("转换出错,未获取到正确的isValid");
}else{
toMaatBean.setIsValid(baseCfg.getIsValid());
}
if(baseCfg.getRequestId()==null){
throw new RuntimeException("转换出错,未获取到正确的requestId");
}else{
toMaatBean.setRequestId(baseCfg.getRequestId());
}
if(baseCfg.getServiceId()==null){
throw new RuntimeException("转换出错,未获取到正确的serviceId");
}else{
toMaatBean.setServiceId(baseCfg.getServiceId());
}
toMaatBean.setAreaEffectiveIds(baseCfg.getAreaEffectiveIds()==null?"":baseCfg.getAreaEffectiveIds());
toMaatBean.setAttribute(baseCfg.getAttribute()==null?"":baseCfg.getAttribute());
toMaatBean.setClassify(baseCfg.getClassify()==null?"":baseCfg.getClassify());
toMaatBean.setLable(baseCfg.getLable()==null?"":baseCfg.getLable());
Gson gson=new GsonBuilder().disableHtmlEscaping()
.setDateFormat("yyyy-MM-dd HH:mm:ss")
/*.setPrettyPrinting().serializeNulls()*/
.excludeFieldsWithoutExposeAnnotation()
.create();
String json=gson.toJson(toMaatBean);
//发送至maat,待完成
return false;
}
}