//3. 更新课表(课表学习小节数,课表状态,课表最近学习小节,课程最新学习时间) boolean success = lessonService.lambdaUpdate() .set(LearningLesson::getLatestSectionId, dto.getSectionId()) //最近学习小节 .set(LearningLesson::getLatestLearnTime, LocalDateTime.now()) //最新学习时间 .set(finished, LearningLesson::getLearnedSections, old.getLearnedSections() + 1) //课表学习小节数 .set(allLearned, LearningLesson::getStatus, LessonStatus.FINISHED) //如果全部学完了 更新课表状态为已经学完 .set(old.getStatus() == LessonStatus.NOT_BEGIN, LearningLesson::getStatus, LessonStatus.LEARNING) //如果整个课程是第一次学, 更新课表状态为学习中 .eq(LearningLesson::getId, old.getId()) .update(); if (!success) { throw new DbException("课表更新失败");
时间: 2024-04-16 10:28:30 浏览: 13
根据你提供的代码,看起来你想更新一个课表的相关信息。然而,在Java中,"=="操作符不能用于比较两个对象的值是否相等。你需要使用equals()方法来比较LessonStatus枚举类型的值。同时,lambdaUpdate()方法返回的是UpdateWrapper对象,你需要通过调用UpdateWrapper对象的lambdaSet()方法来设置更新字段。
以下是修改后的代码示例:
```java
boolean success = lessonService.lambdaUpdate()
.set(LearningLesson::getLatestSectionId, dto.getSectionId()) // 最近学习小节
.set(LearningLesson::getLatestLearnTime, LocalDateTime.now()) // 最新学习时间
.set(LearningLesson::getLearnedSections, old.getLearnedSections() + 1) // 课表学习小节数
.set(LearningLesson::getStatus, LessonStatus.FINISHED) // 如果全部学完了,更新课表状态为已经学完
.set(LearningLesson::getStatus, LessonStatus.LEARNING) // 如果整个课程是第一次学,更新课表状态为学习中
.eq(LearningLesson::getId, old.getId())
.update();
if (!success) {
throw new DbException("课表更新失败");
}
```
请注意,你需要根据你的实际需求调整代码中的字段和枚举类型。希望能对你有所帮助!如有更多问题,请继续提问。