Browse Source

私有云的应用类型的图片信息通过配置项加图片url拼接访问

guo00guo 4 years ago
parent
commit
2c09e551c1

BIN
http:/mooctest-crowd-service.oss-cn-hangzhou.aliyuncs.comImage/14_79a50557-7d9b-4591-b7e6-0897a720446b_1609832754760.png


+ 25 - 6
site/src/main/java/com/mooctest/crowd/site/mediator/impl/WebMediatorImpl.java

@@ -27,6 +27,7 @@ import org.codehaus.jettison.json.JSONException;
 import org.jetbrains.annotations.NotNull;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Component;
@@ -129,6 +130,13 @@ public class WebMediatorImpl implements ViewMediator {
     @Autowired
     private EndPointDao endPointDao;
 
+
+    @Value("${file.save.path}")
+    private String fileSaveRootPath;
+
+    @Value("${feature.client.oss}")
+    private Boolean usingOss;
+
     @Override
     public List<CrowdTestProjectVO> crowdTestProjects() {
         List<CrowdTestProjectVO> authingList = new ArrayList<>();
@@ -501,12 +509,23 @@ public class WebMediatorImpl implements ViewMediator {
     @NotNull
     public List<ApplicationTypeVO> getApplicationTypeRankVOS(Pageable pageable) {
         //获取热门众测
-        return projectDao.findTotalCountOfApplicationType(pageable).stream().map(rankInfos -> {
-            ApplicationType applicationType = commonRepo.getApplicationTypeByAppCode(rankInfos.getCode());
-            ApplicationTypeVO applicationTypeVO = new ApplicationTypeVO(applicationType);
-            applicationTypeVO.setCount(rankInfos.getCount());
-            return applicationTypeVO;
-        }).filter(Objects::nonNull).collect(Collectors.toList());
+        if(usingOss){
+            return projectDao.findTotalCountOfApplicationType(pageable).stream().map(rankInfos -> {
+                ApplicationType applicationType = commonRepo.getApplicationTypeByAppCode(rankInfos.getCode());
+                ApplicationTypeVO applicationTypeVO = new ApplicationTypeVO(applicationType);
+                applicationTypeVO.setCount(rankInfos.getCount());
+                return applicationTypeVO;
+            }).filter(Objects::nonNull).collect(Collectors.toList());
+        }else{
+            return projectDao.findTotalCountOfApplicationType(pageable).stream().map(rankInfos -> {
+                ApplicationType applicationType = commonRepo.getApplicationTypeByAppCode(rankInfos.getCode());
+                ApplicationTypeVO applicationTypeVO = new ApplicationTypeVO(applicationType);
+                applicationTypeVO.setCount(rankInfos.getCount());
+                applicationTypeVO.setImage(fileSaveRootPath + applicationType.getImage());
+                return applicationTypeVO;
+            }).filter(Objects::nonNull).collect(Collectors.toList());
+        }
+
     }
 
     @Override

+ 4 - 0
site/src/main/resources/application.yml

@@ -153,6 +153,10 @@ feature:
   client:
     oss: true
 
+file:
+  save:
+    path: http://mooctest-crowd-service.oss-cn-hangzhou.aliyuncs.com/
+
 user:
   service:
     #    baseUrl: http://127.0.0.1:8081