|
@@ -3,12 +3,15 @@ package com.kuyuntech.vrv.coreservice.service.core.impl;
|
|
|
|
|
|
|
|
import com.kuyuntech.vrv.coreapi.service.core.GatewayService;
|
|
import com.kuyuntech.vrv.coreapi.service.core.GatewayService;
|
|
|
import com.kuyuntech.vrv.coreservice.dao.core.GatewayDao;
|
|
import com.kuyuntech.vrv.coreservice.dao.core.GatewayDao;
|
|
|
|
|
+import com.kuyuntech.vrv.coreservice.domain.core.Project;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import com.kuyuntech.vrv.coreapi.bean.core.GatewayBean;
|
|
import com.kuyuntech.vrv.coreapi.bean.core.GatewayBean;
|
|
|
import com.kuyuntech.vrv.coreservice.domain.core.Gateway;
|
|
import com.kuyuntech.vrv.coreservice.domain.core.Gateway;
|
|
|
import com.wbspool.fastboot.core.common.bean.PagerBean;
|
|
import com.wbspool.fastboot.core.common.bean.PagerBean;
|
|
|
|
|
+
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -16,38 +19,36 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.hibernate.criterion.DetachedCriteria;
|
|
import org.hibernate.criterion.DetachedCriteria;
|
|
|
import org.hibernate.criterion.Restrictions;
|
|
import org.hibernate.criterion.Restrictions;
|
|
|
|
|
+
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
|
+
|
|
|
import org.hibernate.criterion.Order;
|
|
import org.hibernate.criterion.Order;
|
|
|
import com.wbspool.fastboot.core.jpa.service.AbstractFastbootService;
|
|
import com.wbspool.fastboot.core.jpa.service.AbstractFastbootService;
|
|
|
import org.springframework.util.Assert;
|
|
import org.springframework.util.Assert;
|
|
|
-import static com.wbspool.fastboot.core.jpa.constant.DataValidTypes.*;
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
+import static com.wbspool.fastboot.core.jpa.constant.DataValidTypes.*;
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
-* GatewayService
|
|
|
|
|
-*
|
|
|
|
|
-*/
|
|
|
|
|
|
|
+ * GatewayService
|
|
|
|
|
+ */
|
|
|
@Service("gatewayService")
|
|
@Service("gatewayService")
|
|
|
-@Transactional(rollbackFor = Exception.class,transactionManager = "vrvCoreServiceTransactionManager")
|
|
|
|
|
-public class GatewayServiceImpl extends AbstractFastbootService<Gateway,GatewayBean> implements GatewayService {
|
|
|
|
|
|
|
+@Transactional(rollbackFor = Exception.class, transactionManager = "vrvCoreServiceTransactionManager")
|
|
|
|
|
+public class GatewayServiceImpl extends AbstractFastbootService<Gateway, GatewayBean> implements GatewayService {
|
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(GatewayServiceImpl.class);
|
|
private static final Logger logger = LoggerFactory.getLogger(GatewayServiceImpl.class);
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
GatewayDao gatewayDao;
|
|
GatewayDao gatewayDao;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public GatewayBean add(GatewayBean gatewayBean) {
|
|
public GatewayBean add(GatewayBean gatewayBean) {
|
|
|
|
|
|
|
|
Gateway gateway = new Gateway();
|
|
Gateway gateway = new Gateway();
|
|
|
- beanToDomain(gatewayBean,gateway,"id");
|
|
|
|
|
|
|
+ beanToDomain(gatewayBean, gateway, "id");
|
|
|
gatewayDao.save(gateway);
|
|
gatewayDao.save(gateway);
|
|
|
- domainToBean(gateway,gatewayBean);
|
|
|
|
|
|
|
+ domainToBean(gateway, gatewayBean);
|
|
|
return gatewayBean;
|
|
return gatewayBean;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -55,23 +56,23 @@ public class GatewayServiceImpl extends AbstractFastbootService<Gateway,GatewayB
|
|
|
@Override
|
|
@Override
|
|
|
public GatewayBean update(GatewayBean gatewayBean) {
|
|
public GatewayBean update(GatewayBean gatewayBean) {
|
|
|
|
|
|
|
|
- if(gatewayBean == null ){
|
|
|
|
|
- return null ;
|
|
|
|
|
|
|
+ if (gatewayBean == null) {
|
|
|
|
|
+ return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- Gateway gateway = gatewayDao.findByCodeAndValid(gatewayBean.getCode(),VALID);
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
- if(gateway == null){
|
|
|
|
|
|
|
+ Gateway gateway = gatewayDao.findByCodeAndValid(gatewayBean.getCode(), VALID);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (gateway == null) {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- beanToDomain(gatewayBean,gateway,"id","code","version","createTime","updateTime","valid");
|
|
|
|
|
|
|
+ beanToDomain(gatewayBean, gateway, "id", "code", "version", "createTime", "updateTime", "valid");
|
|
|
|
|
|
|
|
gatewayDao.save(gateway);
|
|
gatewayDao.save(gateway);
|
|
|
|
|
|
|
|
- domainToBean(gateway,gatewayBean);
|
|
|
|
|
|
|
+ domainToBean(gateway, gatewayBean);
|
|
|
|
|
|
|
|
return gatewayBean;
|
|
return gatewayBean;
|
|
|
}
|
|
}
|
|
@@ -79,60 +80,58 @@ public class GatewayServiceImpl extends AbstractFastbootService<Gateway,GatewayB
|
|
|
@Override
|
|
@Override
|
|
|
public GatewayBean delete(GatewayBean gatewayBean) {
|
|
public GatewayBean delete(GatewayBean gatewayBean) {
|
|
|
|
|
|
|
|
- if(gatewayBean == null){
|
|
|
|
|
- return null ;
|
|
|
|
|
|
|
+ if (gatewayBean == null) {
|
|
|
|
|
+ return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- Gateway gateway = gatewayDao.findByCodeAndValid(gatewayBean.getCode(),VALID);
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
+ Gateway gateway = gatewayDao.findByCodeAndValid(gatewayBean.getCode(), VALID);
|
|
|
|
|
|
|
|
- if(gateway == null){
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (gateway == null) {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
gateway.setValid(INVALID);
|
|
gateway.setValid(INVALID);
|
|
|
gatewayDao.save(gateway);
|
|
gatewayDao.save(gateway);
|
|
|
-
|
|
|
|
|
|
|
|
|
|
- domainToBean(gateway,gatewayBean);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ domainToBean(gateway, gatewayBean);
|
|
|
|
|
|
|
|
return gatewayBean;
|
|
return gatewayBean;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public GatewayBean find(GatewayBean gatewayBean) {
|
|
public GatewayBean find(GatewayBean gatewayBean) {
|
|
|
- if(gatewayBean == null){
|
|
|
|
|
- return null ;
|
|
|
|
|
|
|
+ if (gatewayBean == null) {
|
|
|
|
|
+ return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- Gateway gateway = gatewayDao.findByCodeAndValid(gatewayBean.getCode(),VALID);
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ Gateway gateway = gatewayDao.findByCodeAndValid(gatewayBean.getCode(), VALID);
|
|
|
|
|
|
|
|
|
|
|
|
|
- if(gateway == null){
|
|
|
|
|
- return null ;
|
|
|
|
|
|
|
+ if (gateway == null) {
|
|
|
|
|
+ return null;
|
|
|
}
|
|
}
|
|
|
- BeanUtils.copyProperties(gateway,gatewayBean);
|
|
|
|
|
|
|
+ BeanUtils.copyProperties(gateway, gatewayBean);
|
|
|
return gatewayBean;
|
|
return gatewayBean;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public GatewayBean find(String code) {
|
|
public GatewayBean find(String code) {
|
|
|
- return this.find(GatewayBean.builder().code(code).build());
|
|
|
|
|
|
|
+ return this.find(GatewayBean.builder().code(code).build());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<GatewayBean> findAll(GatewayBean gatewayBean, PagerBean pagerBean) {
|
|
public List<GatewayBean> findAll(GatewayBean gatewayBean, PagerBean pagerBean) {
|
|
|
List<GatewayBean> gatewayBeans = new ArrayList<>();
|
|
List<GatewayBean> gatewayBeans = new ArrayList<>();
|
|
|
DetachedCriteria detachedCriteria = createListCriteria(gatewayBean);
|
|
DetachedCriteria detachedCriteria = createListCriteria(gatewayBean);
|
|
|
- List<Gateway> gateways = gatewayDao.findAll(detachedCriteria,pagerBean);
|
|
|
|
|
|
|
+ List<Gateway> gateways = gatewayDao.findAll(detachedCriteria, pagerBean);
|
|
|
for (Gateway gateway : gateways) {
|
|
for (Gateway gateway : gateways) {
|
|
|
GatewayBean gatewayBeanTemp = new GatewayBean();
|
|
GatewayBean gatewayBeanTemp = new GatewayBean();
|
|
|
- domainToBean(gateway,gatewayBeanTemp);
|
|
|
|
|
|
|
+ domainToBean(gateway, gatewayBeanTemp);
|
|
|
gatewayBeans.add(gatewayBeanTemp);
|
|
gatewayBeans.add(gatewayBeanTemp);
|
|
|
}
|
|
}
|
|
|
return gatewayBeans;
|
|
return gatewayBeans;
|
|
@@ -140,17 +139,17 @@ public class GatewayServiceImpl extends AbstractFastbootService<Gateway,GatewayB
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<GatewayBean> findAll(GatewayBean gatewayBean) {
|
|
public List<GatewayBean> findAll(GatewayBean gatewayBean) {
|
|
|
- return this.findAll(gatewayBean,null);
|
|
|
|
|
|
|
+ return this.findAll(gatewayBean, null);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public Long countAll(GatewayBean gatewayBean) {
|
|
|
|
|
|
|
+ public Long countAll(GatewayBean gatewayBean) {
|
|
|
DetachedCriteria detachedCriteria = createListCriteria(gatewayBean);
|
|
DetachedCriteria detachedCriteria = createListCriteria(gatewayBean);
|
|
|
return gatewayDao.countAll(detachedCriteria);
|
|
return gatewayDao.countAll(detachedCriteria);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
|
- public PagerBean<GatewayBean> findPager(GatewayBean gatewayBean, PagerBean pagerBean) {
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public PagerBean<GatewayBean> findPager(GatewayBean gatewayBean, PagerBean pagerBean) {
|
|
|
List<GatewayBean> gatewayBeans = this.findAll(gatewayBean, pagerBean);
|
|
List<GatewayBean> gatewayBeans = this.findAll(gatewayBean, pagerBean);
|
|
|
Long count = this.countAll(gatewayBean);
|
|
Long count = this.countAll(gatewayBean);
|
|
|
PagerBean<GatewayBean> gatewayPageBean = new PagerBean<>();
|
|
PagerBean<GatewayBean> gatewayPageBean = new PagerBean<>();
|
|
@@ -158,30 +157,30 @@ public class GatewayServiceImpl extends AbstractFastbootService<Gateway,GatewayB
|
|
|
gatewayPageBean.setItemCount(count.intValue());
|
|
gatewayPageBean.setItemCount(count.intValue());
|
|
|
gatewayPageBean.init();
|
|
gatewayPageBean.init();
|
|
|
gatewayPageBean.setItems(gatewayBeans);
|
|
gatewayPageBean.setItems(gatewayBeans);
|
|
|
- return gatewayPageBean ;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 创建列表查询条件
|
|
|
|
|
- * @param gatewayBean 查询参数
|
|
|
|
|
- * @return
|
|
|
|
|
- */
|
|
|
|
|
- private static DetachedCriteria createListCriteria(GatewayBean gatewayBean){
|
|
|
|
|
- DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Gateway.class);
|
|
|
|
|
- detachedCriteria.add(Restrictions.eq("valid",VALID));
|
|
|
|
|
- return detachedCriteria;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return gatewayPageBean;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 创建列表查询条件
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param gatewayBean 查询参数
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private static DetachedCriteria createListCriteria(GatewayBean gatewayBean) {
|
|
|
|
|
+ DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Gateway.class);
|
|
|
|
|
+ detachedCriteria.add(Restrictions.eq("valid", VALID));
|
|
|
|
|
+ return detachedCriteria;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void batchDelete(List<GatewayBean> gatewayBean) {
|
|
public void batchDelete(List<GatewayBean> gatewayBean) {
|
|
|
- if(gatewayBean.isEmpty()){
|
|
|
|
|
- return ;
|
|
|
|
|
|
|
+ if (gatewayBean.isEmpty()) {
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
List<String> codes = new ArrayList<>();
|
|
List<String> codes = new ArrayList<>();
|
|
|
- gatewayBean.forEach((e) ->{
|
|
|
|
|
- codes.add(e.getCode());
|
|
|
|
|
|
|
+ gatewayBean.forEach((e) -> {
|
|
|
|
|
+ codes.add(e.getCode());
|
|
|
});
|
|
});
|
|
|
batchDeleteByCodes(codes);
|
|
batchDeleteByCodes(codes);
|
|
|
|
|
|
|
@@ -191,17 +190,14 @@ public class GatewayServiceImpl extends AbstractFastbootService<Gateway,GatewayB
|
|
|
@Override
|
|
@Override
|
|
|
public void batchDeleteByCodes(List<String> codes) {
|
|
public void batchDeleteByCodes(List<String> codes) {
|
|
|
|
|
|
|
|
- if(codes.isEmpty()){
|
|
|
|
|
- return ;
|
|
|
|
|
|
|
+ if (codes.isEmpty()) {
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
for (String code : codes) {
|
|
for (String code : codes) {
|
|
|
- Assert.notNull(this.delete(GatewayBean.builder().code(code).build()),"batch delete by codes error! ");
|
|
|
|
|
|
|
+ Assert.notNull(this.delete(GatewayBean.builder().code(code).build()), "batch delete by codes error! ");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|