ct查询ip接口

develop
guyuliang 2024-05-30 18:22:18 +08:00
parent 1876740e27
commit 4cc086835a
3 changed files with 43 additions and 13 deletions

View File

@ -27,15 +27,15 @@ spring:
discovery:
register: true
enable: true
instance-host: 10.40.20.48
instance-host: 127.0.0.1
instance-port: ${server.port}
root: ${spring.cloud.zookeeper.home}/services
datasource:
druid:
dialect: mysql
url: jdbc:mysql://10.20.12.56:3306/cmp?characterEncoding=utf8&useSSL=false
dialect: dm
url: jdbc:dm://23.33.3.28:5236/cmp?characterEncoding=utf8&useSSL=false
username: cmp
password: Gy2VghUgWHszx8gLFT4etT9ZVOukJi73KoG1q3Oz/DAz5h2mFVVunjcyaaKT9tMPsBgoWBFRmrYbhgqJqT/Q8A==
password: BoYunCmp@v587
initialSize: '2'
maxActive: '30'
minIdle: '2'
@ -54,12 +54,12 @@ spring:
timeBetweenEvictionRunsMillis: '10000'
minEvictableIdleTimeMillis: '30001'
asyncCloseConnectionEnable: 'true'
filters: config,stat,wall,log4j
filters: config,stat,log4j
publicKey: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJfVJOpXYGy8aBCk3zEoKKQDTVCCvJwhhithfY/I5PUvzFBAYygunmuCtUhzPUZ+1RJQds0Q4fu07m5mr5kv5ocCAwEAAQ==
connectionProperties: config.decrypt=true;config.decrypt.key=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJfVJOpXYGy8aBCk3zEoKKQDTVCCvJwhhithfY/I5PUvzFBAYygunmuCtUhzPUZ+1RJQds0Q4fu07m5mr5kv5ocCAwEAAQ==;druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
connectionProperties: config.decrypt=false;config.decrypt.key=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJfVJOpXYGy8aBCk3zEoKKQDTVCCvJwhhithfY/I5PUvzFBAYygunmuCtUhzPUZ+1RJQds0Q4fu07m5mr5kv5ocCAwEAAQ==;druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
use-global-data-source-stat: 'true'
rabbitmq:
host: 10.20.12.56
host: 23.33.3.28
port: 5672
username: admin
password: BOCLOUD@CoU6oY/zuAoBbu6cdgOKlA==
@ -71,7 +71,7 @@ spring:
checkTemplateLocation: 'false'
redis:
# standalone
host: 10.20.12.56
host: 23.33.3.28
port: 6379
timeout: 60000ms
password: BOCLOUD@CoU6oY/zuAoBbu6cdgOKlA==
@ -89,7 +89,7 @@ spring:
allow-circular-references: true
zk:
server:
url: 10.20.12.56:2181
url: 127.0.0.1:2181
username: bocloud
password: BOCLOUD@CoU6oY/zuAoBbu6cdgOKlA==
conn:
@ -98,7 +98,7 @@ zk:
timeout: '50000'
logging:
config: classpath:logback-spring.xml
dir: /log/services
dir: /Users/guyuliang/project/EFC
level:
root: info
com:
@ -123,3 +123,6 @@ nim:
#Cmp Repo
cmp:
repo: http://192.168.6.209/yum
regex:

View File

@ -8,15 +8,19 @@ import com.bocloud.common.utils.ListTool;
import com.bocloud.common.utils.MapTools;
import com.bocloud.database.core.intf.impl.BasicGenericDao;
import com.bocloud.database.utils.QueryBuilder;
import com.bocloud.ims.entity.model.SimpleIpModel;
import com.bocloud.ims.entity.resource.Ip;
import com.bocloud.ims.entity.resource.Ip.IpStatus;
import com.bocloud.orm.OrmBasicDaoImpl;
import com.bocloud.orm.OrmGenericDaoImpl;
import com.google.common.collect.Maps;
import org.springframework.beans.BeanUtils;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -179,6 +183,23 @@ public class IpRepository extends OrmGenericDaoImpl<Ip, Long> {
return this.list(Ip.class, sql, params);
}
public List<SimpleIpModel> listByPool(Long poolId, String status) {
String sql = "select id,ip,mask,gateway,dns,vendor_id,target,catalog,pool_id,status from ip where pool_id = :poolId and status = :status";
Map<String, Object> params = MapTools.simpleMap("poolId", poolId);
params.put("status", status);
List<Ip> ips = this.list(Ip.class, sql, params);
List<SimpleIpModel> list = new ArrayList<>();
if (!ObjectUtils.isEmpty(ips)) {
for (Ip ip : ips) {
SimpleIpModel model = new SimpleIpModel();
BeanUtils.copyProperties(ip, model);
list.add(model);
}
}
return list;
}
public boolean delete(Long target, String catalog, Long vendorId) {
// 5.6版本IP池中的IP是不允许被删除掉的 #PBSM-13169 bug
// 初步怀疑是调用delete方法将IP删除导致的因为调用的地方有点多版本今天要发布所以直接修改源头后续该部分逻辑需要移到相关业务层

View File

@ -15,6 +15,7 @@ import com.bocloud.common.utils.GridHelper;
import com.bocloud.common.utils.IDFactory;
import com.bocloud.common.utils.ListTool;
import com.bocloud.entity.bean.GenericEntity;
import com.bocloud.ims.entity.model.SimpleIpModel;
import com.bocloud.ims.entity.params.IpPatchParams;
import com.bocloud.ims.entity.resource.*;
import com.bocloud.ims.entity.resource.Ip.IpStatus;
@ -144,6 +145,11 @@ public class IpServiceImpl implements IpService {
} else if ("checkIp".equalsIgnoreCase(object.getString("condition"))) {
List<String> ips = JSONArray.parseArray(object.getString("ips"), String.class);
return this.checkIp(object.getLong("poolId"), ips, context);
}else if ("listByPoolAndStatus".equalsIgnoreCase(object.getString("condition"))) {
Long poolId = object.getLong("poolId");
String status = object.getString("status");
List<SimpleIpModel> ipList = ipRepository.listByPool(poolId, status);
return new BocloudResult<>(true, ipList, "查询成功");
}
return new BocloudResult<>(false, "参数格式错误");
} catch (Exception e) {