mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-07-28 05:19:30 +08:00
Compare commits
No commits in common. "893ab3381109e38297cc2b68cc0cbdeb3a6e9178" and "877aec3b011cee930651e15c1088f6c02a062d6f" have entirely different histories.
893ab33811
...
877aec3b01
@ -129,7 +129,7 @@ public class HourController {
|
|||||||
String lockKey = String.format("record:%d", FCtx.getId());
|
String lockKey = String.format("record:%d", FCtx.getId());
|
||||||
boolean tryLock = redisDistributedLock.tryLock(lockKey, 5, TimeUnit.SECONDS);
|
boolean tryLock = redisDistributedLock.tryLock(lockKey, 5, TimeUnit.SECONDS);
|
||||||
if (!tryLock) {
|
if (!tryLock) {
|
||||||
return JsonResponse.success();
|
return JsonResponse.error("请稍后再试");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -166,7 +166,7 @@ public class HourController {
|
|||||||
String lockKey = String.format("ping:%d", FCtx.getId());
|
String lockKey = String.format("ping:%d", FCtx.getId());
|
||||||
boolean tryLock = redisDistributedLock.tryLock(lockKey, 5, TimeUnit.SECONDS);
|
boolean tryLock = redisDistributedLock.tryLock(lockKey, 5, TimeUnit.SECONDS);
|
||||||
if (!tryLock) {
|
if (!tryLock) {
|
||||||
return JsonResponse.success();
|
return JsonResponse.error("请稍后再试");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -18,7 +18,6 @@ package xyz.playedu.course.service.impl;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import xyz.playedu.common.types.paginate.PaginationResult;
|
import xyz.playedu.common.types.paginate.PaginationResult;
|
||||||
import xyz.playedu.common.types.paginate.UserCourseRecordPaginateFilter;
|
import xyz.playedu.common.types.paginate.UserCourseRecordPaginateFilter;
|
||||||
@ -145,7 +144,6 @@ public class UserCourseRecordServiceImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
|
||||||
public void updateUserCourseLearnProgress(Integer userId, Integer courseId, int count) {
|
public void updateUserCourseLearnProgress(Integer userId, Integer courseId, int count) {
|
||||||
UserCourseRecord record = find(userId, courseId);
|
UserCourseRecord record = find(userId, courseId);
|
||||||
if (record == null) {
|
if (record == null) {
|
||||||
@ -154,23 +152,18 @@ public class UserCourseRecordServiceImpl
|
|||||||
|
|
||||||
int finishedCount = record.getFinishedCount() - count;
|
int finishedCount = record.getFinishedCount() - count;
|
||||||
|
|
||||||
UserCourseRecord newRecord = new UserCourseRecord();
|
|
||||||
newRecord.setUserId(record.getUserId());
|
|
||||||
newRecord.setCourseId(record.getCourseId());
|
|
||||||
newRecord.setHourCount(record.getHourCount());
|
|
||||||
newRecord.setFinishedCount(finishedCount);
|
|
||||||
newRecord.setProgress(finishedCount * 10000 / record.getHourCount());
|
|
||||||
newRecord.setIsFinished(0);
|
|
||||||
newRecord.setCreatedAt(record.getCreatedAt());
|
|
||||||
newRecord.setUpdatedAt(new Date());
|
|
||||||
|
|
||||||
// 删除老记录
|
|
||||||
remove(query().getWrapper().eq("id", record.getId()));
|
|
||||||
|
|
||||||
if (0 == finishedCount) {
|
if (0 == finishedCount) {
|
||||||
|
remove(query().getWrapper().eq("id", record.getId()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
save(newRecord);
|
UserCourseRecord newRecord = new UserCourseRecord();
|
||||||
|
newRecord.setId(record.getId());
|
||||||
|
newRecord.setIsFinished(0);
|
||||||
|
newRecord.setFinishedAt(null);
|
||||||
|
newRecord.setProgress(finishedCount * 10000 / record.getHourCount());
|
||||||
|
newRecord.setFinishedCount(finishedCount);
|
||||||
|
|
||||||
|
updateById(newRecord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user