From 4cc086835adf7ea2b1db8a0a6052cf90ebb7094d Mon Sep 17 00:00:00 2001 From: guyuliang Date: Thu, 30 May 2024 18:22:18 +0800 Subject: [PATCH] =?UTF-8?q?ct=E6=9F=A5=E8=AF=A2ip=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/config/application.yml | 29 ++++++++++--------- .../ims/repository/resource/IpRepository.java | 21 ++++++++++++++ .../ims/service/resource/IpServiceImpl.java | 6 ++++ 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/bocloud.ims.booter/src/main/resources/config/application.yml b/bocloud.ims.booter/src/main/resources/config/application.yml index 3386966..ff6642a 100644 --- a/bocloud.ims.booter/src/main/resources/config/application.yml +++ b/bocloud.ims.booter/src/main/resources/config/application.yml @@ -8,7 +8,7 @@ service: size: '2000' server: port: '18081' - + upload: storage: path: /home/cmp @@ -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: @@ -117,9 +117,12 @@ nim: password: password network: nimnet0 bosinst_data: bosinst_new - lpp_source: + lpp_source: spot: powerha72-spot mksysb: powerha72-sysb #Cmp Repo cmp: - repo: http://192.168.6.209/yum \ No newline at end of file + repo: http://192.168.6.209/yum + + +regex: \ No newline at end of file diff --git a/bocloud.ims.repository/src/main/java/com/bocloud/ims/repository/resource/IpRepository.java b/bocloud.ims.repository/src/main/java/com/bocloud/ims/repository/resource/IpRepository.java index 75400bf..880a2d7 100644 --- a/bocloud.ims.repository/src/main/java/com/bocloud/ims/repository/resource/IpRepository.java +++ b/bocloud.ims.repository/src/main/java/com/bocloud/ims/repository/resource/IpRepository.java @@ -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 { return this.list(Ip.class, sql, params); } + + public List 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 params = MapTools.simpleMap("poolId", poolId); + params.put("status", status); + List ips = this.list(Ip.class, sql, params); + List 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删除导致的,因为调用的地方有点多,版本今天要发布,所以直接修改源头,后续该部分逻辑需要移到相关业务层 diff --git a/bocloud.ims.service/src/main/java/com/bocloud/ims/service/resource/IpServiceImpl.java b/bocloud.ims.service/src/main/java/com/bocloud/ims/service/resource/IpServiceImpl.java index 5358e0c..d823383 100644 --- a/bocloud.ims.service/src/main/java/com/bocloud/ims/service/resource/IpServiceImpl.java +++ b/bocloud.ims.service/src/main/java/com/bocloud/ims/service/resource/IpServiceImpl.java @@ -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 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 ipList = ipRepository.listByPool(poolId, status); + return new BocloudResult<>(true, ipList, "查询成功"); } return new BocloudResult<>(false, "参数格式错误"); } catch (Exception e) {