Compare commits

..

29 Commits

Author SHA1 Message Date
yang
6dadd80372 代码审计-spring 2024-08-29 16:48:54 +08:00
yang
04a4f528bf 代码审计-tomcat 2024-08-29 16:18:24 +08:00
yang
f7cd9f8469 代码审计-spring、snakeyaml 2024-08-29 15:15:05 +08:00
yang
1021f0bd43 代码审计-spring 2024-08-28 15:00:21 +08:00
yang
0d0b45f017 代码审计-Commons Text、tomcat 2024-08-27 21:14:52 +08:00
nisen
2ae3d99f21 Merge branch 'zcwy0823-llf' into master-0705 2024-08-23 19:44:02 +08:00
zhaolongfei
89573debef 在线课考试添加任务计算,redis放开 2024-08-23 19:43:18 +08:00
nisen
457597eabc Merge branch 'zcwy0823-llf' into master-0705 2024-08-23 19:28:25 +08:00
zhaolongfei
24ae3c0ec6 在线课考试添加任务计算,暂时注释redis 2024-08-23 19:27:31 +08:00
zhaolongfei
fffa12344a 在线课考试添加任务计算,回退 2024-08-23 18:54:38 +08:00
nisen
52a58a6c6f Merge branch 'zcwy0823-llf' into master-0705 2024-08-23 18:45:46 +08:00
zhaolongfei
a4b034752d 在线课考试添加任务计算 2024-08-23 18:45:10 +08:00
nisen
23e63062e9 Merge branch 'zcwy0823-llf' into master-0705 2024-08-23 18:30:42 +08:00
zhaolongfei
06415d58ac 在线课考试添加任务计算 2024-08-23 18:30:05 +08:00
nisen
3fc8ce614d Merge branch 'zcwy0823-llf' into master-0705 2024-08-23 18:00:57 +08:00
zhaolongfei
bebe36d39e 在线课考试添加任务计算 2024-08-23 18:00:26 +08:00
nisen
d4af5ba8d5 Merge branch 'zcwy0823-llf' into master-0705 2024-08-23 17:59:12 +08:00
zhaolongfei
d42d1b2e83 处理study接口,添加接口访问限制次数 2024-08-23 17:55:53 +08:00
nisen
cf64f0406f Merge branch 'zcwy0815-llf' into master-0705 2024-08-15 20:20:14 +08:00
nisen
f5ff666c07 Merge branch 'zcwy0815-llf' into master-0705 2024-08-15 19:57:23 +08:00
670788339
61754d3852 放开redis 2024-08-15 16:26:47 +08:00
670788339
a26ee1c707 放开注释 2024-08-15 15:42:45 +08:00
670788339
1f0060c4dc 放开注释 2024-08-15 15:27:41 +08:00
670788339
6b0050286c 放开注释 2024-08-15 15:19:59 +08:00
670788339
2b07029aca 注释 2024-08-15 12:09:40 +08:00
670788339
d2d7fab96c 注释 2024-08-15 12:03:05 +08:00
670788339
be3bae969c study接口加redis过滤 2024-08-15 11:35:02 +08:00
670788339
8e1b7519ef study接口加redis过滤 2024-08-15 11:31:17 +08:00
670788339
bddb11caf8 study接口加redis过滤 2024-08-15 10:53:26 +08:00
4 changed files with 80 additions and 28 deletions

View File

@@ -84,6 +84,7 @@
<artifactId>xboe-module-es</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>it.sauronsoftware</groupId>
<artifactId>jave</artifactId>
@@ -232,6 +233,31 @@
<artifactId>spring-retry</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.3.26</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.10.0</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>9.0.83</version>
</dependency>
</dependencies>
<build>
<resources>

View File

@@ -133,6 +133,4 @@ public interface CacheName {
* 字典缓存key
* */
String KEY_DICT="dict";
String STUDY_KEY = "StudyKey:";
}

View File

@@ -3,12 +3,16 @@ package com.xboe.school.study.api;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.alibaba.nacos.shaded.com.google.common.util.concurrent.RateLimiter;
import cn.hutool.core.util.ArrayUtil;
import com.xboe.api.ThirdApi;
import com.xboe.constants.CacheName;
import com.xboe.api.vo.*;
import com.xboe.module.course.vo.TeacherVo;
import com.xboe.module.usergroup.entity.UserGroupItem;
import com.xboe.module.usergroup.service.IUserGroupService;
import com.xboe.school.study.dao.StudyCourseDao;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
@@ -63,6 +67,8 @@ import javax.servlet.http.HttpServletRequest;
@RequestMapping(value="/xboe/school/study/course")
public class StudyCourseApi extends ApiBaseController{
@Autowired
IStudyCourseService service;
@@ -92,6 +98,7 @@ public class StudyCourseApi extends ApiBaseController{
@Autowired
StringRedisTemplate redisTemplate;
/**
* 用于查询课程的学习记录
* @param pager
@@ -283,7 +290,11 @@ public class StudyCourseApi extends ApiBaseController{
}
/**
* 记录学习信息,在学习每个资源时都要记录.前端用户打开课程资源按规则调用带着课程及学习信息调用此接口。
* @param
* @return 返回学习条目的id
*/
@PostMapping("/study")
public JsonResponse<String> study(@RequestBody StudyContentDto sci, HttpServletRequest request){
@@ -313,32 +324,29 @@ public class StudyCourseApi extends ApiBaseController{
if (StringUtils.isEmpty(token)) {
token = request.getHeader("token");
}
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
if(item!=null) {
String studyKey = CacheName.NAME_AUTH + ":" + CacheName.STUDY_KEY + item.getCourseId()+":"+cuser.getAccountId()+":"+item.getContentId();
String studyKey2 = CacheName.NAME_AUTH + ":" + CacheName.STUDY_KEY + sci.getCourseId()+":"+cuser.getAccountId()+":"+sci.getContentId();
redisTemplate.opsForValue().set(studyKey,
String.valueOf(item.getProgress()), 2, TimeUnit.HOURS);
String progressStr = redisTemplate.opsForValue().get(studyKey2);
if (progressStr != null && !progressStr.isEmpty()) {
// 尝试将 Redis 中的字符串转换为整数
int redisProgress = Integer.parseInt(progressStr);
// 假设 item.getProgress() 返回的是 int 类型
int sciProgress = sci.getProgress();
if (redisProgress < sciProgress && redisProgress < 100) {
// 执行一些操作
// if(item.getProgress()<100 && sci.getProgress()>item.getProgress()) {
//检查是否已存在
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
// 20240815 特训营结营考试 临时代码
// if(item != null && redisTemplate.opsForValue().get(item.getId())==null){
// redisTemplate.opsForValue().set(item.getId(),item.getId());
// //设置过期时间为1天
// redisTemplate.expire(item.getId(), 60, TimeUnit.SECONDS);
// }else{
// return success("");
// }
if(item!=null) {
//如果记录存在但是进度不100无成情况就更新进度一期不会有这种情况
if(item.getProgress()<100 && sci.getProgress()>item.getProgress()) {
studyService.updateProcess(item.getId(), sci.getStudyId(), sci.getCourseId(), sci.getContentTotal(), sci.getProgress(),token);
}
}
//追加学习时长
studyService.appendStudyDuration(sci.getStudyId(),item.getId(),sci.getContentId(),sci.getDuration());
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(sci.getStudyId() ,sci.getCourseId(), token);
log.info("在线课学习记录"+allUserList);
return success(item.getId());
//如果记录存在但是进度不100无成情况就更新进度一期不会有这种情况
}
if(StringUtils.isBlank(sci.getCourseId())){
@@ -413,6 +421,14 @@ public class StudyCourseApi extends ApiBaseController{
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
if(item!=null) {
//如果记录存在但是进度不到100未完成情况就更新进度一期不会有这种情况
// 20240815 特训营结营考试 临时代码
// if(item != null && redisTemplate.opsForValue().get(item.getId())==null){
// redisTemplate.opsForValue().set(item.getId(),item.getId());
// //设置过期时间为1天
// redisTemplate.expire(item.getId(), 60, TimeUnit.SECONDS);
// }else{
// return success("");
// }
if(item.getProgress()<100) {
studyService.updateProcess(item.getId(),sci.getStudyId(),sci.getCourseId(), sci.getContentTotal(),100,token);
}
@@ -518,6 +534,14 @@ public class StudyCourseApi extends ApiBaseController{
token = request.getHeader("token");
}
try {
// 20240815 特训营结营考试 临时代码
// if(itemId != null && redisTemplate.opsForValue().get(itemId)==null){
// redisTemplate.opsForValue().set(itemId,itemId);
// //设置过期时间为1天
// redisTemplate.expire(itemId, 60, TimeUnit.SECONDS);
// }else{
// return success(true);
// }
studyService.finishVideoStudyItem(itemId, studyId,courseId,cnum,token);
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(studyId ,courseId, token);
log.info("在线课学习记录"+allUserList);
@@ -700,8 +724,9 @@ public class StudyCourseApi extends ApiBaseController{
}
}
@RequestMapping(value="/study-course-content",method = {RequestMethod.GET,RequestMethod.POST})
public JsonResponse<StudyCourseItem> findStudyCourseItem(String studyId,String contentId){
public JsonResponse<StudyCourseItem> findStudyCourseItem(String studyId,String contentId, HttpServletRequest request){
if(StringUtils.isBlank(studyId)){
return error("无学习信息");
}

View File

@@ -7,6 +7,7 @@ import java.util.Map;
import java.util.concurrent.TimeUnit;
import com.xboe.api.ThirdApi;
import com.xboe.school.study.dao.StudyCourseDao;
import com.xboe.school.study.entity.StudyCourse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -32,6 +33,8 @@ import javax.servlet.http.HttpServletRequest;
@RestController
@RequestMapping(value="/xboe/school/study/exam")
public class StudyExamApi extends ApiBaseController{
@Autowired
StudyCourseDao scDao;
@Autowired
IStudyExamService sexamService;