mirror of
https://github.com/PlayEdu/PlayEdu
synced 2026-01-10 16:01:45 +08:00
Compare commits
5 Commits
877aec3b01
...
1.5.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3b3e06a07 | ||
|
|
8e60deb3bc | ||
|
|
03403d2c33 | ||
|
|
893ab33811 | ||
|
|
5e4c35f9bf |
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@@ -38,7 +38,7 @@ jobs:
|
|||||||
tags: |
|
tags: |
|
||||||
${{ env.IMAGE_FQDN }}:${{ env.IMAGE_TAG }}
|
${{ env.IMAGE_FQDN }}:${{ env.IMAGE_TAG }}
|
||||||
env:
|
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/')
|
if: startsWith(github.ref, 'refs/heads/')
|
||||||
- name: Build with Tag
|
- name: Build with Tag
|
||||||
uses: docker/build-push-action@v3
|
uses: docker/build-push-action@v3
|
||||||
@@ -47,5 +47,5 @@ jobs:
|
|||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
${{ env.IMAGE_FQDN }}:${{ github.ref }}
|
${{ env.IMAGE_FQDN }}:${{ github.ref_name }}
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
|||||||
@@ -35,7 +35,3 @@
|
|||||||
- 保留页脚处版权信息。
|
- 保留页脚处版权信息。
|
||||||
- 保留源代码中的协议。
|
- 保留源代码中的协议。
|
||||||
- 如果修改了代码,则必须在文件中进行说明。
|
- 如果修改了代码,则必须在文件中进行说明。
|
||||||
|
|
||||||
● 允许
|
|
||||||
|
|
||||||
- 私用、商用、修改。
|
|
||||||
|
|||||||
@@ -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.error("请稍后再试");
|
return JsonResponse.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
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.error("请稍后再试");
|
return JsonResponse.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import java.util.*;
|
|||||||
import javax.naming.Context;
|
import javax.naming.Context;
|
||||||
import javax.naming.NamingEnumeration;
|
import javax.naming.NamingEnumeration;
|
||||||
import javax.naming.NamingException;
|
import javax.naming.NamingException;
|
||||||
|
import javax.naming.directory.Attribute;
|
||||||
import javax.naming.directory.Attributes;
|
import javax.naming.directory.Attributes;
|
||||||
import javax.naming.directory.SearchControls;
|
import javax.naming.directory.SearchControls;
|
||||||
import javax.naming.directory.SearchResult;
|
import javax.naming.directory.SearchResult;
|
||||||
@@ -148,7 +149,7 @@ public class LdapUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 唯一特征值
|
// 唯一特征值
|
||||||
String uSNCreated = (String) attributes.get("uSNCreated").get();
|
String uSNCreated = getAttribute(attributes, "uSNCreated");
|
||||||
if (StringUtil.isEmpty(uSNCreated)) {
|
if (StringUtil.isEmpty(uSNCreated)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -253,17 +254,16 @@ public class LdapUtil {
|
|||||||
ldapUser.setDn(item.getName());
|
ldapUser.setDn(item.getName());
|
||||||
|
|
||||||
// name解析
|
// name解析
|
||||||
String displayName = (String) attributes.get("displayName").get();
|
String displayName = getAttribute(attributes, "displayName");
|
||||||
if (StringUtil.isEmpty(displayName)) {
|
if (StringUtil.isEmpty(displayName)) {
|
||||||
displayName = (String) attributes.get("cn").get();
|
displayName = getAttribute(attributes, "cn");
|
||||||
}
|
}
|
||||||
ldapUser.setCn(displayName);
|
ldapUser.setCn(displayName);
|
||||||
|
|
||||||
// 邮箱解析
|
// 邮箱解析
|
||||||
String email =
|
String email = getAttribute(attributes, "mail");
|
||||||
attributes.get("mail") == null ? null : (String) attributes.get("mail").get();
|
if (StringUtil.isEmpty(email)) {
|
||||||
if (email == null) {
|
getAttribute(attributes, "email");
|
||||||
email = attributes.get("email") == null ? null : (String) attributes.get("email").get();
|
|
||||||
}
|
}
|
||||||
ldapUser.setEmail(email);
|
ldapUser.setEmail(email);
|
||||||
|
|
||||||
@@ -296,6 +296,15 @@ public class LdapUtil {
|
|||||||
return ldapUser;
|
return ldapUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getAttribute(Attributes attributes, String keyName)
|
||||||
|
throws NamingException {
|
||||||
|
Attribute attribute = attributes.get(keyName);
|
||||||
|
if (attribute == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return (String) attribute.get();
|
||||||
|
}
|
||||||
|
|
||||||
private static String baseDNOuScope(String baseDN) {
|
private static String baseDNOuScope(String baseDN) {
|
||||||
List<String> ouScopes = new ArrayList<>();
|
List<String> ouScopes = new ArrayList<>();
|
||||||
String[] rdnList = baseDN.toLowerCase().split(",");
|
String[] rdnList = baseDN.toLowerCase().split(",");
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ 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;
|
||||||
@@ -144,6 +145,7 @@ 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) {
|
||||||
@@ -152,18 +154,23 @@ public class UserCourseRecordServiceImpl
|
|||||||
|
|
||||||
int finishedCount = record.getFinishedCount() - count;
|
int finishedCount = record.getFinishedCount() - count;
|
||||||
|
|
||||||
if (0 == finishedCount) {
|
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()));
|
remove(query().getWrapper().eq("id", record.getId()));
|
||||||
|
|
||||||
|
if (0 == finishedCount) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
UserCourseRecord newRecord = new UserCourseRecord();
|
save(newRecord);
|
||||||
newRecord.setId(record.getId());
|
|
||||||
newRecord.setIsFinished(0);
|
|
||||||
newRecord.setFinishedAt(null);
|
|
||||||
newRecord.setProgress(finishedCount * 10000 / record.getHourCount());
|
|
||||||
newRecord.setFinishedCount(finishedCount);
|
|
||||||
|
|
||||||
updateById(newRecord);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user