Showing
6 changed files
with
123 additions
and
0 deletions
@@ -34,6 +34,10 @@ | @@ -34,6 +34,10 @@ | ||
34 | <artifactId>bcprov-jdk16</artifactId> | 34 | <artifactId>bcprov-jdk16</artifactId> |
35 | <version>1.46</version> | 35 | <version>1.46</version> |
36 | </dependency> | 36 | </dependency> |
37 | + <dependency> | ||
38 | + <groupId>monitor-service</groupId> | ||
39 | + <artifactId>monitor-service-cmdb</artifactId> | ||
40 | + </dependency> | ||
37 | 41 | ||
38 | </dependencies> | 42 | </dependencies> |
39 | 43 |
monitor-service-other/src/main/java/com/monitor/other/degrade/ctrl/DegradeController.java
0 → 100644
1 | +package com.monitor.other.degrade.ctrl; | ||
2 | + | ||
3 | +import com.monitor.model.page.PageResponse; | ||
4 | +import com.monitor.other.degrade.model.DegradeConfig; | ||
5 | +import com.monitor.other.degrade.model.DegradeReq; | ||
6 | +import com.monitor.other.degrade.service.DegradeService; | ||
7 | +import org.springframework.stereotype.Controller; | ||
8 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
9 | + | ||
10 | +import javax.annotation.Resource; | ||
11 | + | ||
12 | +/** | ||
13 | + * Created by zhaoqi on 2016/8/26 0026. | ||
14 | + */ | ||
15 | +@Controller | ||
16 | +@RequestMapping("/degrade") | ||
17 | +public class DegradeController { | ||
18 | + | ||
19 | + @Resource | ||
20 | + private DegradeService degradeService; | ||
21 | + | ||
22 | + private PageResponse<DegradeConfig> getDegradeConfigList(DegradeReq req){ | ||
23 | + PageResponse<DegradeConfig> pageResponse = new PageResponse<>(); | ||
24 | + pageResponse.setRows(degradeService.getDegradeConfigList(req)); | ||
25 | + return pageResponse; | ||
26 | + } | ||
27 | +} |
1 | +package com.monitor.other.degrade.model; | ||
2 | + | ||
3 | +import lombok.Data; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by zhaoqi on 2016/8/26 0026. | ||
7 | + */ | ||
8 | +@Data | ||
9 | +public class DegradeConfig { | ||
10 | + | ||
11 | + private String configName; | ||
12 | + | ||
13 | + private String configDesc; | ||
14 | + | ||
15 | + private String level; | ||
16 | + | ||
17 | + private String imgUrl; | ||
18 | + | ||
19 | + private String switcher; | ||
20 | + | ||
21 | +} |
monitor-service-other/src/main/java/com/monitor/other/degrade/service/DegradeService.java
0 → 100644
1 | +package com.monitor.other.degrade.service; | ||
2 | + | ||
3 | +import com.monitor.other.degrade.model.DegradeConfig; | ||
4 | +import com.monitor.other.degrade.model.DegradeReq; | ||
5 | + | ||
6 | +import java.util.List; | ||
7 | + | ||
8 | +/** | ||
9 | + * Created by zhaoqi on 2016/8/26 0026. | ||
10 | + */ | ||
11 | +public interface DegradeService { | ||
12 | + | ||
13 | + List<DegradeConfig> getDegradeConfigList(DegradeReq req); | ||
14 | + | ||
15 | +} |
monitor-service-other/src/main/java/com/monitor/other/degrade/service/impl/DegradeServiceImpl.java
0 → 100644
1 | +package com.monitor.other.degrade.service.impl; | ||
2 | + | ||
3 | +import com.monitor.cmdb.service.IZkMoitorService; | ||
4 | +import com.monitor.other.degrade.model.DegradeConfig; | ||
5 | +import com.monitor.other.degrade.model.DegradeReq; | ||
6 | +import com.monitor.other.degrade.service.DegradeService; | ||
7 | +import org.springframework.stereotype.Service; | ||
8 | + | ||
9 | +import javax.annotation.Resource; | ||
10 | +import java.util.List; | ||
11 | + | ||
12 | +/** | ||
13 | + * Created by zhaoqi on 2016/8/26 0026. | ||
14 | + */ | ||
15 | +@Service | ||
16 | +public class DegradeServiceImpl implements DegradeService { | ||
17 | + | ||
18 | + @Resource | ||
19 | + private IZkMoitorService zkMoitorService; | ||
20 | + | ||
21 | + @Override | ||
22 | + public List<DegradeConfig> getDegradeConfigList(DegradeReq req) { | ||
23 | + // 从zk中获取降级开关信息 | ||
24 | + List<DegradeConfig> configListZk= getFromZk(req); | ||
25 | + // 从数据库中获取附加信息 | ||
26 | + List<DegradeConfig> configListDb= getFromDatabase(req); | ||
27 | + | ||
28 | + return mergeDegradeConfig(configListZk,configListDb); | ||
29 | + } | ||
30 | + | ||
31 | + /** | ||
32 | + * 合并zk和数据库的结果 | ||
33 | + * @param configListZk | ||
34 | + * @param configListDb | ||
35 | + * @return | ||
36 | + */ | ||
37 | + private List<DegradeConfig> mergeDegradeConfig(List<DegradeConfig> configListZk, List<DegradeConfig> configListDb) { | ||
38 | + return null; | ||
39 | + } | ||
40 | + | ||
41 | + private List<DegradeConfig> getFromDatabase(DegradeReq req) { | ||
42 | + return null; | ||
43 | + } | ||
44 | + | ||
45 | + private List<DegradeConfig> getFromZk(DegradeReq req) { | ||
46 | + | ||
47 | + return null; | ||
48 | + } | ||
49 | +} |
-
Please register or login to post a comment