Authored by qinchao

标签管理

... ... @@ -16,7 +16,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
... ... @@ -50,6 +53,33 @@ public class HostGroupCtrl {
}
@RequestMapping("/getAllTagsGroupByType")
@ResponseBody
public BaseResponse getAllTagsGroupByType() {
try{
List<HostGroup> list=hostGroupService.getAllGroups("");
Map<String,List<HostGroup>> map= new HashMap<String,List<HostGroup>>();
if(list!=null&&list.size()>0){
for(HostGroup tag:list){
if(map.keySet().contains(tag.getTagType())){
map.get(tag.getTagType()).add(tag);
}else{
List<HostGroup> ls=new ArrayList<HostGroup>();
ls.add(tag);
map.put(tag.getTagType(),ls);
}
}
}
return new BaseResponse<Map<String,List<HostGroup>>>(map);
}catch (Exception e){
log.error("getAllTagsGroupByType error",e);
return null;
}
}
@RequestMapping("/getHostGroups")
@ResponseBody
public BaseResponse<PageResponse<HostGroup>> getHostGroups(@RequestBody TagReq request) {
... ...
... ... @@ -7,6 +7,7 @@ import com.monitor.model.request.TagReq;
import com.monitor.model.response.BaseResponse;
import java.util.List;
import java.util.Map;
/**
* Created by yoho on 2016/6/14.
... ...
... ... @@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Map;
/**
* Created by yoho on 2016/6/15.
... ...
... ... @@ -54,7 +54,7 @@
<if test="params.tagTypeContent!=null &amp;&amp; params.tagTypeContent != ''">
and tag_type = #{params.tagTypeContent,jdbcType=VARCHAR}
</if>
order by id desc
order by tag_type,id desc
limit #{startIndex},#{pageSize}
</select>
... ...