|
|
|
@ -127,7 +127,7 @@ public class LearningRecordsServiceImpl extends ServiceImpl<LearningRecordsMappe |
|
|
|
|
throw new BusinessException(ErrorCode.PARAMS_ERROR); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
System.out.println("学习记录:"+learningRecords); |
|
|
|
|
// System.out.println("学习记录:"+learningRecords);
|
|
|
|
|
//查找该用户是否观看过该学习资源
|
|
|
|
|
LambdaQueryWrapper<LearningRecords> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
lambdaQueryWrapper |
|
|
|
@ -144,15 +144,16 @@ public class LearningRecordsServiceImpl extends ServiceImpl<LearningRecordsMappe |
|
|
|
|
learningRecords.setContent("img/v2-c57eb7863ec4233f503176ca3f90f8d5_1440w.png"); |
|
|
|
|
} |
|
|
|
|
List<LearningRecords> list = query().eq("courses_id", coursesId).eq("type", learningRecords.getType()).list(); |
|
|
|
|
int number; |
|
|
|
|
if (list != null){ |
|
|
|
|
number = list.get(0).getNumber() + 1; |
|
|
|
|
LearningRecords one1 = query().eq("courses_id", coursesId).eq("type", learningRecords.getType()).eq("user_id", userId).one(); |
|
|
|
|
int number = list.size(); |
|
|
|
|
//该用户是否学习过
|
|
|
|
|
if (one1 != null){//学习过观看人数不加
|
|
|
|
|
learningRecords.setNumber(number); |
|
|
|
|
list.forEach(learningRecords1 -> { |
|
|
|
|
learningRecords1.setNumber(number); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
number = 0; |
|
|
|
|
} else {//否则观看人数加1
|
|
|
|
|
learningRecords.setNumber(number + 1); |
|
|
|
|
} |
|
|
|
|
updateBatchById(list); |
|
|
|
|
if (count == 0){//如果没有就新增并记录学习方式是打开还是下载
|
|
|
|
|