Jelajahi Sumber

IPAD发送和生成notion修改

wjj 4 hari lalu
induk
melakukan
f1c899dd7d

+ 23 - 5
fs-ipad-task/src/main/java/com/fs/app/service/IpadSendServer.java

@@ -32,6 +32,9 @@ import com.fs.his.service.IFsShareMaterialService;
 import com.fs.his.service.IFsSignArticleService;
 import com.fs.ipad.IpadSendUtils;
 import com.fs.ipad.vo.*;
+import com.fs.notion.dto.NotionPageRequest;
+import com.fs.notion.dto.NotionPageResponse;
+import com.fs.notion.service.INotionService;
 import com.fs.qw.domain.*;
 import com.fs.qw.mapper.BindPhoneRedPacketRecordMapper;
 import com.fs.qw.mapper.QwCompanyMapper;
@@ -70,6 +73,7 @@ import java.util.regex.Pattern;
 @Service
 @AllArgsConstructor
 public class IpadSendServer {
+    private static final String notionLink = "https://notion.hcdyfa.top/pages_course/videoDetail?logId=";
     private static final Pattern LINK_PATTERN = Pattern.compile("link=([^&]+)");
     private final QwUserMapper qwUserMapper;
     private final IQwUserService qwUserService;
@@ -113,6 +117,9 @@ public class IpadSendServer {
     @Autowired
     private QwCompanyMapper qwCompanyMapper;
 
+    @Autowired
+    private INotionService notionService;
+
     //销售的个人飞书应用账户缓存的key
     private static final String FEISHU_COMPANY_USER_KEY = "feishu:account_company_user:";
 
@@ -338,11 +345,7 @@ public class IpadSendServer {
             // 新飞书逻辑
             completeFeishuCourseLink(vo, content,qwSopLogs, externalId,qwUserId);
         } else if ("19".equals(content.getContentType())){
-            String linkUrl = content.getLinkUrl();
-            if (linkUrl == null || StringUtils.isEmpty(linkUrl)) {
-                linkUrl = redisCache.getCacheObject("notion_course:"+content.getVideoId()+"_"+externalId+"_"+qwUserId);
-                content.setLinkUrl(linkUrl);
-            }
+            completeNotionCourseLink(vo, content,qwSopLogs, externalId,qwUserId);
         }
         // 文本
         LinkVo linkVo = LinkVo.builder()
@@ -360,6 +363,20 @@ public class IpadSendServer {
         }
     }
 
+    public void completeNotionCourseLink(BaseVo vo, QwSopCourseFinishTempSetting.Setting content,QwSopLogs qwSopLogs,Long externalId,Long qwUserId) {
+        String linkUrl = content.getLinkUrl();
+        if (StringUtils.isEmpty(linkUrl)) {
+            Long logId = fsCourseWatchLogMapper.selectFsCourseWatchLogIdByVideoIdAndExternalIdAndQwUserId(content.getVideoId(), externalId, String.valueOf(qwUserId));
+            NotionPageRequest request = new NotionPageRequest();
+            request.setTitle(content.getLinkDescribe());
+            request.setIframeUrl(notionLink + logId);
+            NotionPageResponse page = notionService.createPage(request);
+            content.setLinkUrl(page.getPublicUrl());
+            redisCache.setCacheObject("notion_course:"+content.getVideoId()+"_"+externalId+"_"+qwUserId,content.getLinkUrl(),3,TimeUnit.DAYS);
+            qwSopLogsService.updateLinkUrlInContentJson(qwSopLogs, page.getPublicUrl());
+        }
+    }
+
     /**
      * 完善飞书课程链接
      * */
@@ -811,6 +828,7 @@ public class IpadSendServer {
                 case "8":
                     // 语音
                     sendWxVideo(vo, content);
+
                     break;
                 case "14":
                     log.info("===============进入授权手机号红包=============");

+ 3 - 0
fs-qw-task/src/main/java/com/fs/app/taskService/impl/SopLogsTaskServiceImpl.java

@@ -1676,6 +1676,9 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
                         NotionPageResponse page = notionService.createPage(request);
                         url = page.getPublicUrl();
                     }
+                    if (StringUtils.isEmpty(url)) {
+                        url ="";
+                    }
                     setting.setLinkUrl(url);
                     break;
 

+ 1 - 1
fs-service/src/main/java/com/fs/sop/service/impl/QwSopLogsServiceImpl.java

@@ -2200,7 +2200,7 @@ public class QwSopLogsServiceImpl extends ServiceImpl<QwSopLogsMapper, QwSopLogs
         boolean updated = false;
         if (settingObj.getSetting() != null) {
             for (QwSopCourseFinishTempSetting.Setting setting : settingObj.getSetting()) {
-                if (setting.getContentType() != null && ("18".equals(setting.getContentType())||"20".equals(setting.getContentType()))) {
+                if (setting.getContentType() != null && ("18".equals(setting.getContentType())||"20".equals(setting.getContentType()) || "19".equals(setting.getContentType()))) {
                     setting.setLinkUrl(newLinkUrl);
                     updated = true;
                     // 不 break,更新全部飞书相关的LinkUrl