|
|
@@ -39,6 +39,8 @@ public class FeiShuService {
|
|
|
private ISysConfigService configService;
|
|
|
@Autowired
|
|
|
private FsUserCourseVideoMapper videoMapper;
|
|
|
+ @Autowired
|
|
|
+ private IFsAuthLinkTokenService authLinkTokenService;
|
|
|
|
|
|
private Client client;
|
|
|
|
|
|
@@ -205,12 +207,13 @@ public class FeiShuService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 拼接授权url(课程参数JSON方式,适配飞书iframe,双重URL编码)
|
|
|
+ * 拼接授权url(生成短token,参数存Redis+数据库,适配飞书iframe,双重URL编码)
|
|
|
*/
|
|
|
private String buildAuthLink(Long companyId, Long companyUserId, Long courseId, Long videoId, Long periodId, Long projectId,Long id) {
|
|
|
String json = configService.selectConfigByKey("course.config");
|
|
|
CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
|
|
|
|
|
|
+ // 授权参数:生成短token,参数存Redis+数据库
|
|
|
Map<String, Object> authParam = new LinkedHashMap<>();
|
|
|
authParam.put("periodId", periodId);
|
|
|
authParam.put("companyUserId", companyUserId);
|
|
|
@@ -219,12 +222,12 @@ public class FeiShuService {
|
|
|
authParam.put("companyId", companyId);
|
|
|
authParam.put("courseId", courseId);
|
|
|
authParam.put("id", id);
|
|
|
- String authJson = JSONUtil.toJsonStr(authParam);
|
|
|
+ String token = authLinkTokenService.saveAuthParams(authParam);
|
|
|
|
|
|
try {
|
|
|
- String encodedJson = URLEncoder.encode(authJson, "UTF-8");
|
|
|
- String baseUrl =config.getFeishuNewLinkDomainName();
|
|
|
- String fullUrl = baseUrl + "/feishuCourse/pages_course/wxauth?course=" + encodedJson;
|
|
|
+ String baseUrl = config.getFeishuNewLinkDomainName();
|
|
|
+ String AUTH_PATH ="/pages/wxauth";
|
|
|
+ String fullUrl = baseUrl + AUTH_PATH + "?t=" + token;
|
|
|
return URLEncoder.encode(fullUrl, "UTF-8");
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
throw new CustomException("授权URL拼接失败", e);
|
|
|
@@ -388,19 +391,21 @@ public class FeiShuService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 删除今天之前创建的飞书云文档
|
|
|
+ * 删除两天之前创建的飞书云文档
|
|
|
* 1. 查询云文档列表
|
|
|
* 2. 遍历比较创建时间(飞书返回秒级时间戳)
|
|
|
- * 3. 创建时间在今天 00:00:00 之前的执行删除
|
|
|
+ * 3. 创建时间在两天 之前的执行删除
|
|
|
*/
|
|
|
public void deleteFilesBeforeToday() throws Exception {
|
|
|
// 今天 00:00:00 的时间戳(秒)
|
|
|
- Calendar today = Calendar.getInstance();
|
|
|
- today.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
- today.set(Calendar.MINUTE, 0);
|
|
|
- today.set(Calendar.SECOND, 0);
|
|
|
- today.set(Calendar.MILLISECOND, 0);
|
|
|
- long todayStartSec = today.getTimeInMillis() / 1000;
|
|
|
+ Calendar twoDaysAgo = Calendar.getInstance();
|
|
|
+ twoDaysAgo .set(Calendar.HOUR_OF_DAY, 0);
|
|
|
+ twoDaysAgo .set(Calendar.MINUTE, 0);
|
|
|
+ twoDaysAgo .set(Calendar.SECOND, 0);
|
|
|
+ twoDaysAgo .set(Calendar.MILLISECOND, 0);
|
|
|
+ // 减去两天
|
|
|
+ twoDaysAgo.add(Calendar.DAY_OF_MONTH, -2);
|
|
|
+ long todayStartSec = twoDaysAgo .getTimeInMillis() / 1000;
|
|
|
|
|
|
List<FeishuFileDTO> files = listFiles(200);
|
|
|
int total = files.size();
|
|
|
@@ -427,5 +432,4 @@ public class FeiShuService {
|
|
|
}
|
|
|
log.info("飞书云文档清理完成 | 列表总数={} | 删除成功={}", total, deleted);
|
|
|
}
|
|
|
-
|
|
|
}
|