|
|
@@ -1,51 +0,0 @@
|
|
|
-package cn.reghao.devops.manager.home.controller;
|
|
|
-
|
|
|
-import cn.reghao.devops.manager.app.db.repository.config.AppConfigRepository;
|
|
|
-import cn.reghao.devops.manager.app.model.constant.AppType;
|
|
|
-import cn.reghao.devops.manager.app.model.po.config.AppConfig;
|
|
|
-import cn.reghao.devops.manager.home.model.NameValue;
|
|
|
-import cn.reghao.jutil.jdk.result.WebResult;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.data.domain.Page;
|
|
|
-import org.springframework.data.domain.PageRequest;
|
|
|
-import org.springframework.http.MediaType;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-/**
|
|
|
- * @author reghao
|
|
|
- * @date 2022-09-23 11:24:18
|
|
|
- */
|
|
|
-@Slf4j
|
|
|
-@Api(tags = "首页接口")
|
|
|
-@RequestMapping("/api/home")
|
|
|
-@RestController
|
|
|
-public class HomeController {
|
|
|
- private final AppConfigRepository appConfigRepository;
|
|
|
-
|
|
|
- public HomeController(AppConfigRepository appConfigRepository) {
|
|
|
- this.appConfigRepository = appConfigRepository;
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping(value = "/app", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- public String appStatistic(@RequestParam("env") String env) {
|
|
|
- PageRequest pageRequest = PageRequest.of(0, 1);
|
|
|
-
|
|
|
- List<NameValue> list = new ArrayList<>();
|
|
|
- for (AppType appType : AppType.values()) {
|
|
|
- String type = appType.getName();
|
|
|
- Page<AppConfig> page = appConfigRepository.findByEnvAndAppType(env, type, pageRequest);
|
|
|
- Long total = page.getTotalElements();
|
|
|
- if (total != 0) {
|
|
|
- list.add(new NameValue(type, total.intValue()));
|
|
|
- }
|
|
|
- }
|
|
|
- return WebResult.success(list);
|
|
|
- }
|
|
|
-}
|