|
|
@@ -17,6 +17,7 @@ import com.fs.live.mapper.LiveCompletionPointsRecordMapper;
|
|
|
import com.fs.live.service.ILiveCompletionPointsRecordService;
|
|
|
import com.fs.live.service.ILiveService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
@@ -181,6 +182,7 @@ public class LiveCompletionPointsController extends AppBaseController {
|
|
|
* 更新用户看课completionPointsRecordService看课记录里面的时长
|
|
|
*/
|
|
|
@PostMapping("/update-watch-duration")
|
|
|
+ @Transactional
|
|
|
public R updateWatchDuration(@RequestParam Long liveId, @RequestParam Long watchDuration) {
|
|
|
Long userId = Long.parseLong(getUserId());
|
|
|
|
|
|
@@ -251,6 +253,8 @@ public class LiveCompletionPointsController extends AppBaseController {
|
|
|
if (record == null) {
|
|
|
// 如果没有记录,先创建记录
|
|
|
record = completionPointsRecordService.createCompletionRecord(liveId, userId);
|
|
|
+ record.setWatchDuration(finalWatchDuration);
|
|
|
+ completionPointsRecordMapper.updateRecord(record);
|
|
|
} else {
|
|
|
// 更新现有记录的看课时长
|
|
|
Long currentWatchDuration = record.getWatchDuration() != null
|
|
|
@@ -269,7 +273,10 @@ public class LiveCompletionPointsController extends AppBaseController {
|
|
|
record.setCompletionRate(completionRate);
|
|
|
}
|
|
|
|
|
|
- completionPointsRecordMapper.updateRecord(record);
|
|
|
+ int updateResult = completionPointsRecordMapper.updateRecord(record);
|
|
|
+ if (updateResult <= 0) {
|
|
|
+ return R.error("更新看课时间失败");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
UpdateWatchDurationVO vo = new UpdateWatchDurationVO();
|