Authored by qinchao

标签管理

... ... @@ -34,9 +34,9 @@ public class HostGroupCtrl {
@RequestMapping("/getAllGroups")
@ResponseBody
public BaseResponse getAllGroups() {
public BaseResponse getAllGroups(String tagType) {
try{
List<HostGroup> list=hostGroupService.getListGroups();
List<HostGroup> list=hostGroupService.getAllGroups(tagType);
if (list == null || CollectionUtils.isEmpty(list)) {
return new BaseResponse<List<HostGroup>>();
... ...
... ... @@ -76,7 +76,7 @@ public class MObjectInfoCtrl {
String selectTag = "";
List<HostGroup> sourceGroupList = groupService.getListGroups();
List<HostGroup> sourceGroupList = groupService.getAllGroups("");
//add blank tag
... ...
... ... @@ -20,6 +20,6 @@ public interface IHostGroupService {
BaseResponse<HostGroup> getHostGroupById(int id);
List<HostGroup> getListGroups();
List<HostGroup> getAllGroups(String tagType);
}
... ...
... ... @@ -92,7 +92,7 @@ public class HostGroupServiceImpl implements IHostGroupService {
}
@Override
public List<HostGroup> getListGroups() {
return hostGroupMapper.selectAllGroups();
public List<HostGroup> getAllGroups(String tagType) {
return hostGroupMapper.selectAllGroups(tagType);
}
}
... ...
... ... @@ -155,10 +155,6 @@ public class HostInfoServiceImpl implements IHostInfoService {
public PageResponse<HostInfo> getHostInfos(HostInfoReq req) {
logger.info("getHostInfos with param is {}", req);
if(req.getTagsList() != null && req.getTagsList().contains("isNull")){//查找没有标签的主机
req.setTags("isNull");
req.getTagsList().remove("isNull");
}
// 组装分页对象
PageBean page = PageBean.initPageInfo(req.getCurrentPage(),
req.getPageSize(), req);
... ...
... ... @@ -15,6 +15,8 @@ public class HostInfoReq extends PageRequest {
private String hostIp;
private String onlyShowTagsIsNull;
private int cloudType;
private int groupId;
... ...
... ... @@ -4,6 +4,7 @@ package com.monitor.mysql.mapper;
import com.model.HostGroup;
import com.monitor.model.domain.PageBean;
import com.monitor.model.page.PageRequest;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
... ... @@ -22,6 +23,6 @@ public interface HostGroupMapper {
List<HostGroup> selectHostGroups(PageBean page);
List<HostGroup> selectAllGroups();
List<HostGroup> selectAllGroups(@Param("tagType") String tagType);
}
\ No newline at end of file
... ...
... ... @@ -62,6 +62,10 @@
select
<include refid="Base_Column_List" />
from host_group
where 1=1
<if test="tagType!=null &amp;&amp; tagType != ''">
and tag_type = #{tagType,jdbcType=VARCHAR}
</if>
</select>
<select id="selectCount" resultType="java.lang.Integer">
... ...
... ... @@ -141,15 +141,19 @@
<if test="params.hostIp != null &amp;&amp; params.hostIp != ''" >
and a.host_ip = #{params.hostIp}
</if>
<if test=" params.tags == 'isNull'" >
and ( ISNULL(a.tags) or trim(a.tags) = "")
</if>
<if test="params.tagsList != null &amp;&amp; params.tagsList.size()>0" >
and
<foreach collection="params.tagsList" index="index" item="item" separator="and">
instr(a.tags, #{item}) &gt; 0
</foreach>
</if>
<choose>
<when test="params.onlyShowTagsIsNull != null &amp;&amp; params.onlyShowTagsIsNull != '' ">
and ( ISNULL(a.tags) or trim(a.tags) = "")
</when>
<otherwise>
<if test="params.tagsList != null &amp;&amp; params.tagsList.size()>0" >
and
<foreach collection="params.tagsList" index="index" item="item" separator="and">
instr(a.tags, #{item}) &gt; 0
</foreach>
</if>
</otherwise>
</choose>
</select>
<select id="selectHostInfosByCodition" resultMap="BaseResultMap">
... ... @@ -167,15 +171,20 @@
<if test="params.hostIp != null &amp;&amp; params.hostIp != ''" >
and a.host_ip = #{params.hostIp}
</if>
<if test=" params.tags == 'isNull'" >
and ( ISNULL(a.tags) or trim(a.tags) = "")
</if>
<if test="params.tagsList != null &amp;&amp; params.tagsList.size() > 0" >
and
<foreach collection="params.tagsList" index="index" item="item" separator="and">
<choose>
<when test="params.onlyShowTagsIsNull != null &amp;&amp; params.onlyShowTagsIsNull != '' ">
and ( ISNULL(a.tags) or trim(a.tags) = "")
</when>
<otherwise>
<if test="params.tagsList != null &amp;&amp; params.tagsList.size()>0" >
and
<foreach collection="params.tagsList" index="index" item="item" separator="and">
instr(a.tags, #{item}) &gt; 0
</foreach>
</if>
</if>
</otherwise>
</choose>
order by a.create_time desc
limit #{startIndex},#{pageSize}
... ...
... ... @@ -5,5 +5,6 @@
<configuration>
<settings>
<setting name="defaultStatementTimeout" value="2"/> <!-- seconds -->
<!--<setting name="logImpl" value="STDOUT_LOGGING" />-->
</settings>
</configuration>
\ No newline at end of file
... ...