完善社交应用审核通过、取消审核通过界面端功能逻辑。

This commit is contained in:
zhangwei
2018-04-03 11:12:49 +08:00
parent 33b7df09c9
commit 83a60871c0
15 changed files with 773 additions and 68 deletions

View File

@@ -1,25 +1,40 @@
package com.nis.web.service.configuration;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.nis.domain.Page;
import com.nis.domain.ServiceConfigInfo;
import com.nis.domain.configuration.AppComplexKeywordCfg;
import com.nis.domain.configuration.AppIdCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.AppStringCfg;
import com.nis.domain.configuration.AreaIpCfg;
import com.nis.domain.configuration.BaseIpCfg;
import com.nis.domain.configuration.AppIdCfg.AppFeaturesIndex;
import com.nis.domain.configuration.ComplexkeywordCfg;
import com.nis.domain.maat.AppMaatCfg;
import com.nis.domain.specific.ConfigGroupInfo;
import com.nis.domain.specific.SpecificServiceCfg;
import com.nis.domain.specific.SpecificServiceHostCfg;
import com.nis.main.ConvertTool;
import com.nis.util.Constants;
import com.nis.util.StringUtil;
import com.nis.web.dao.configuration.AppCfgDao;
import com.nis.web.dao.configuration.ComplexStringCfgDao;
import com.nis.web.dao.configuration.IpCfgDao;
import com.nis.web.dao.configuration.StringCfgDao;
import com.nis.web.dao.specific.SpecificServiceCfgDao;
import com.nis.web.dao.specific.SpecificServiceHostCfgDao;
import com.nis.web.dao.systemService.ServiceConfigInfoDao;
import com.nis.web.service.CrudService;
@@ -39,6 +54,12 @@ public class AppCfgService extends CrudService<AppCfgDao,AppIdCfg> {
protected StringCfgDao stringCfgDao;
@Autowired
protected ComplexStringCfgDao complexStringCfgDao;
@Autowired
private SpecificServiceCfgDao specificServiceCfgDao;
@Autowired
private SpecificServiceHostCfgDao specificServiceHostCfgDao;
@Autowired
protected IpCfgDao ipCfgDao;
public Page<AppIdCfg> findPage(Page<AppIdCfg> page, AppIdCfg entity) {
entity.setPage(page);
@@ -49,18 +70,18 @@ public class AppCfgService extends CrudService<AppCfgDao,AppIdCfg> {
public AppIdCfg findAppIdCfg(AppIdCfg entity) {
//查询协议关联特征表
List<AppFeaturesIndex> featuresTableList = appCfgDao.getFeaturesTableListByAppCompileId(entity.getCompileId());
List<ComplexkeywordCfg> complexList = new ArrayList();
List<BaseStringCfg> strList = new ArrayList();
List<AppComplexKeywordCfg> complexList = new ArrayList();
List<AppStringCfg> strList = new ArrayList();
if(!StringUtil.isEmpty(featuresTableList)){
for(AppFeaturesIndex features:featuresTableList){
if(features.getFeaturesTableType().equals(4)){//增强字符串特征配置
List<ComplexkeywordCfg> complexFeaturesList = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId(
List<AppComplexKeywordCfg> complexFeaturesList = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId(
features.getFeaturesTable(),features.getFeaturesCompileId());
complexList.addAll(complexFeaturesList);
}else if(features.getFeaturesTableType().equals(2)){//普通字符串特征配置
List<BaseStringCfg> strFeaturesCfgList = appCfgDao.getStrFeaturesCfgListByCompileId(
List<AppStringCfg> strFeaturesCfgList = appCfgDao.getStrFeaturesCfgListByCompileId(
features.getFeaturesTable(),features.getFeaturesCompileId());
strList.addAll(strFeaturesCfgList);
}
@@ -90,7 +111,7 @@ public class AppCfgService extends CrudService<AppCfgDao,AppIdCfg> {
cfg.setCompileId(appCompileId);
cfgId = appCfgDao.insert(cfg);
if(cfg.getComplexFeaturesList()!=null){
for(ComplexkeywordCfg c:cfg.getComplexFeaturesList()){
for(AppComplexKeywordCfg c:cfg.getComplexFeaturesList()){
Integer featuresCompileId = new ConvertTool().getCompileId();
AppFeaturesIndex f = new AppFeaturesIndex();
f.setAppCompileId(cfg.getCompileId());
@@ -119,7 +140,7 @@ public class AppCfgService extends CrudService<AppCfgDao,AppIdCfg> {
}
}
if(cfg.getStrFeaturesCfgList()!=null){
for(BaseStringCfg s:cfg.getStrFeaturesCfgList()){
for(AppStringCfg s:cfg.getStrFeaturesCfgList()){
Integer featuresCompileId = new ConvertTool().getCompileId();
AppFeaturesIndex f = new AppFeaturesIndex();
f.setAppCompileId(cfg.getCompileId());
@@ -162,7 +183,7 @@ public class AppCfgService extends CrudService<AppCfgDao,AppIdCfg> {
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public int updateAppCfg(AppIdCfg cfg) throws Exception{
if(cfg.getComplexFeaturesList()!=null){
for(ComplexkeywordCfg c:cfg.getComplexFeaturesList()){
for(AppComplexKeywordCfg c:cfg.getComplexFeaturesList()){
Integer featuresCompileId = 0;
c.setIsAreaEffective(cfg.getIsAreaEffective());
c.setAreaEffectiveIds(cfg.getAreaEffectiveIds());
@@ -191,14 +212,14 @@ public class AppCfgService extends CrudService<AppCfgDao,AppIdCfg> {
c.setIsValid(cfg.getIsValid());
complexStringCfgDao.insert(c);
}else{
complexStringCfgDao.update(c);
complexStringCfgDao.updateByPrimaryKeySelective(c);
}
}
}
if(cfg.getStrFeaturesCfgList()!=null){
for(BaseStringCfg s:cfg.getStrFeaturesCfgList()){
for(AppStringCfg s:cfg.getStrFeaturesCfgList()){
Integer featuresCompileId = 0;
s.setIsAreaEffective(cfg.getIsAreaEffective());
s.setAreaEffectiveIds(cfg.getAreaEffectiveIds());
@@ -227,7 +248,7 @@ public class AppCfgService extends CrudService<AppCfgDao,AppIdCfg> {
s.setIsValid(cfg.getIsValid());
stringCfgDao.insert(s);
}else{
stringCfgDao.update(s);
stringCfgDao.updateByPrimaryKeySelective(s);
}
}
@@ -241,12 +262,221 @@ public class AppCfgService extends CrudService<AppCfgDao,AppIdCfg> {
* @param cfg
* @return
*int
* @throws Exception
* @exception
* @since 1.0.0
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public int auditAppCfg(AppIdCfg cfg){
return appCfgDao.audit(cfg);
public int auditAppCfg(AppIdCfg entity) throws Exception{
boolean sendFlag = false;
AppIdCfg appCfg = appCfgDao.getById(entity.getCfgId());
List<AppFeaturesIndex> featuresTableList = appCfgDao.getFeaturesTableListByAppCompileId(appCfg.getCompileId());
List<AppStringCfg> strList = new ArrayList();
List<AppComplexKeywordCfg> complexList = new ArrayList();
List<SpecificServiceHostCfg> hostList =new ArrayList();
List<BaseIpCfg> areaList = new ArrayList();
ConfigGroupInfo group = new ConfigGroupInfo();
Gson gson=new GsonBuilder().disableHtmlEscaping()
.excludeFieldsWithoutExposeAnnotation()
.create();
//配置审核状态即将改变后的状态
if(Constants.AUDIT_NOT_YES==entity.getIsAudit().intValue()||
Constants.AUDIT_YES==entity.getIsAudit().intValue()){//审核通过,取消审核通过需要发到maat
if(Constants.AUDIT_YES==entity.getIsAudit().intValue()){//审核通过
if(StringUtil.isEmpty(featuresTableList)){
SpecificServiceCfg protocol = specificServiceCfgDao.getBySpecServiceId(appCfg.getAppId().intValue());
SpecificServiceHostCfg hostCfg = new SpecificServiceHostCfg();
hostCfg.setSpecServiceId(protocol.getSpecServiceId());
hostList = specificServiceHostCfgDao.findSpecHostList(hostCfg);
//featuresTableList为空的时候该service只有特定服务IP一个配置表
ServiceConfigInfo serviceCfg=serviceConfigInfoDao.findSysServiceConfigInfo(appCfg.getServiceId());
for(SpecificServiceHostCfg host:hostList){
SpecificServiceCfg specServiceCfg = specificServiceCfgDao.getBySpecServiceId(host.getSpecServiceId());
host.setProtocolId(0);
host.setGroupId(specServiceCfg.getGroupId());
if(StringUtil.isEmpty(serviceCfg)){
host.setMaatTable("DF_PROTOCOL_APP");
}else{
host.setMaatTable(serviceCfg.getMaatTable());
}
group.setGroupId(specServiceCfg.getGroupId());
group.setIsIssued(1);
}
//生效区域列表信息
if(appCfg.getIsAreaEffective()==1){
if(StringUtil.isEmpty(appCfg.getAreaEffectiveIds())){
BaseIpCfg ipCfg = new BaseIpCfg();
ipCfg.setCompileId(appCfg.getCompileId());
ipCfg.setTableName("area_ip_cfg");
areaList = ipCfgDao.findList(ipCfg);
}
}
}else{
for(AppFeaturesIndex featuresCfg:featuresTableList){
if(featuresCfg.getFeaturesTableType()==2){
List<AppStringCfg> list =appCfgDao.getStrFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId());
for(AppStringCfg cfg:list){
List<ServiceConfigInfo> cList = serviceConfigInfoDao.findList(appCfg.getServiceId());
if(!StringUtil.isEmpty(cList)){
for(ServiceConfigInfo c:cList){
if(c.getTableName().equals(featuresCfg.getFeaturesTable())){
cfg.setMaatTable(c.getMaatTable());
}
}
}
cfg.setCompileId(featuresCfg.getFeaturesCompileId());
strList.add(cfg);
}
}
if(featuresCfg.getFeaturesTableType()==4){
List<AppComplexKeywordCfg> list = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId());
for(AppComplexKeywordCfg cfg:list){
List<ServiceConfigInfo> cList = serviceConfigInfoDao.findList(appCfg.getServiceId());
if(!StringUtil.isEmpty(cList)){
for(ServiceConfigInfo c:cList){
if(c.getTableName().equals(featuresCfg.getFeaturesTable())){
cfg.setMaatTable(c.getMaatTable());
}
}
}
cfg.setCompileId(featuresCfg.getFeaturesCompileId());
complexList.add(cfg);
}
}
}
}
AppMaatCfg maatCfg = new AppMaatCfg();
if(StringUtil.isEmpty(featuresTableList)){
maatCfg.setIpCfg(hostList);
maatCfg.setAreaCfg(areaList);
if(appCfg.getCompileId()==0){
throw new RuntimeException("转换出错,未获取到正确的compileId");
}else{
maatCfg.setCompileId(appCfg.getCompileId());
}
}else{//特征配置
maatCfg.setStrCfg(strList);
maatCfg.setComplexStrCfg(complexList);
}
if(appCfg.getAction()==null){
throw new RuntimeException("转换出错,未获取到正确的action");
}else{
maatCfg.setAction(appCfg.getAction());
}
if(appCfg.getIsAreaEffective()==null){
throw new RuntimeException("转换出错,未获取到正确的isAreaEffective");
}else{
maatCfg.setIsAreaEffective(appCfg.getIsAreaEffective());
}
if(appCfg.getIsValid()==null){
throw new RuntimeException("转换出错,未获取到正确的isValid");
}else{
maatCfg.setIsValid(appCfg.getIsValid());
}
if(appCfg.getRequestId()==null){
throw new RuntimeException("转换出错,未获取到正确的requestId");
}else{
maatCfg.setRequestId(appCfg.getRequestId());
}
if(appCfg.getServiceId()==null){
throw new RuntimeException("转换出错,未获取到正确的serviceId");
}else{
maatCfg.setServiceId(appCfg.getServiceId());
}
maatCfg.setSpecificServiceId(appCfg.getAppId());
maatCfg.setAreaEffectiveIds(appCfg.getAreaEffectiveIds()==null?"":appCfg.getAreaEffectiveIds());
maatCfg.setAttribute(appCfg.getAttribute()==null?"":appCfg.getAttribute());
maatCfg.setClassify(appCfg.getClassify()==null?"":appCfg.getClassify());
maatCfg.setLable(appCfg.getLable()==null?"":appCfg.getLable());
String json=gson.toJson(maatCfg);
//下发maat
// new ConvertTool().saveAppConfig(json);
sendFlag = true;
}else{//取消审核通过
AppMaatCfg maatCfg = new AppMaatCfg();
if(StringUtil.isEmpty(featuresTableList)){
ServiceConfigInfo serviceCfg=serviceConfigInfoDao.findSysServiceConfigInfo(appCfg.getServiceId());
maatCfg.setMaatTable(serviceCfg.getMaatTable());
if(appCfg.getCompileId()==0){
throw new RuntimeException("转换出错,未获取到正确的compileId");
}else{
maatCfg.setCompileId(appCfg.getCompileId());
}
}else{//特征配置
for(AppFeaturesIndex featuresCfg:featuresTableList){
if(featuresCfg.getFeaturesTableType()==2){
List<AppStringCfg> list =appCfgDao.getStrFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId());
for(AppStringCfg cfg:list){
AppStringCfg strCfg = new AppStringCfg();
List<ServiceConfigInfo> cList = serviceConfigInfoDao.findList(appCfg.getServiceId());
if(!StringUtil.isEmpty(cList)){
for(ServiceConfigInfo c:cList){
if(c.getTableName().equals(featuresCfg.getFeaturesTable())){
strCfg.setMaatTable(c.getMaatTable());
}
}
}
strCfg.setCompileId(featuresCfg.getFeaturesCompileId());
strList.add(strCfg);
}
}
if(featuresCfg.getFeaturesTableType()==4){
List<AppComplexKeywordCfg> list = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId());
for(AppComplexKeywordCfg cfg:list){
AppComplexKeywordCfg complexCfg = new AppComplexKeywordCfg();
List<ServiceConfigInfo> cList = serviceConfigInfoDao.findList(appCfg.getServiceId());
if(!StringUtil.isEmpty(cList)){
for(ServiceConfigInfo c:cList){
if(c.getTableName().equals(featuresCfg.getFeaturesTable())){
complexCfg.setMaatTable(c.getMaatTable());
}
}
}
complexCfg.setCompileId(featuresCfg.getFeaturesCompileId());
complexList.add(complexCfg);
}
}
}
maatCfg.setStrCfg(strList);
maatCfg.setComplexStrCfg(complexList);
}
String json=gson.toJson(maatCfg);
//下发maat
// new ConvertTool().saveAppConfig(json);
sendFlag = true;
}
}else{
sendFlag = false;
}
if(sendFlag){
//修改appId配置审核下发状态
appCfgDao.audit(entity);
//修改特定服务IP分组下发状态
specificServiceCfgDao.updateConfigGroupInfobyGroupId(group);
//修改特征表配置审核下发状态
for(AppFeaturesIndex cfg:featuresTableList){
appCfgDao.auditFeaturesTable(cfg.getFeaturesTable(), cfg.getFeaturesCompileId(), entity.getIsValid(),
entity.getIsAudit(), entity.getAuditorId(), entity.getAuditTime());
}
return 1;
}else{
return 0;
}
}
/**
*
@@ -259,8 +489,22 @@ public class AppCfgService extends CrudService<AppCfgDao,AppIdCfg> {
* @since 1.0.0
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public int deleteAppCfg(AppIdCfg cfg){
return appCfgDao.updateValid(cfg);
public int deleteAppCfg(AppIdCfg entity){
Integer status = appCfgDao.updateValid(entity);
if(status==1){
List<AppFeaturesIndex> featuresTableList = appCfgDao.getFeaturesTableListByAppCompileId(entity.getCompileId());
for(AppFeaturesIndex cfg:featuresTableList){
status = appCfgDao.updateFeaturesTableValid(cfg.getFeaturesTable(), cfg.getFeaturesCompileId(),
entity.getIsValid(), entity.getEditorId(), entity.getEditTime());
if(status==0){
return 0;
}
}
return status;
}else{
return status;
}
// return appCfgDao.updateValid(cfg);
}
/**
*
@@ -288,18 +532,18 @@ public class AppCfgService extends CrudService<AppCfgDao,AppIdCfg> {
public AppIdCfg getAppCfgById(AppIdCfg cfg){
cfg = appCfgDao.get(cfg);
List<AppFeaturesIndex> featuresTableList = appCfgDao.getFeaturesTableListByAppCompileId(cfg.getCompileId());
List<ComplexkeywordCfg> complexList = new ArrayList();
List<BaseStringCfg> strList = new ArrayList();
List<AppComplexKeywordCfg> complexList = new ArrayList();
List<AppStringCfg> strList = new ArrayList();
if(!StringUtil.isEmpty(featuresTableList)){
for(AppFeaturesIndex features:featuresTableList){
if(features.getFeaturesTableType().equals(4)){//增强字符串特征配置
List<ComplexkeywordCfg> complexFeaturesList = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId(
List<AppComplexKeywordCfg> complexFeaturesList = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId(
features.getFeaturesTable(),features.getFeaturesCompileId());
complexList.addAll(complexFeaturesList);
}else if(features.getFeaturesTableType().equals(2)){//普通字符串特征配置
List<BaseStringCfg> strFeaturesCfgList = appCfgDao.getStrFeaturesCfgListByCompileId(
List<AppStringCfg> strFeaturesCfgList = appCfgDao.getStrFeaturesCfgListByCompileId(
features.getFeaturesTable(),features.getFeaturesCompileId());
strList.addAll(strFeaturesCfgList);
}
@@ -313,13 +557,13 @@ public class AppCfgService extends CrudService<AppCfgDao,AppIdCfg> {
public Integer getIsValid(Long cfgId){
return appCfgDao.getIsValid(cfgId);
}
/*public Integer getIsValid(String tableName, long id){
public Integer getIsValid(String tableName, long id){
return appCfgDao.getIsValid(tableName,id);
}*/
}
public Integer getIsAudit(Long cfgId){
return appCfgDao.getIsAudit(cfgId);
}
/*public Integer getIsAudit(String tableName, long id){
public Integer getIsAudit(String tableName, long id){
return appCfgDao.getIsAudit(tableName,id);
}*/
}
}