Authored by zhaoqi

Merge branch 'dev_degrade'

... ... @@ -22,4 +22,6 @@ public class DegradeConfig {
private String switchOn;
private String functionPointName;
}
... ...
... ... @@ -22,4 +22,6 @@ public class DegradeInfoReq extends PageRequest {
private int id;
private String configDesc;
private String functionPointName;
}
... ...
... ... @@ -20,4 +20,5 @@ public interface DegradeConfigMapper {
List<DegradeConfig> selectByCondition(DegradeInfoReq req);
List<String> selectAllFunction();
}
\ No newline at end of file
... ...
... ... @@ -9,9 +9,10 @@
<result column="config_desc" property="configDesc" jdbcType="VARCHAR" />
<result column="level" property="level" jdbcType="TINYINT" />
<result column="img_url" property="imgUrl" jdbcType="VARCHAR" />
<result column="function_point_name" property="functionPointName" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, config_name, config_show_name, switch_on, config_desc, level, img_url
id, config_name, config_show_name, switch_on, config_desc, level, img_url,function_point_name
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
... ... @@ -19,7 +20,7 @@
from degrade_info
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByCondition" resultMap="BaseResultMap" >
<select id="selectByCondition" resultMap="BaseResultMap" parameterType="com.monitor.model.request.DegradeInfoReq">
select
<include refid="Base_Column_List" />
from degrade_info
... ... @@ -31,16 +32,22 @@
and level = #{level}
</if>
</select>
<select id="selectAllFunction" resultType="java.lang.String">
select function_point_name
from degrade_info WHERE function_point_name IS NOT NULL AND function_point_name !='' group by function_point_name
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from degrade_info
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.monitor.model.domain.DegradeConfig" >
insert into degrade_info (id, config_name, config_show_name, switch_on,
config_desc, level, img_url
config_desc, level, img_url,function_point_name
)
values (#{id,jdbcType=INTEGER}, #{configName,jdbcType=VARCHAR}, #{configShowName,jdbcType=VARCHAR}, #{switchOn,jdbcType=CHAR},
#{configDesc,jdbcType=VARCHAR}, #{level,jdbcType=TINYINT}, #{imgUrl,jdbcType=VARCHAR}
#{configDesc,jdbcType=VARCHAR}, #{level,jdbcType=TINYINT}, #{imgUrl,jdbcType=VARCHAR},#{functionPointName,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.monitor.model.domain.DegradeConfig" >
... ... @@ -64,6 +71,9 @@
<if test="imgUrl != null" >
img_url,
</if>
<if test="functionPointName != null" >
function_point_name,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="configName != null" >
... ... @@ -84,6 +94,9 @@
<if test="imgUrl != null" >
#{imgUrl,jdbcType=VARCHAR},
</if>
<if test="functionPointName != null" >
#{functionPointName,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.monitor.model.domain.DegradeConfig" >
... ... @@ -104,6 +117,9 @@
<if test="imgUrl != null" >
img_url = #{imgUrl,jdbcType=VARCHAR},
</if>
<if test="functionPointName != null" >
function_point_name = #{functionPointName,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
... ... @@ -114,7 +130,8 @@
switch_on = #{switchOn,jdbcType=CHAR},
config_desc = #{configDesc,jdbcType=VARCHAR},
level = #{level,jdbcType=TINYINT},
img_url = #{imgUrl,jdbcType=VARCHAR}
img_url = #{imgUrl,jdbcType=VARCHAR},
function_point_name = #{functionPointName,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -34,7 +34,7 @@ public class DegradeController {
@RequestMapping("/change")
@ResponseBody
public BaseResponse addDegradeConfig(@RequestBody DegradeInfoReq req){
BaseResponse<Integer> baseResponse = new BaseResponse();
BaseResponse<Integer> baseResponse = new BaseResponse<>();
if (req.getId()>0) {
baseResponse.setData(degradeService.updateDegradeConfig(req));
} else {
... ... @@ -44,4 +44,13 @@ public class DegradeController {
return baseResponse;
}
@RequestMapping("/getFunction")
@ResponseBody
public BaseResponse getFunction(){
BaseResponse<List> baseResponse = new BaseResponse<>();
List<String> functions = degradeService.getFunction();
baseResponse.setData(functions);
return baseResponse;
}
}
... ...
... ... @@ -4,6 +4,8 @@ import com.monitor.model.domain.DegradeConfig;
import com.monitor.model.response.PageResponse;
import com.monitor.model.request.DegradeInfoReq;
import java.util.List;
/**
* Created by zhaoqi on 2016/8/26 0026.
*/
... ... @@ -14,4 +16,6 @@ public interface DegradeService {
int addDegradeConfig(DegradeInfoReq config);
int updateDegradeConfig(DegradeInfoReq config);
List<String> getFunction();
}
... ...
... ... @@ -13,9 +13,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
... ... @@ -38,7 +36,8 @@ public class DegradeServiceImpl implements DegradeService {
private static String QQ = "zookeeper_qq";
// 测试用
// private static String TEST = "zookeeper_205";
// private static String TEST205 = "zookeeper_205";
// private static String TEST211 = "zookeeper_211";
@Override
public PageResponse<DegradeConfig> getDegradeConfigList(DegradeInfoReq req) {
... ... @@ -71,6 +70,11 @@ public class DegradeServiceImpl implements DegradeService {
return degradeConfigMapper.updateByPrimaryKeySelective(degradeConfig);
}
@Override
public List<String> getFunction() {
return degradeConfigMapper.selectAllFunction();
}
private void modifyZkConfig(DegradeInfoReq req) {
ZkTreeAllReq zkTreeAllReq = new ZkTreeAllReq();
... ... @@ -85,9 +89,14 @@ public class DegradeServiceImpl implements DegradeService {
zkMoitorService.editZkMonitorDetail(zkTreeAllReq);
return ;
}
zkTreeAllReq.setIp(req.getCloudType());
// test
// zkTreeAllReq.setIp(TEST);
// // test
// if (req.getCloudType().equals(AWS)) {
// zkTreeAllReq.setIp(TEST205);
// } else {
// zkTreeAllReq.setIp(TEST211);
// }
zkMoitorService.editZkMonitorDetail(zkTreeAllReq);
}
... ... @@ -112,6 +121,7 @@ public class DegradeServiceImpl implements DegradeService {
config.setImgUrl(configDb.getImgUrl());
config.setId(configDb.getId());
config.setLevel(configDb.getLevel());
config.setFunctionPointName(configDb.getFunctionPointName());
break;
}
}
... ... @@ -149,6 +159,11 @@ public class DegradeServiceImpl implements DegradeService {
continue;
}
}
if (StringUtils.isNotBlank(req.getFunctionPointName())) {
if (!Objects.equals(degradeConfig.getFunctionPointName(), req.getFunctionPointName())) {
continue;
}
}
// 名称没有degrade的配置也不要
if (!degradeConfig.getConfigName().contains("degrade")) {
continue;
... ... @@ -187,8 +202,20 @@ public class DegradeServiceImpl implements DegradeService {
// 默认查询aws
cloudType = AWS;
}
// test
// cloudType = TEST;
// if (StringUtils.isNotBlank(req.getCloudType())) {
// if (req.getCloudType().equals(AWS)) {
// cloudType = TEST205;
// } else {
// cloudType = TEST211;
// }
// } else {
// cloudType = TEST205;
// }
return zkMoitorService.getAllChildren(cloudType,ZK_PATH);
}
}
... ...