Authored by qinchao

可用区hostinfo

... ... @@ -33,8 +33,6 @@ public interface IHostInfoService {
List<HostInfo> getHostInfoByIps(List<String> ips);
BaseResponse updateTagByIps(List<HostInfo> hostInfoList);
BaseResponse saveHostListInfo(List<HostInfo> hostInfos);
BaseResponse removeByIps(List<String> removeIps);
... ...
... ... @@ -187,13 +187,6 @@ public class HostInfoServiceImpl implements IHostInfoService {
req.setTags(newTags);
}
//暂时无法确定腾讯云的可用区
if(1==req.getCloudType()){
req.setCloudDetailType(1);
}else if(2==req.getCloudType()){
req.setCloudDetailType(2);
}
if(req.getId()>0){
result=hostInfoMapper.updateByPrimaryKey(req);
... ... @@ -215,13 +208,6 @@ public class HostInfoServiceImpl implements IHostInfoService {
for(HostInfo host : hostInfos){
HostInfo h = hostInfoMapper.selectByHostIp(host.getHostIp());
//暂时无法确定腾讯云的可用区
if(1==h.getCloudType()){
h.setCloudDetailType(1);
}else if(2==h.getCloudType()){
h.setCloudDetailType(2);
}
try{
if(h != null){//存在则更新
hostInfoMapper.updateHostInfoByIp(host);
... ... @@ -306,33 +292,6 @@ public class HostInfoServiceImpl implements IHostInfoService {
return hostInfoMapper.selectHostInfosByIps(ips);
}
/**
* 将tag更新为空
* @param
*/
@Override
public BaseResponse updateTagByIps(List<HostInfo> hostInfoList){
BaseResponse resp = new BaseResponse();
String message = "";
if(hostInfoList != null && hostInfoList.size() > 0){
for(HostInfo host : hostInfoList){
try{
hostInfoMapper.updateHostInfoByIp(host);
}catch(Exception e){
logger.error("updateTagByIps error: ",e);
message = message + "updateTagByIps error --ip:" + host.getHostIp() + ";";
}
}
}
if(!"".equals(message)){
resp.setCode(201);
resp.setMessage(message);
}
return resp;
}
@Override
public BaseResponse removeByIps(List<String> removeIps) {
... ...
... ... @@ -21,6 +21,8 @@ public class HostInfoReq extends PageRequest {
private int cloudType;
private int cloudDetailType;
private int groupId;
private String tags;
... ...
... ... @@ -11,8 +11,6 @@ public interface HostInfoMapper {
int insert(HostInfo record);
int insertSelective(HostInfo record);
HostInfo selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(HostInfo record);
... ... @@ -35,8 +33,6 @@ public interface HostInfoMapper {
List<HostInfo> selectHostInfosByIps(@Param("hostIps") List<String> ips);
int updateTagByIps(HostInfo record);
int updateHostInfoByIp(HostInfo record);
int deleteByIp(String ip);
... ...
... ... @@ -6,14 +6,15 @@
<result column="alias" property="alias" jdbcType="VARCHAR" />
<result column="host_ip" property="hostIp" jdbcType="VARCHAR" />
<result column="group_id" property="groupId" jdbcType="INTEGER" />
<result column="cloud_type" property="cloudType" jdbcType="BIT" />
<result column="cloud_type" property="cloudType" jdbcType="INTEGER" />
<result column="cloud_detail_type" property="cloudDetailType" jdbcType="INTEGER" />
<result column="tags" property="tags" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
<result column="group_name" property="groupName" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, alias, host_ip, group_id, cloud_type, tags, create_time, update_time
id, alias, host_ip, group_id, cloud_type, tags, create_time, update_time,cloud_detail_type
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
... ... @@ -28,66 +29,12 @@
<insert id="insert" parameterType="com.model.HostInfo" >
insert into host_info (id, alias, host_ip,
group_id, cloud_type, tags,
create_time, update_time)
create_time, update_time,cloud_detail_type)
values (#{id,jdbcType=INTEGER}, #{alias,jdbcType=VARCHAR}, #{hostIp,jdbcType=VARCHAR},
#{groupId,jdbcType=INTEGER}, #{cloudType,jdbcType=BIT}, #{tags,jdbcType=VARCHAR},
now(), now())
</insert>
<insert id="insertSelective" parameterType="com.model.HostInfo" >
insert into host_info
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="alias != null" >
alias,
</if>
<if test="hostIp != null" >
host_ip,
</if>
<if test="groupId != null" >
group_id,
</if>
<if test="cloudType != null" >
cloud_type,
</if>
<if test="tags != null" >
tags,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="alias != null" >
#{alias,jdbcType=VARCHAR},
</if>
<if test="hostIp != null" >
#{hostIp,jdbcType=VARCHAR},
</if>
<if test="groupId != null" >
#{groupId,jdbcType=INTEGER},
</if>
<if test="cloudType != null" >
#{cloudType,jdbcType=BIT},
</if>
<if test="tags != null" >
#{tags,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
#{groupId,jdbcType=INTEGER}, #{cloudType,jdbcType=INTEGER}, #{tags,jdbcType=VARCHAR},
now(), now(), #{cloudDetailType,jdbcType=INTEGER})
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.model.HostInfo" >
update host_info
<set >
... ... @@ -101,7 +48,10 @@
group_id = #{groupId,jdbcType=INTEGER},
</if>
<if test="cloudType != null &amp;&amp; cloudType != 0" >
cloud_type = #{cloudType,jdbcType=BIT},
cloud_type = #{cloudType,jdbcType=INTEGER},
</if>
<if test="cloudDetailType != null &amp;&amp; cloudDetailType != 0" >
cloud_detail_type = #{cloudDetailType,jdbcType=INTEGER},
</if>
<if test="tags != null" >
tags = #{tags,jdbcType=VARCHAR},
... ... @@ -120,7 +70,8 @@
set alias = #{alias,jdbcType=VARCHAR},
host_ip = #{hostIp,jdbcType=VARCHAR},
group_id = #{groupId,jdbcType=INTEGER},
cloud_type = #{cloudType,jdbcType=BIT},
cloud_type = #{cloudType,jdbcType=INTEGER},
cloud_detail_type = #{cloudDetailType,jdbcType=INTEGER},
tags = #{tags,jdbcType=VARCHAR},
update_time = now()
where id = #{id,jdbcType=INTEGER}
... ... @@ -138,6 +89,9 @@
<if test="params.cloudType != null &amp;&amp; params.cloudType != 0" >
and a.cloud_type = #{params.cloudType}
</if>
<if test="params.cloudDetailType != null &amp;&amp; params.cloudDetailType != 0" >
and a.cloud_detail_type = #{params.cloudDetailType}
</if>
<if test="params.hostIp != null &amp;&amp; params.hostIp != ''" >
and a.host_ip like concat(#{params.hostIp},'%')
</if>
... ... @@ -169,7 +123,7 @@
<select id="selectHostInfosByCodition" resultMap="BaseResultMap">
select
a.id, a.alias, a.host_ip, a.group_id, a.cloud_type, a.tags, a.create_time, a.update_time,b.group_name
a.id, a.alias, a.host_ip, a.group_id, a.cloud_type,a.cloud_detail_type, a.tags, a.create_time, a.update_time,b.group_name
from host_info a left join host_group b on a.group_id=b.id
where
1=1
... ... @@ -179,6 +133,9 @@
<if test="params.cloudType != null &amp;&amp; params.cloudType != 0" >
and a.cloud_type = #{params.cloudType}
</if>
<if test="params.cloudDetailType != null &amp;&amp; params.cloudDetailType != 0" >
and a.cloud_detail_type = #{params.cloudDetailType}
</if>
<if test="params.hostIp != null &amp;&amp; params.hostIp != ''" >
and a.host_ip like concat(#{params.hostIp},'%')
</if>
... ... @@ -277,24 +234,15 @@
</foreach>
</select>
<update id="updateTagByIps" >
update host_info
set tags = ""
where host_ip in
<foreach item="hostIp" index="index" collection="hostIps" open="("
separator="," close=")">
#{hostIp}
</foreach>
</update>
<update id="updateHostInfoByIp" parameterType="com.model.HostInfo" >
update host_info
set alias = #{alias,jdbcType=VARCHAR},
cloud_type = #{cloudType,jdbcType=BIT},
cloud_type = #{cloudType,jdbcType=INTEGER},
cloud_detail_type = #{cloudType,jdbcType=INTEGER},
tags = #{tags,jdbcType=VARCHAR},
update_time = now()
where host_ip = #{hostIp,jdbcType=INTEGER}
where host_ip = #{hostIp,jdbcType=VARCHAR}
</update>
... ...