Showing
6 changed files
with
58 additions
and
5 deletions
1 | -package com.monitor.other.degrade.model; | 1 | +package com.monitor.model.domain; |
2 | 2 | ||
3 | import lombok.Data; | 3 | import lombok.Data; |
4 | 4 | ||
@@ -8,6 +8,8 @@ import lombok.Data; | @@ -8,6 +8,8 @@ import lombok.Data; | ||
8 | @Data | 8 | @Data |
9 | public class DegradeConfig { | 9 | public class DegradeConfig { |
10 | 10 | ||
11 | + private int id; | ||
12 | + | ||
11 | private String configName; | 13 | private String configName; |
12 | 14 | ||
13 | private String configDesc; | 15 | private String configDesc; |
1 | +package com.monitor.mysql.mapper; | ||
2 | + | ||
3 | +import com.monitor.model.domain.DegradeConfig; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by zhaoqi on 2016/8/26 0026. | ||
7 | + */ | ||
8 | +public interface DegradeInfoMapper { | ||
9 | + void insertDegradeConfig(DegradeConfig config); | ||
10 | + | ||
11 | + void updateDegradeConfig(DegradeConfig config); | ||
12 | +} |
1 | package com.monitor.other.degrade.ctrl; | 1 | package com.monitor.other.degrade.ctrl; |
2 | 2 | ||
3 | import com.monitor.model.page.PageResponse; | 3 | import com.monitor.model.page.PageResponse; |
4 | -import com.monitor.other.degrade.model.DegradeConfig; | 4 | +import com.monitor.model.response.BaseResponse; |
5 | +import com.monitor.model.domain.DegradeConfig; | ||
5 | import com.monitor.other.degrade.model.DegradeReq; | 6 | import com.monitor.other.degrade.model.DegradeReq; |
6 | import com.monitor.other.degrade.service.DegradeService; | 7 | import com.monitor.other.degrade.service.DegradeService; |
7 | import org.springframework.stereotype.Controller; | 8 | import org.springframework.stereotype.Controller; |
@@ -19,9 +20,25 @@ public class DegradeController { | @@ -19,9 +20,25 @@ public class DegradeController { | ||
19 | @Resource | 20 | @Resource |
20 | private DegradeService degradeService; | 21 | private DegradeService degradeService; |
21 | 22 | ||
22 | - private PageResponse<DegradeConfig> getDegradeConfigList(DegradeReq req){ | 23 | + @RequestMapping("/getList") |
24 | + public PageResponse<DegradeConfig> getDegradeConfigList(DegradeReq req){ | ||
23 | PageResponse<DegradeConfig> pageResponse = new PageResponse<>(); | 25 | PageResponse<DegradeConfig> pageResponse = new PageResponse<>(); |
24 | pageResponse.setRows(degradeService.getDegradeConfigList(req)); | 26 | pageResponse.setRows(degradeService.getDegradeConfigList(req)); |
25 | return pageResponse; | 27 | return pageResponse; |
26 | } | 28 | } |
29 | + | ||
30 | + @RequestMapping("/add") | ||
31 | + public BaseResponse addDegradeConfig(DegradeConfig config){ | ||
32 | + BaseResponse baseResponse = new BaseResponse(); | ||
33 | + degradeService.addDegradeConfig(config); | ||
34 | + return baseResponse; | ||
35 | + } | ||
36 | + | ||
37 | + @RequestMapping("/update") | ||
38 | + public BaseResponse updateDegradeConfig(DegradeConfig config){ | ||
39 | + BaseResponse baseResponse = new BaseResponse(); | ||
40 | + degradeService.updateDegradeConfig(config); | ||
41 | + return baseResponse; | ||
42 | + } | ||
43 | + | ||
27 | } | 44 | } |
1 | package com.monitor.other.degrade.service; | 1 | package com.monitor.other.degrade.service; |
2 | 2 | ||
3 | -import com.monitor.other.degrade.model.DegradeConfig; | 3 | +import com.monitor.model.domain.DegradeConfig; |
4 | import com.monitor.other.degrade.model.DegradeReq; | 4 | import com.monitor.other.degrade.model.DegradeReq; |
5 | 5 | ||
6 | import java.util.List; | 6 | import java.util.List; |
@@ -12,4 +12,7 @@ public interface DegradeService { | @@ -12,4 +12,7 @@ public interface DegradeService { | ||
12 | 12 | ||
13 | List<DegradeConfig> getDegradeConfigList(DegradeReq req); | 13 | List<DegradeConfig> getDegradeConfigList(DegradeReq req); |
14 | 14 | ||
15 | + void addDegradeConfig(DegradeConfig config); | ||
16 | + | ||
17 | + void updateDegradeConfig(DegradeConfig config); | ||
15 | } | 18 | } |
1 | package com.monitor.other.degrade.service.impl; | 1 | package com.monitor.other.degrade.service.impl; |
2 | 2 | ||
3 | import com.monitor.cmdb.service.IZkMoitorService; | 3 | import com.monitor.cmdb.service.IZkMoitorService; |
4 | -import com.monitor.other.degrade.model.DegradeConfig; | 4 | +import com.monitor.mysql.mapper.DegradeInfoMapper; |
5 | +import com.monitor.model.domain.DegradeConfig; | ||
5 | import com.monitor.other.degrade.model.DegradeReq; | 6 | import com.monitor.other.degrade.model.DegradeReq; |
6 | import com.monitor.other.degrade.service.DegradeService; | 7 | import com.monitor.other.degrade.service.DegradeService; |
7 | import org.springframework.stereotype.Service; | 8 | import org.springframework.stereotype.Service; |
@@ -18,6 +19,9 @@ public class DegradeServiceImpl implements DegradeService { | @@ -18,6 +19,9 @@ public class DegradeServiceImpl implements DegradeService { | ||
18 | @Resource | 19 | @Resource |
19 | private IZkMoitorService zkMoitorService; | 20 | private IZkMoitorService zkMoitorService; |
20 | 21 | ||
22 | + @Resource | ||
23 | + private DegradeInfoMapper degradeInfoMapper; | ||
24 | + | ||
21 | @Override | 25 | @Override |
22 | public List<DegradeConfig> getDegradeConfigList(DegradeReq req) { | 26 | public List<DegradeConfig> getDegradeConfigList(DegradeReq req) { |
23 | // 从zk中获取降级开关信息 | 27 | // 从zk中获取降级开关信息 |
@@ -28,6 +32,16 @@ public class DegradeServiceImpl implements DegradeService { | @@ -28,6 +32,16 @@ public class DegradeServiceImpl implements DegradeService { | ||
28 | return mergeDegradeConfig(configListZk,configListDb); | 32 | return mergeDegradeConfig(configListZk,configListDb); |
29 | } | 33 | } |
30 | 34 | ||
35 | + @Override | ||
36 | + public void addDegradeConfig(DegradeConfig config) { | ||
37 | + degradeInfoMapper.insertDegradeConfig(config); | ||
38 | + } | ||
39 | + | ||
40 | + @Override | ||
41 | + public void updateDegradeConfig(DegradeConfig config) { | ||
42 | + degradeInfoMapper.updateDegradeConfig(config); | ||
43 | + } | ||
44 | + | ||
31 | /** | 45 | /** |
32 | * 合并zk和数据库的结果 | 46 | * 合并zk和数据库的结果 |
33 | * @param configListZk | 47 | * @param configListZk |
-
Please register or login to post a comment