Authored by mlge

Revert "no message"

This reverts commit 4233b6ff.
... ... @@ -6,8 +6,6 @@ import com.monitor.cmdb.service.IHostInfoService;
import com.monitor.model.request.HostInfoReq;
import com.monitor.model.response.BaseResponse;
import com.monitor.model.response.PageResponse;
import com.monitor.mysql.mapper.HostInfoMapper;
import org.codehaus.jackson.map.Serializers;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -19,15 +17,10 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.xml.ws.Response;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
/**
... ... @@ -43,8 +36,6 @@ public class HostInfoCtrl {
@Autowired
IHostInfoService hostInfoService;
@RequestMapping("/getHostInfos")
@ResponseBody
public BaseResponse<PageResponse<HostInfo>> getHostInfos(@RequestBody HostInfoReq req) throws Exception {
... ... @@ -130,30 +121,5 @@ public class HostInfoCtrl {
return JSON.toJSONString(ips);
}
/**
* 更新主机tag信息为空
* @param ips
* @return
*/
@RequestMapping("/updateHostInfoByIps")
@ResponseBody
public BaseResponse updateHostInfoByIps(String ips){
List<HostInfo> hostInfoList = JSON.parseArray(ips,HostInfo.class);
try{
hostInfoService.updateTagByIps(hostInfoList);
return new BaseResponse();
}catch(Exception e){
log.error("updateHostInfoByIps error",e);
return new BaseResponse("updateHostInfoByIps error");
}
}
@RequestMapping("/saveHostListInfos")
@ResponseBody
public BaseResponse saveHostListInfos(String hosts){
List<HostInfo> hostInfos = JSON.parseArray(hosts,HostInfo.class);
return hostInfoService.saveHostListInfo(hostInfos);
}
}
... ...
... ... @@ -6,6 +6,7 @@ import com.monitor.model.response.BaseResponse;
import com.monitor.model.response.PageResponse;
import java.util.List;
import java.util.Set;
/**
* Created by yoho on 2016/6/14.
... ... @@ -24,8 +25,4 @@ public interface IHostInfoService {
List<HostInfo> getHostInfosByTag(String tag);
List<HostInfo> getHostInfoByIps(List<String> ids);
void updateTagByIps(List<HostInfo> hostInfoList);
BaseResponse saveHostListInfo(List<HostInfo> hostInfos);
}
... ...
... ... @@ -123,40 +123,4 @@ public class HostInfoServiceImpl implements IHostInfoService {
return hostInfoMapper.selectHostInfosByIps(ips);
}
/**
* 将tag更新为空
* @param
*/
@Override
public void updateTagByIps(List<HostInfo> hostInfoList){
if(hostInfoList != null && hostInfoList.size() > 0){
for(HostInfo host : hostInfoList)
hostInfoMapper.updateHostInfoByIp(host);
}
}
@Override
public BaseResponse saveHostListInfo(List<HostInfo> hostInfos) {
BaseResponse resp = new BaseResponse();
String message = "";
for(HostInfo host : hostInfos){
HostInfo h = hostInfoMapper.selectByHostIp(host.getHostIp());
try{
if(h != null){//存在则更新
hostInfoMapper.updateHostInfoByIp(host);
}else{
hostInfoMapper.insert(host);
}
}catch(Exception e){
logger.error("saveHostListInfo error: ",e);
message = message + "saveHostListInfo error --ip:" + host.getHostIp() + ";";
}
}
if(!"".equals(message)){
resp.setMessage(message);
}
return new BaseResponse();
}
}
... ...
... ... @@ -30,8 +30,4 @@ public interface HostInfoMapper {
HostInfo selectByHostIp(@Param("hostIp") String hostIp);
List<HostInfo> selectHostInfosByIps(@Param("hostIps") List<String> ips);
int updateTagByIps(HostInfo record);
int updateHostInfoByIp(HostInfo record);
}
\ No newline at end of file
... ...
... ... @@ -199,24 +199,4 @@
#{hostIp}
</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},
tags = #{tags,jdbcType=VARCHAR},
update_time = now()
where ip = #{hostIp,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -5,6 +5,5 @@
<configuration>
<settings>
<setting name="defaultStatementTimeout" value="2"/> <!-- seconds -->
<setting name="logImpl" value="STDOUT_LOGGING" />
</settings>
</configuration>
\ No newline at end of file
... ...
... ... @@ -121,9 +121,9 @@
<properties>
<package.environment>product</package.environment>
</properties>
<!-- <activation>
<activation>
<activeByDefault>true</activeByDefault>
</activation>-->
</activation>
</profile>
<profile>
<id>qcloud</id>
... ... @@ -136,9 +136,6 @@
<properties>
<package.environment>test</package.environment>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
</project>
\ No newline at end of file
... ...
... ... @@ -13,14 +13,6 @@
<!-- 日志最大的文件大小 10MB-->
<property name="maxFileSize" value="100MB"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- 对日志进行格式化 -->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger -%msg%n</pattern>
</encoder>
</appender>
<appender name="WARN" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${catalina.home}/logs/warn.log</file>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
... ... @@ -218,17 +210,4 @@
<appender-ref ref="WARN"/>
</root>
<logger name="org.apache.ibatis" additivity="false">
<level value="DEBUG"/>
<appender-ref ref="STDOUT"/>
</logger>
<logger name="com.monitor.mysql.mapper" additivity="false">
<level value="DEBUG"/>
<appender-ref ref="STDOUT"/>
<!--<appender-ref ref="FILE"/>-->
</logger>
</configuration>
\ No newline at end of file
... ...