|
@@ -9,6 +9,7 @@ import com.fs.course.domain.FsUserCourseVideo;
|
|
|
import com.fs.course.mapper.FsCourseLinkMapper;
|
|
import com.fs.course.mapper.FsCourseLinkMapper;
|
|
|
import com.fs.course.mapper.FsUserCourseVideoMapper;
|
|
import com.fs.course.mapper.FsUserCourseVideoMapper;
|
|
|
import com.fs.feishu.model.FeishuLinkParam;
|
|
import com.fs.feishu.model.FeishuLinkParam;
|
|
|
|
|
+import com.fs.feishu.util.FeishuErrorCode;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import com.lark.oapi.Client;
|
|
import com.lark.oapi.Client;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -82,7 +83,6 @@ public class FeiShuService {
|
|
|
}
|
|
}
|
|
|
throw new CustomException("所有飞书账号均不可用,请联系管理员");
|
|
throw new CustomException("所有飞书账号均不可用,请联系管理员");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 002 生成飞书课程链接
|
|
* 002 生成飞书课程链接
|
|
|
* 相同参数可能重复,使用 Redis 缓存避免重复创建文档
|
|
* 相同参数可能重复,使用 Redis 缓存避免重复创建文档
|
|
@@ -107,14 +107,17 @@ public class FeiShuService {
|
|
|
if (userCourseVideo == null) {
|
|
if (userCourseVideo == null) {
|
|
|
throw new CustomException("视频不存在: " + param.getVideoId());
|
|
throw new CustomException("视频不存在: " + param.getVideoId());
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ //获取该视频是否有答题
|
|
|
|
|
+ String questionBankId = userCourseVideo.getQuestionBankId();
|
|
|
|
|
+ boolean hasQuestion = StringUtils.isNotBlank(questionBankId) && !"null".equals(questionBankId);
|
|
|
|
|
+ Integer questionFlag = hasQuestion ? 1 : 0;//0:无题 1:有题
|
|
|
int maxRetries = clientPool.getAvailableCount();
|
|
int maxRetries = clientPool.getAvailableCount();
|
|
|
for (int i = 0; i < maxRetries; i++) {
|
|
for (int i = 0; i < maxRetries; i++) {
|
|
|
Client client = clientPool.getClient();
|
|
Client client = clientPool.getClient();
|
|
|
try {
|
|
try {
|
|
|
String documentId = docApiService.createDocument(client, userCourseVideo.getTitle());
|
|
String documentId = docApiService.createDocument(client, userCourseVideo.getTitle());
|
|
|
String url = buildCourseNewLink(param.getCompanyId(), param.getCompanyUserId(),
|
|
String url = buildCourseNewLink(param.getCompanyId(), param.getCompanyUserId(),
|
|
|
- param.getCourseId(), param.getVideoId(), param.getUserId(), param.getLink());
|
|
|
|
|
|
|
+ param.getCourseId(), param.getVideoId(), param.getUserId(), param.getLink(),questionFlag);
|
|
|
docApiService.createIframeBlock(client, documentId, url);
|
|
docApiService.createIframeBlock(client, documentId, url);
|
|
|
docApiService.changeDocumentPermissions(client, documentId);
|
|
docApiService.changeDocumentPermissions(client, documentId);
|
|
|
|
|
|
|
@@ -137,7 +140,7 @@ public class FeiShuService {
|
|
|
// ==================== URL 构建(纯业务逻辑,无外部调用) ====================
|
|
// ==================== URL 构建(纯业务逻辑,无外部调用) ====================
|
|
|
|
|
|
|
|
private String buildCourseNewLink(Long companyId, Long companyUserId, Long courseId,
|
|
private String buildCourseNewLink(Long companyId, Long companyUserId, Long courseId,
|
|
|
- Long videoId, Long userId, String link) {
|
|
|
|
|
|
|
+ Long videoId, Long userId, String link,Integer questionFlag) {
|
|
|
CourseConfig config = getCourseConfig();
|
|
CourseConfig config = getCourseConfig();
|
|
|
|
|
|
|
|
Map<String, Object> courseParam = new LinkedHashMap<>();
|
|
Map<String, Object> courseParam = new LinkedHashMap<>();
|
|
@@ -146,6 +149,7 @@ public class FeiShuService {
|
|
|
courseParam.put("companyId", companyId);
|
|
courseParam.put("companyId", companyId);
|
|
|
courseParam.put("courseId", courseId);
|
|
courseParam.put("courseId", courseId);
|
|
|
courseParam.put("link", link);
|
|
courseParam.put("link", link);
|
|
|
|
|
+ courseParam.put("questionFlag", questionFlag);
|
|
|
|
|
|
|
|
FsCourseLink fsCourseLink = courseLinkMapper.selectFsCourseLinkByLink(link);
|
|
FsCourseLink fsCourseLink = courseLinkMapper.selectFsCourseLinkByLink(link);
|
|
|
if (fsCourseLink == null) {
|
|
if (fsCourseLink == null) {
|