|
|
@@ -2,12 +2,12 @@ package com.fs.company.controller.course;
|
|
|
|
|
|
|
|
|
import com.fs.common.core.controller.BaseController;
|
|
|
-import com.fs.common.core.domain.R;
|
|
|
+import com.fs.common.core.domain.AjaxResult;
|
|
|
import com.fs.common.exception.CustomException;
|
|
|
-import com.fs.common.utils.StringUtils;
|
|
|
-import com.fs.feishu.model.FeishuLinkParam;
|
|
|
+import com.fs.company.domain.CompanyUser;
|
|
|
import com.fs.feishu.service.FeiShuService;
|
|
|
-import com.fs.system.service.ISysConfigService;
|
|
|
+import com.fs.framework.security.LoginUser;
|
|
|
+import com.fs.framework.security.SecurityUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -23,42 +23,54 @@ public class FeiShuCourseController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private FeiShuService feiShuService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ISysConfigService configService;
|
|
|
@ApiOperation("生成飞书看课链接")
|
|
|
@GetMapping("/getFeiShuCourseLink")
|
|
|
- public R getFeiShuCourseLink(@RequestParam Long companyUserId,
|
|
|
- @RequestParam Long videoId,
|
|
|
- @RequestParam(required = false) Long companyId,
|
|
|
- @RequestParam(required = false) Long courseId,
|
|
|
- @RequestParam(required = false) Long projectId,
|
|
|
- @RequestParam(required = false) Long id) {
|
|
|
- // 读取配置判断是否启用飞书新跳转
|
|
|
- Boolean enableFeishuNewLink = null;
|
|
|
+ public AjaxResult getFeiShuCourseLink(
|
|
|
+ @RequestParam(value = "videoId", required = true) Long videoId,
|
|
|
+ @RequestParam(value = "courseId", required = false) Long courseId,
|
|
|
+ @RequestParam(value = "projectId", required = false) Long projectId,
|
|
|
+ @RequestParam(value = "id", required = false) Long id) {
|
|
|
+
|
|
|
+ // 1. 强制必填参数校验
|
|
|
+ if (videoId == null) {
|
|
|
+ return AjaxResult.error("视频ID不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 获取当前登录企业用户信息
|
|
|
+ CompanyUser companyUser;
|
|
|
try {
|
|
|
- String json = configService.selectConfigByKey("course.config");
|
|
|
- if (StringUtils.isNotBlank(json)) {
|
|
|
- com.fs.course.config.CourseConfig config = cn.hutool.json.JSONUtil.toBean(json, com.fs.course.config.CourseConfig.class);
|
|
|
- enableFeishuNewLink = config.getEnableFeishuNewLink();
|
|
|
- }
|
|
|
+ companyUser = getCurrentCompanyUser();
|
|
|
+ } catch (CustomException e) {
|
|
|
+ log.warn("获取登录用户信息失败:{}", e.getMessage());
|
|
|
+ return AjaxResult.error(e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 组装用户参数
|
|
|
+ Long companyUserId = companyUser.getUserId();
|
|
|
+ Long companyId = companyUser.getCompanyId();
|
|
|
+
|
|
|
+ // 4. 调用业务层生成链接
|
|
|
+ try {
|
|
|
+ String feishuLink = feiShuService.generateRegisterLink(videoId, companyId, courseId, companyUserId, projectId, id);
|
|
|
+ return AjaxResult.success(feishuLink);
|
|
|
+ } catch (CustomException e) {
|
|
|
+ log.error("生成飞书看课链接业务异常:{}", e.getMessage());
|
|
|
+ return AjaxResult.error(e.getMessage());
|
|
|
} catch (Exception e) {
|
|
|
- log.warn("读取飞书跳转配置失败", e);
|
|
|
- throw new CustomException("读取飞书看课配置失败");
|
|
|
+ log.error("生成飞书看课链接系统异常", e);
|
|
|
+ return AjaxResult.error("生成飞书课程链接失败,请稍后重试");
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if (Boolean.TRUE.equals(enableFeishuNewLink)) {
|
|
|
- FeishuLinkParam param = new FeishuLinkParam();
|
|
|
- param.setCompanyId(companyId);
|
|
|
- param.setCompanyUserId(companyUserId);
|
|
|
- param.setCourseId(courseId);
|
|
|
- param.setVideoId(videoId);
|
|
|
- param.setProjectId(projectId);
|
|
|
- param.setId(id);
|
|
|
- String link = feiShuService.getFeishuRegisterLink(param);
|
|
|
- log.info("链接{}", link);
|
|
|
- return R.ok().put("data", link);
|
|
|
+ /**
|
|
|
+ * 获取当前登录企业用户
|
|
|
+ * @return CompanyUser
|
|
|
+ */
|
|
|
+ public static CompanyUser getCurrentCompanyUser() {
|
|
|
+ LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
|
+ if (loginUser == null || loginUser.getUser() == null) {
|
|
|
+ throw new CustomException("登录信息已过期,请重新登录");
|
|
|
}
|
|
|
- return R.error("未开启飞书看课,生成链接失败!");
|
|
|
+ return loginUser.getUser();
|
|
|
}
|
|
|
}
|