3 Commits

Author SHA1 Message Date
xxx
03403d2c33 fixed: github action 2023-11-15 15:00:35 +08:00
xxx
893ab33811 优化学员学习记录的错误提示 2023-11-15 14:00:34 +08:00
xxx
5e4c35f9bf fixed: userCourseRecord更新 2023-11-15 13:59:12 +08:00
3 changed files with 20 additions and 13 deletions

View File

@@ -38,7 +38,7 @@ jobs:
tags: |
${{ env.IMAGE_FQDN }}:${{ env.IMAGE_TAG }}
env:
IMAGE_TAG: ${{ startsWith(github.ref, 'refs/heads/main') && 'latest' || startsWith(github.ref, 'refs/heads/dev') && 'dev' || github.ref_slug }}
IMAGE_TAG: ${{ startsWith(github.ref, 'refs/heads/main') && 'latest' || startsWith(github.ref, 'refs/heads/dev') && 'dev' || github.ref_name }}
if: startsWith(github.ref, 'refs/heads/')
- name: Build with Tag
uses: docker/build-push-action@v3
@@ -47,5 +47,5 @@ jobs:
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.IMAGE_FQDN }}:${{ github.ref }}
${{ env.IMAGE_FQDN }}:${{ github.ref_name }}
if: startsWith(github.ref, 'refs/tags/')

View File

@@ -129,7 +129,7 @@ public class HourController {
String lockKey = String.format("record:%d", FCtx.getId());
boolean tryLock = redisDistributedLock.tryLock(lockKey, 5, TimeUnit.SECONDS);
if (!tryLock) {
return JsonResponse.error("请稍后再试");
return JsonResponse.success();
}
try {
@@ -166,7 +166,7 @@ public class HourController {
String lockKey = String.format("ping:%d", FCtx.getId());
boolean tryLock = redisDistributedLock.tryLock(lockKey, 5, TimeUnit.SECONDS);
if (!tryLock) {
return JsonResponse.error("请稍后再试");
return JsonResponse.success();
}
try {

View File

@@ -18,6 +18,7 @@ package xyz.playedu.course.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import xyz.playedu.common.types.paginate.PaginationResult;
import xyz.playedu.common.types.paginate.UserCourseRecordPaginateFilter;
@@ -144,6 +145,7 @@ public class UserCourseRecordServiceImpl
}
@Override
@Transactional
public void updateUserCourseLearnProgress(Integer userId, Integer courseId, int count) {
UserCourseRecord record = find(userId, courseId);
if (record == null) {
@@ -152,18 +154,23 @@ public class UserCourseRecordServiceImpl
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) {
remove(query().getWrapper().eq("id", record.getId()));
return;
}
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);
save(newRecord);
}
}