Authored by zhaoqi

降级服务后台接口

package com.monitor.other.degrade.model;
package com.monitor.model.domain;
import lombok.Data;
... ... @@ -8,6 +8,8 @@ import lombok.Data;
@Data
public class DegradeConfig {
private int id;
private String configName;
private String configDesc;
... ...
package com.monitor.mysql.mapper;
import com.monitor.model.domain.DegradeConfig;
/**
* Created by zhaoqi on 2016/8/26 0026.
*/
public interface DegradeInfoMapper {
void insertDegradeConfig(DegradeConfig config);
void updateDegradeConfig(DegradeConfig config);
}
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.monitor.mysql.mapper.DegradeInfoMapper" >
</mapper>
\ No newline at end of file
... ...
package com.monitor.other.degrade.ctrl;
import com.monitor.model.page.PageResponse;
import com.monitor.other.degrade.model.DegradeConfig;
import com.monitor.model.response.BaseResponse;
import com.monitor.model.domain.DegradeConfig;
import com.monitor.other.degrade.model.DegradeReq;
import com.monitor.other.degrade.service.DegradeService;
import org.springframework.stereotype.Controller;
... ... @@ -19,9 +20,25 @@ public class DegradeController {
@Resource
private DegradeService degradeService;
private PageResponse<DegradeConfig> getDegradeConfigList(DegradeReq req){
@RequestMapping("/getList")
public PageResponse<DegradeConfig> getDegradeConfigList(DegradeReq req){
PageResponse<DegradeConfig> pageResponse = new PageResponse<>();
pageResponse.setRows(degradeService.getDegradeConfigList(req));
return pageResponse;
}
@RequestMapping("/add")
public BaseResponse addDegradeConfig(DegradeConfig config){
BaseResponse baseResponse = new BaseResponse();
degradeService.addDegradeConfig(config);
return baseResponse;
}
@RequestMapping("/update")
public BaseResponse updateDegradeConfig(DegradeConfig config){
BaseResponse baseResponse = new BaseResponse();
degradeService.updateDegradeConfig(config);
return baseResponse;
}
}
... ...
package com.monitor.other.degrade.service;
import com.monitor.other.degrade.model.DegradeConfig;
import com.monitor.model.domain.DegradeConfig;
import com.monitor.other.degrade.model.DegradeReq;
import java.util.List;
... ... @@ -12,4 +12,7 @@ public interface DegradeService {
List<DegradeConfig> getDegradeConfigList(DegradeReq req);
void addDegradeConfig(DegradeConfig config);
void updateDegradeConfig(DegradeConfig config);
}
... ...
package com.monitor.other.degrade.service.impl;
import com.monitor.cmdb.service.IZkMoitorService;
import com.monitor.other.degrade.model.DegradeConfig;
import com.monitor.mysql.mapper.DegradeInfoMapper;
import com.monitor.model.domain.DegradeConfig;
import com.monitor.other.degrade.model.DegradeReq;
import com.monitor.other.degrade.service.DegradeService;
import org.springframework.stereotype.Service;
... ... @@ -18,6 +19,9 @@ public class DegradeServiceImpl implements DegradeService {
@Resource
private IZkMoitorService zkMoitorService;
@Resource
private DegradeInfoMapper degradeInfoMapper;
@Override
public List<DegradeConfig> getDegradeConfigList(DegradeReq req) {
// 从zk中获取降级开关信息
... ... @@ -28,6 +32,16 @@ public class DegradeServiceImpl implements DegradeService {
return mergeDegradeConfig(configListZk,configListDb);
}
@Override
public void addDegradeConfig(DegradeConfig config) {
degradeInfoMapper.insertDegradeConfig(config);
}
@Override
public void updateDegradeConfig(DegradeConfig config) {
degradeInfoMapper.updateDegradeConfig(config);
}
/**
* 合并zk和数据库的结果
* @param configListZk
... ...