فهرست منبع

修复河南:首页资讯

jinxia.mo 2 روز پیش
والد
کامیت
f2f4ffc803

+ 16 - 12
ie-admin/src/main/java/com/ruoyi/web/controller/front/FrontNewsController.java

@@ -72,10 +72,7 @@ public class FrontNewsController extends BaseController {
     @ApiOperation("00 通关指南")
     public TableDataInfo getMainList(@ApiParam(value = "省份 ", example = "湖南") @RequestParam(required = false) String location) {
         BWwwNewsRef cond = new BWwwNewsRef();
-        if(StringUtils.isBlank(location) && StringUtils.isBlank((location = VistorContextHolder.getLocation()))) {
-            cond.setLocation("湖南");
-        }
-        cond.setLocation(location);
+        cond.setLocation(getLocation(location));
         return getDataTable(newsRefService.selectBWwwNewsRefList(cond));
     }
 
@@ -83,7 +80,7 @@ public class FrontNewsController extends BaseController {
     @ApiOperation("00 通关指南免登陆")
     public TableDataInfo getMainListNoToken(@ApiParam(value = "省份 ", example = "湖南") @RequestParam(required = false) String location) {
         BWwwNewsRef cond = new BWwwNewsRef();
-        cond.setLocation(StringUtils.isNotBlank(location) ? location : "湖南");
+        cond.setLocation(getLocation(location));
         return getDataTable(newsRefService.selectBWwwNewsRefList(cond));
     }
 
@@ -110,26 +107,23 @@ public class FrontNewsController extends BaseController {
                               @ApiParam(value = "省份 ", example = "湖南") @RequestParam(required = false) String location,
                               @ApiParam(value = "页数", example = "1") @RequestParam Integer pageNum,
                               @ApiParam(value = "页大小", example = "15") @RequestParam Integer pageSize) {
-        if(StringUtils.isBlank(location)) {
-            location = VistorContextHolder.getLocation();
-        }
-        return llist(ids,top,type,tag,title,location, pageNum,pageSize);
+        return llist(ids,top,type,tag,title,getLocation(location), pageNum,pageSize);
     }
 
     private TableDataInfo llist(String ids,Boolean top,String type, String tag,String title,String location, Integer pageNum,Integer pageSize){
-        startPage();
         BWwwNews exam = new BWwwNews();
         exam.setIsTop(null==top?null:(top?1:0));
         exam.setType(type);
         exam.setTitle(title);
         exam.setTag(StringUtils.trimToNull(tag));
-        exam.setLocation(StringUtils.isNotBlank(location) ? location : "湖南");
+        exam.setLocation(getLocation(location));
         if(StringUtils.isNotBlank(ids)){
             String[] strArray = ids.split(",");
             List<String> strList = new ArrayList<>(strArray.length);
             Collections.addAll(strList, strArray);
             exam.setIds(strList);
         }
+        startPage();
         List<BWwwNews> arr = newsService.selectBWwwNewsList(exam);
         return getDataTable(arr);
     }
@@ -141,7 +135,7 @@ public class FrontNewsController extends BaseController {
                                      @ApiParam(value = "省份 ", example = "湖南") @RequestParam(required = false) String location,
                                      @ApiParam(value = "页数", example = "1") Integer pageNum,
                                      @ApiParam(value = "页大小", example = "15") Integer pageSize) {
-        return llist(ids,top,type,tag,title,location, pageNum,pageSize);
+        return llist(ids,top,type,tag,title,getLocation(location), pageNum,pageSize);
     }
 
     @GetMapping("info")
@@ -163,4 +157,14 @@ public class FrontNewsController extends BaseController {
         return AjaxResult.success(clicked);
     }
 
+    private String getLocation(String location){
+        if(StringUtils.isBlank(location)) {
+            location = VistorContextHolder.getLocation();
+        }
+        if (StringUtils.isBlank(location)) {
+            location = "湖南";
+        }
+        return location;
+    }
+
 }

+ 22 - 1
ie-common/src/main/java/com/ruoyi/common/core/content/VistorContextHolder.java

@@ -3,6 +3,10 @@ package com.ruoyi.common.core.content;
 
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.enums.ExamType;
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
 
 /**
  * 身份验证信息
@@ -33,6 +37,23 @@ public class VistorContextHolder
     }
 
     public static String getLocation() {
-        return getContext().getLocation();
+        SysUser context = getContext();
+        if (context == null) {
+            return null;
+        }
+        String location = context.getLocation();
+        if (StringUtils.isBlank(location)) {
+            return location;
+        }
+        // 如果 location 是 URL 编码的(包含 %),则进行解码
+        if (location.contains("%")) {
+            try {
+                return URLDecoder.decode(location, "UTF-8");
+            } catch (UnsupportedEncodingException e) {
+                // 如果解码失败,返回原始值
+                return location;
+            }
+        }
+        return location;
     }
 }