ct 4 hari lalu
induk
melakukan
301db759e1

+ 19 - 6
fs-common/src/main/java/com/fs/common/core/redis/RedisCache.java

@@ -96,6 +96,25 @@ public class RedisCache
         if (value == null || clazz == null) {
             return null;
         }
+        // 数字类型优先转换:Fastjson 常把小 Long 反序列成 Integer,直接 cast 会 ClassCastException
+        if (clazz == Long.class && value instanceof Number) {
+            return (T) Long.valueOf(((Number) value).longValue());
+        }
+        if (clazz == Integer.class && value instanceof Number) {
+            return (T) Integer.valueOf(((Number) value).intValue());
+        }
+        if (clazz == Double.class && value instanceof Number) {
+            return (T) Double.valueOf(((Number) value).doubleValue());
+        }
+        if (clazz == Float.class && value instanceof Number) {
+            return (T) Float.valueOf(((Number) value).floatValue());
+        }
+        if (clazz == Short.class && value instanceof Number) {
+            return (T) Short.valueOf(((Number) value).shortValue());
+        }
+        if (clazz == Byte.class && value instanceof Number) {
+            return (T) Byte.valueOf(((Number) value).byteValue());
+        }
         if (clazz.isInstance(value)) {
             return clazz.cast(value);
         }
@@ -105,12 +124,6 @@ public class RedisCache
             r.putAll((Map<? extends String, ?>) value);
             return (T) r;
         }
-        if (clazz == Long.class && value instanceof Number) {
-            return (T) Long.valueOf(((Number) value).longValue());
-        }
-        if (clazz == Integer.class && value instanceof Number) {
-            return (T) Integer.valueOf(((Number) value).intValue());
-        }
         if (clazz == BigDecimal.class) {
             if (value instanceof BigDecimal) {
                 return (T) value;

+ 3 - 0
fs-user-app/src/main/java/com/fs/app/controller/course/CourseFsUserController.java

@@ -4,6 +4,7 @@ package com.fs.app.controller.course;
 
 import cn.hutool.core.util.ObjectUtil;
 import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fs.app.annotation.Anonymous;
 import com.fs.app.annotation.UserOperationLog;
 import com.fs.app.controller.AppBaseController;
 import com.fs.common.annotation.Log;
@@ -94,6 +95,7 @@ public class CourseFsUserController extends AppBaseController {
     }
 
 
+    @Anonymous
     @ApiOperation("h5课程简介")
     @GetMapping("/getH5CourseByVideoId")
     public R getCourseByVideoId(@RequestParam("videoId") Long videoId)
@@ -114,6 +116,7 @@ public class CourseFsUserController extends AppBaseController {
         return courseVideoService.getLinkCourseVideoDetails(param);
     }
 
+    @Anonymous
     @ApiOperation("获取真实链接")
     @GetMapping("/getRealLink")
     public R getRealLink(@RequestParam("sortLink")String link)

+ 7 - 5
fs-user-app/src/main/java/com/fs/app/controller/course/CourseQwController.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fs.app.annotation.Anonymous;
 import com.fs.app.annotation.Login;
 import com.fs.app.annotation.UserOperationLog;
 import com.fs.app.controller.AppBaseController;
@@ -132,6 +133,7 @@ public class CourseQwController extends AppBaseController {
       return R.ok().put("data",courseVideos);
     }
 
+    @Anonymous
     @ApiOperation("h5课程简介")
     @GetMapping("/getH5CourseByVideoId")
     public R getCourseByVideoId(@RequestParam("videoId") Long videoId,HttpServletRequest request)
@@ -202,12 +204,11 @@ public class CourseQwController extends AppBaseController {
 
             getGoodsAndShow(param,course);
 
-            //将视频时长也存到redis
+            //将视频时长也存到redis(兼容 Redis 反序列化为 Integer,避免 Integer→Long 强转失败)
             String videoRedisKey = "h5user:video:duration:" + param.getVideoId();
-            Long videoDuration = redisCache.getCacheObject(videoRedisKey, Long.class);
-            if (videoDuration==null){
-
-                redisCache.setCacheObject(videoRedisKey,course.getDuration());
+            Object videoDuration = redisCache.getCacheObject(videoRedisKey);
+            if (videoDuration == null && course.getDuration() != null) {
+                redisCache.setCacheObject(videoRedisKey, course.getDuration());
             }
             // 返回是否开启评论/弹幕。优先获取sop任务配置的是否开启评论/弹幕,如果没有配置就取总后台的配置;
             QwSop qwSop = qwSopService.selectQwSopById(log.getSopId());
@@ -340,6 +341,7 @@ public class CourseQwController extends AppBaseController {
         return courseVideoService.sendReward(param);
     }
 
+    @Anonymous
     @ApiOperation("获取真实链接")
     @GetMapping("/getRealLink")
     public R getRealLink(@RequestParam("sortLink")String link)

+ 3 - 0
fs-user-app/src/main/java/com/fs/app/controller/course/FeiShuCourseController.java

@@ -1,6 +1,7 @@
 package com.fs.app.controller.course;
 
 import cn.hutool.core.util.IdUtil;
+import com.fs.app.annotation.Anonymous;
 import com.fs.app.param.FeiShuGetInternetTrafficParam;
 import com.fs.app.param.FeiShuUpdateWatchDurationParam;
 import com.fs.feishu.util.SecureTokenUtil;
@@ -28,12 +29,14 @@ public class FeiShuCourseController {
     @Autowired
     private IFsUserCourseVideoService courseVideoService;
 
+    @Anonymous
     @ApiOperation("飞书获取唯一标识")
     @GetMapping("/getUniqueIdentifier")
     public R getUniqueIdentifier(@RequestParam("token") String token) {
         return R.ok().put("data", IdUtil.getSnowflake(0, 0).nextIdStr());
     }
 
+    @Anonymous
     @ApiOperation("飞书课程简介")
     @GetMapping("/getH5CourseByVideoId")
     public R getCourseByVideoId(@RequestParam("token") String token) {

+ 7 - 4
fs-user-app/src/main/java/com/fs/app/controller/store/CourseH5ScrmController.java

@@ -2,6 +2,7 @@ package com.fs.app.controller.store;
 
 
 import cn.hutool.json.JSONUtil;
+import com.fs.app.annotation.Anonymous;
 import com.fs.app.controller.AppBaseController;
 import com.fs.common.annotation.RepeatSubmit;
 import com.fs.common.core.domain.R;
@@ -52,6 +53,7 @@ public class CourseH5ScrmController extends AppBaseController {
     private IFsCourseQuestionBankService questionBankService;
 
 
+    @Anonymous
     @ApiOperation("h5课程简介")
     @GetMapping("/getH5CourseByVideoId")
     public R getCourseByVideoId(@RequestParam("videoId") Long videoId,HttpServletRequest request)
@@ -106,17 +108,18 @@ public class CourseH5ScrmController extends AppBaseController {
            isFinish=1;
         }
 
-        //将视频时长也存到redis
+        //将视频时长也存到redis(兼容 Redis 反序列化为 Integer)
         String videoRedisKey = "h5user:video:duration:" + param.getVideoId();
-        Long videoDuration = redisCache.getCacheObject(videoRedisKey, Long.class);
-        if (videoDuration==null){
-            redisCache.setCacheObject(videoRedisKey,course.getDuration());
+        Object videoDuration = redisCache.getCacheObject(videoRedisKey);
+        if (videoDuration == null && course.getDuration() != null) {
+            redisCache.setCacheObject(videoRedisKey, course.getDuration());
         }
 
         return R.ok().put("course",course).put("questions",questionVOList).put("config",config).put("playDuration",duration).put("tipsTime",tipsTime).put("maxBufferLength",config.getMaxBufferLength()).put("isFinish",isFinish);    }
 
 
 
+    @Anonymous
     @ApiOperation("获取真实链接")
     @GetMapping("/getRealLink")
     public R getRealLink(@RequestParam("sortLink")String link)

+ 7 - 4
fs-user-app/src/main/java/com/fs/app/controller/store/CourseScrmController.java

@@ -2,6 +2,7 @@ package com.fs.app.controller.store;
 
 
 import cn.hutool.json.JSONUtil;
+import com.fs.app.annotation.Anonymous;
 import com.fs.app.annotation.Login;
 import com.fs.app.controller.AppBaseController;
 import com.fs.common.annotation.RepeatSubmit;
@@ -337,6 +338,7 @@ public class CourseScrmController extends AppBaseController {
         return courseService.getIntegralByCourseVideo(param);
     }
 
+    @Anonymous
     @ApiOperation("h5课程简介")
     @GetMapping("/getH5CourseByVideoId")
     public R getCourseByVideoId(@RequestParam("videoId") Long videoId,HttpServletRequest request)
@@ -405,11 +407,11 @@ public class CourseScrmController extends AppBaseController {
             isFinish=1;
         }
 
-        //将视频时长也存到redis
+        //将视频时长也存到redis(兼容 Redis 反序列化为 Integer)
         String videoRedisKey = "h5user:video:duration:" + param.getVideoId();
-        Long videoDuration = redisCache.getCacheObject(videoRedisKey, Long.class);
-        if (videoDuration==null){
-            redisCache.setCacheObject(videoRedisKey,course.getDuration());
+        Object videoDuration = redisCache.getCacheObject(videoRedisKey);
+        if (videoDuration == null && course.getDuration() != null) {
+            redisCache.setCacheObject(videoRedisKey, course.getDuration());
         }
 
 
@@ -448,6 +450,7 @@ public class CourseScrmController extends AppBaseController {
         return courseVideoService.sendReward(param);
     }
 
+    @Anonymous
     @ApiOperation("获取真实链接")
     @GetMapping("/getRealLink")
     public R getRealLink(@RequestParam("sortLink")String link)

+ 3 - 0
fs-user-app/src/main/java/com/fs/app/controller/store/CourseWxH5ScrmController.java

@@ -1,6 +1,7 @@
 package com.fs.app.controller.store;
 
 
+import com.fs.app.annotation.Anonymous;
 import com.fs.app.annotation.Login;
 import com.fs.app.controller.AppBaseController;
 import com.fs.common.annotation.RepeatSubmit;
@@ -64,6 +65,7 @@ public class CourseWxH5ScrmController extends AppBaseController {
         return courseVideoService.isAddCompanyUser(param);
     }
 
+    @Anonymous
     @ApiOperation("h5课程简介")
     @GetMapping("/getH5CourseByVideoId")
     public R getCourseByVideoId(@RequestParam("videoId") Long videoId)
@@ -80,6 +82,7 @@ public class CourseWxH5ScrmController extends AppBaseController {
         return courseVideoService.getLinkCourseVideoDetails(param);
     }
 
+    @Anonymous
     @ApiOperation("获取真实链接")
     @GetMapping("/getRealLink")
     public R getRealLink(@RequestParam("sortLink")String link)