社交应用配置查询、新增、修改功能
This commit is contained in:
@@ -1,6 +1,28 @@
|
||||
package com.nis.web.service.configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
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.nis.domain.Page;
|
||||
import com.nis.domain.ServiceConfigInfo;
|
||||
import com.nis.domain.configuration.AppIdCfg;
|
||||
import com.nis.domain.configuration.BaseStringCfg;
|
||||
import com.nis.domain.configuration.AppIdCfg.AppFeaturesIndex;
|
||||
import com.nis.domain.configuration.ComplexkeywordCfg;
|
||||
import com.nis.main.ConvertTool;
|
||||
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.StringCfgDao;
|
||||
import com.nis.web.dao.systemService.ServiceConfigInfoDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
|
||||
|
||||
/**
|
||||
* 特定协议相关配置事务类
|
||||
@@ -8,6 +30,296 @@ import org.springframework.stereotype.Service;
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
public class AppCfgService {
|
||||
|
||||
public class AppCfgService extends CrudService<AppCfgDao,AppIdCfg> {
|
||||
@Autowired
|
||||
protected AppCfgDao appCfgDao;
|
||||
@Autowired
|
||||
protected ServiceConfigInfoDao serviceConfigInfoDao;
|
||||
@Autowired
|
||||
protected StringCfgDao stringCfgDao;
|
||||
@Autowired
|
||||
protected ComplexStringCfgDao complexStringCfgDao;
|
||||
|
||||
public Page<AppIdCfg> findPage(Page<AppIdCfg> page, AppIdCfg entity) {
|
||||
entity.setPage(page);
|
||||
List<AppIdCfg> list = dao.findList(entity);
|
||||
page.setList(list);
|
||||
return page;
|
||||
}
|
||||
public AppIdCfg findAppIdCfg(AppIdCfg entity) {
|
||||
//查询协议关联特征表
|
||||
List<AppFeaturesIndex> featuresTableList = appCfgDao.getFeaturesTableListByAppCompileId(entity.getCompileId());
|
||||
List<ComplexkeywordCfg> complexList = new ArrayList();
|
||||
List<BaseStringCfg> strList = new ArrayList();
|
||||
if(!StringUtil.isEmpty(featuresTableList)){
|
||||
for(AppFeaturesIndex features:featuresTableList){
|
||||
if(features.getFeaturesTableType().equals(4)){//增强字符串特征配置
|
||||
List<ComplexkeywordCfg> complexFeaturesList = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId(
|
||||
features.getFeaturesTable(),features.getFeaturesCompileId());
|
||||
complexList.addAll(complexFeaturesList);
|
||||
|
||||
|
||||
}else if(features.getFeaturesTableType().equals(2)){//普通字符串特征配置
|
||||
List<BaseStringCfg> strFeaturesCfgList = appCfgDao.getStrFeaturesCfgListByCompileId(
|
||||
features.getFeaturesTable(),features.getFeaturesCompileId());
|
||||
strList.addAll(strFeaturesCfgList);
|
||||
}
|
||||
}
|
||||
}
|
||||
entity.setComplexFeaturesList(complexList);
|
||||
entity.setStrFeaturesCfgList(strList);
|
||||
return entity;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* addAppCfg(新增IP类配置)
|
||||
* (继承AppIdCfg这个类方可使用)
|
||||
* @param cfg
|
||||
* @return
|
||||
*int
|
||||
* @throws Exception
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public int addAppCfg(AppIdCfg cfg) throws Exception{
|
||||
//通过配置转换工具获取compileId
|
||||
Integer appCompileId = 0;
|
||||
int cfgId = 0;
|
||||
appCompileId = new ConvertTool().getCompileId();
|
||||
cfg.setCompileId(appCompileId);
|
||||
cfgId = appCfgDao.insert(cfg);
|
||||
if(cfg.getComplexFeaturesList()!=null){
|
||||
for(ComplexkeywordCfg c:cfg.getComplexFeaturesList()){
|
||||
Integer featuresCompileId = new ConvertTool().getCompileId();
|
||||
AppFeaturesIndex f = new AppFeaturesIndex();
|
||||
f.setAppCompileId(cfg.getCompileId());
|
||||
f.setFeaturesCompileId(featuresCompileId);
|
||||
f.setFeaturesTableType(4);
|
||||
f.setFeaturesTable(c.getTableName());
|
||||
appCfgDao.insertFeatures(f);
|
||||
|
||||
c.setTableName(c.getTableName());
|
||||
// c.initDefaultValue();
|
||||
c.setAction(cfg.getAction());
|
||||
c.setServiceId(cfg.getServiceId());
|
||||
c.setCompileId(featuresCompileId);
|
||||
c.setCreateTime(cfg.getCreateTime());
|
||||
c.setCreatorId(cfg.getCreatorId());
|
||||
c.setIsAudit(cfg.getIsAudit());
|
||||
c.setIsValid(cfg.getIsValid());
|
||||
c.setIsAreaEffective(cfg.getIsAreaEffective());
|
||||
c.setAreaEffectiveIds(cfg.getAreaEffectiveIds());
|
||||
c.setAttribute(cfg.getAttribute());
|
||||
c.setLable(cfg.getLable());
|
||||
c.setClassify(cfg.getClassify());
|
||||
c.setRequestId(cfg.getRequestId());
|
||||
c.setCfgDesc(cfg.getCfgDesc());
|
||||
complexStringCfgDao.insert(c);
|
||||
}
|
||||
}
|
||||
if(cfg.getStrFeaturesCfgList()!=null){
|
||||
for(BaseStringCfg s:cfg.getStrFeaturesCfgList()){
|
||||
Integer featuresCompileId = new ConvertTool().getCompileId();
|
||||
AppFeaturesIndex f = new AppFeaturesIndex();
|
||||
f.setAppCompileId(cfg.getCompileId());
|
||||
f.setFeaturesCompileId(featuresCompileId);
|
||||
f.setFeaturesTableType(2);
|
||||
f.setFeaturesTable(s.getTableName());
|
||||
appCfgDao.insertFeatures(f);
|
||||
s.setTableName(s.getTableName());
|
||||
// s.initDefaultValue();
|
||||
s.setAction(cfg.getAction());
|
||||
s.setServiceId(cfg.getServiceId());
|
||||
s.setCompileId(featuresCompileId);
|
||||
s.setCreateTime(cfg.getCreateTime());
|
||||
s.setCreatorId(cfg.getCreatorId());
|
||||
s.setIsAudit(cfg.getIsAudit());
|
||||
s.setIsValid(cfg.getIsValid());
|
||||
s.setIsAreaEffective(cfg.getIsAreaEffective());
|
||||
s.setAreaEffectiveIds(cfg.getAreaEffectiveIds());
|
||||
s.setAttribute(cfg.getAttribute());
|
||||
s.setLable(cfg.getLable());
|
||||
s.setClassify(cfg.getClassify());
|
||||
s.setRequestId(cfg.getRequestId());
|
||||
s.setCfgDesc(cfg.getCfgDesc());
|
||||
stringCfgDao.insert(s);
|
||||
}
|
||||
}
|
||||
return cfgId;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* updateAppCfg(更新IP类配置)
|
||||
* (继承AppIdCfg这个类方可使用)
|
||||
* @param cfg
|
||||
* @return
|
||||
*int
|
||||
* @throws Exception
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public int updateAppCfg(AppIdCfg cfg) throws Exception{
|
||||
if(cfg.getComplexFeaturesList()!=null){
|
||||
for(ComplexkeywordCfg c:cfg.getComplexFeaturesList()){
|
||||
Integer featuresCompileId = 0;
|
||||
c.setIsAreaEffective(cfg.getIsAreaEffective());
|
||||
c.setAreaEffectiveIds(cfg.getAreaEffectiveIds());
|
||||
c.setAttribute(cfg.getAttribute());
|
||||
c.setLable(cfg.getLable());
|
||||
c.setClassify(cfg.getClassify());
|
||||
c.setRequestId(cfg.getRequestId());
|
||||
c.setCfgDesc(cfg.getCfgDesc());
|
||||
c.setEditorId(cfg.getEditorId());
|
||||
c.setEditTime(cfg.getEditTime());
|
||||
if(c.getCompileId()==null){
|
||||
featuresCompileId = new ConvertTool().getCompileId();
|
||||
AppFeaturesIndex f = new AppFeaturesIndex();
|
||||
f.setAppCompileId(cfg.getCompileId());
|
||||
f.setFeaturesCompileId(featuresCompileId);
|
||||
f.setFeaturesTableType(4);
|
||||
f.setFeaturesTable(c.getTableName());
|
||||
appCfgDao.insertFeatures(f);
|
||||
c.setTableName(c.getTableName());
|
||||
c.setAction(cfg.getAction());
|
||||
c.setServiceId(cfg.getServiceId());
|
||||
c.setCompileId(featuresCompileId);
|
||||
c.setCreateTime(new Date());
|
||||
c.setCreatorId(cfg.getCurrentUser().getId());
|
||||
c.setIsAudit(cfg.getIsAudit());
|
||||
c.setIsValid(cfg.getIsValid());
|
||||
complexStringCfgDao.insert(c);
|
||||
}else{
|
||||
complexStringCfgDao.update(c);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if(cfg.getStrFeaturesCfgList()!=null){
|
||||
for(BaseStringCfg s:cfg.getStrFeaturesCfgList()){
|
||||
Integer featuresCompileId = 0;
|
||||
s.setIsAreaEffective(cfg.getIsAreaEffective());
|
||||
s.setAreaEffectiveIds(cfg.getAreaEffectiveIds());
|
||||
s.setAttribute(cfg.getAttribute());
|
||||
s.setLable(cfg.getLable());
|
||||
s.setClassify(cfg.getClassify());
|
||||
s.setRequestId(cfg.getRequestId());
|
||||
s.setCfgDesc(cfg.getCfgDesc());
|
||||
s.setEditorId(cfg.getEditorId());
|
||||
s.setEditTime(cfg.getEditTime());
|
||||
if(s.getCompileId()==null){
|
||||
featuresCompileId = new ConvertTool().getCompileId();
|
||||
AppFeaturesIndex f = new AppFeaturesIndex();
|
||||
f.setAppCompileId(cfg.getCompileId());
|
||||
f.setFeaturesCompileId(featuresCompileId);
|
||||
f.setFeaturesTableType(2);
|
||||
f.setFeaturesTable(s.getTableName());
|
||||
appCfgDao.insertFeatures(f);
|
||||
s.setTableName(s.getTableName());
|
||||
s.setAction(cfg.getAction());
|
||||
s.setServiceId(cfg.getServiceId());
|
||||
s.setCompileId(featuresCompileId);
|
||||
s.setCreateTime(new Date());
|
||||
s.setCreatorId(cfg.getCurrentUser().getId());
|
||||
s.setIsAudit(cfg.getIsAudit());
|
||||
s.setIsValid(cfg.getIsValid());
|
||||
stringCfgDao.insert(s);
|
||||
}else{
|
||||
stringCfgDao.update(s);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return appCfgDao.updateByPrimaryKeySelective(cfg);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* auditAppCfg(审核IP类配置)
|
||||
* (继承AppIdCfg这个类方可使用)
|
||||
* @param cfg
|
||||
* @return
|
||||
*int
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public int auditAppCfg(AppIdCfg cfg){
|
||||
return appCfgDao.audit(cfg);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* deleteAppCfg(删除IP类配置)
|
||||
* (继承AppIdCfg这个类方可使用)
|
||||
* @param cfg
|
||||
* @return
|
||||
*int
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public int deleteAppCfg(AppIdCfg cfg){
|
||||
return appCfgDao.updateValid(cfg);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* getAppCfg(根据IP与类名获取IP配置)
|
||||
* (继承AppIdCfg这个类方可使用)
|
||||
* @param id
|
||||
* @return
|
||||
*AppIdCfg
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public AppIdCfg getAppCfgById(long id){
|
||||
return appCfgDao.getById(id);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* getAppCfg(根据IP与类名获取IP配置)
|
||||
* (继承AppIdCfg这个类方可使用)
|
||||
* @param id
|
||||
* @return
|
||||
*AppIdCfg
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
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();
|
||||
if(!StringUtil.isEmpty(featuresTableList)){
|
||||
for(AppFeaturesIndex features:featuresTableList){
|
||||
if(features.getFeaturesTableType().equals(4)){//增强字符串特征配置
|
||||
List<ComplexkeywordCfg> complexFeaturesList = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId(
|
||||
features.getFeaturesTable(),features.getFeaturesCompileId());
|
||||
complexList.addAll(complexFeaturesList);
|
||||
|
||||
|
||||
}else if(features.getFeaturesTableType().equals(2)){//普通字符串特征配置
|
||||
List<BaseStringCfg> strFeaturesCfgList = appCfgDao.getStrFeaturesCfgListByCompileId(
|
||||
features.getFeaturesTable(),features.getFeaturesCompileId());
|
||||
strList.addAll(strFeaturesCfgList);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
cfg.setComplexFeaturesList(complexList);
|
||||
cfg.setStrFeaturesCfgList(strList);
|
||||
return cfg;
|
||||
}
|
||||
public Integer getIsValid(Long cfgId){
|
||||
return appCfgDao.getIsValid(cfgId);
|
||||
}
|
||||
/*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){
|
||||
return appCfgDao.getIsAudit(tableName,id);
|
||||
}*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user