Browse Source

文件分享和协作时,对方不在线发送短信提醒

wukai 1 year ago
parent
commit
1239340b22

+ 14 - 0
doc-biz/src/main/java/com/doc/biz/controller/DocActorController.java

@@ -14,10 +14,13 @@ import com.doc.common.core.domain.AjaxResult;
 import com.doc.common.core.page.TableDataInfo;
 import com.doc.common.enums.BusinessType;
 import com.doc.common.utils.SecurityUtils;
+import com.doc.sms.TencentSmsService;
 import com.doc.system.service.ISysConfigService;
+import com.doc.system.service.ISysUserService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+import javafx.util.Pair;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -46,6 +49,9 @@ public class DocActorController extends BaseController {
     @Resource
     private IDocInfoService infoService;
 
+    @Resource
+    private ISysUserService userService;
+
     @ApiOperation("归档")
     @PutMapping("/{docId}")
     @Log(title = "文档协作", businessType = BusinessType.UPDATE)
@@ -104,6 +110,14 @@ public class DocActorController extends BaseController {
             msg.setToId(u);
             msg.setContent(txt);
             msgService.sendSysMsg(msg);
+
+            Pair<Boolean, String> pair = userService.isOnline(u);
+            if (!pair.getKey()) {
+                String fromUser = SecurityUtils.getLoginUser().getUser().getNickName();
+                String fileName = info.getFileName();
+                //如果不在线发送短信
+                TencentSmsService.send(TencentSmsService.FILE_SHARE, fromUser, fileName);
+            }
         });
 
         return success();

+ 17 - 0
doc-biz/src/main/java/com/doc/biz/controller/DocShareController.java

@@ -1,15 +1,20 @@
 package com.doc.biz.controller;
 
+import com.doc.biz.domain.DocInfo;
 import com.doc.biz.domain.DocShare;
+import com.doc.biz.service.IDocInfoService;
 import com.doc.biz.service.IDocShareService;
 import com.doc.chat.domain.ChatMsg;
 import com.doc.chat.service.IChatMsgService;
 import com.doc.common.core.controller.BaseController;
 import com.doc.common.core.domain.AjaxResult;
 import com.doc.common.utils.SecurityUtils;
+import com.doc.sms.TencentSmsService;
+import com.doc.system.service.ISysUserService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+import javafx.util.Pair;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -30,6 +35,10 @@ public class DocShareController extends BaseController {
     private IDocShareService docShareService;
     @Resource
     private IChatMsgService msgService;
+    @Resource
+    private ISysUserService userService;
+    @Resource
+    private IDocInfoService docInfoService;
 
     /**
      * 文件分享
@@ -71,6 +80,14 @@ public class DocShareController extends BaseController {
             msg.setContent(docId + "");
             msg.setFromId(SecurityUtils.getUserId());
             msgService.send(msg);
+            Pair<Boolean, String> pair = userService.isOnline(uid);
+            if (!pair.getKey()) {
+                String fromUser = SecurityUtils.getLoginUser().getUser().getNickName();
+                DocInfo docInfo = docInfoService.selectDocInfoByDocId(docId);
+                String fileName = docInfo.getFileName();
+                //如果不在线发送短信
+                TencentSmsService.send(TencentSmsService.FILE_SHARE, fromUser, fileName);
+            }
 
             //添加人员
             DocShare share = new DocShare();