Selaa lähdekoodia

广告模块 语言返回

songfuqiang 1 vuosi sitten
vanhempi
commit
8da8a63f1a

+ 15 - 0
backend-core/src/main/java/cn/kdan/pdf/backend/core/enums/LanguageEnum.java

@@ -42,4 +42,19 @@ public enum LanguageEnum {
         return value;
     }
 
+    /**
+     * 通过code获取语言枚举
+     * @param value
+     * @return
+     */
+    public static LanguageEnum getLanguageByCode(Integer value){
+        LanguageEnum language = ZH_CN;
+        for (LanguageEnum languageEnum : LanguageEnum.values()) {
+            if(languageEnum.getValue().equals(value)){
+                language = languageEnum;
+            }
+        }
+        return language;
+    }
+
 }

+ 10 - 7
backend-core/src/main/java/cn/kdan/pdf/backend/core/service/impl/AdvertisementServiceImpl.java

@@ -31,11 +31,6 @@ public class AdvertisementServiceImpl implements AdvertisementService {
     @Autowired
     private OssProperties ossProperties;
 
-    /**
-     * 远程弹窗控制
-     */
-    private static final String POPUP_CONTROL = "popup control";
-
     @Override
     public List<AdvertisementVo> list(QueryAdvertisementParam param) {
         List<AdvertisementVo> result = new ArrayList<>();
@@ -60,9 +55,11 @@ public class AdvertisementServiceImpl implements AdvertisementService {
             AdvertisementVo vo = new AdvertisementVo();
             Advertisements adv = advertisementList.get(0);
             BeanUtils.copyProperties(adv,vo);
+            LanguageEnum languageEnum = LanguageEnum.getLanguageByCode(adv.getLanguage());
+            vo.setLanguage(languageEnum.getName());
             setExtraInfo(vo,adv);
             increaseHit(adv);
-            if(POPUP_CONTROL.equals(slug)){
+            if(StringUtils.isEmpty(adv.getImage())){
                 vo.setImageUrl("");
             } else{
                 vo.setImageUrl(viewUrl + adv.getImage());
@@ -72,7 +69,13 @@ public class AdvertisementServiceImpl implements AdvertisementService {
             for (Advertisements adv : advertisementList) {
                 AdvertisementVo vo = new AdvertisementVo();
                 BeanUtils.copyProperties(adv,vo);
-                vo.setImageUrl(viewUrl+adv.getImage());
+                LanguageEnum languageEnum = LanguageEnum.getLanguageByCode(adv.getLanguage());
+                vo.setLanguage(languageEnum.getName());
+                if(StringUtils.isEmpty(adv.getImage())){
+                    vo.setImageUrl("");
+                } else{
+                    vo.setImageUrl(viewUrl + adv.getImage());
+                }
                 setExtraInfo(vo,adv);
                 result.add(vo);
             }