فهرست منبع

邮件服务调用逻辑整理

chenkq 1 ماه پیش
والد
کامیت
f68da8f7df

+ 39 - 0
storlead-mail-api/src/main/java/com/storlead/mail/common/MailCommonApiController.java

@@ -0,0 +1,39 @@
+package com.storlead.mail.common;
+
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.storlead.framework.common.result.Result;
+import com.storlead.sales.mail.common.entity.MailServerPortConfigEntity;
+import com.storlead.sales.mail.common.service.MailServerPortConfigService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.io.IOException;
+
+@RestController
+@RequestMapping("/common")
+@Api(tags = "021. 邮件公共配置接口")
+@Log4j2
+public class MailCommonApiController {
+
+    @Resource
+    private MailServerPortConfigService serverPortConfigService;
+
+    @PostMapping(value = "/mail_port_config")
+    @ApiOperation(value = "获取邮箱端口配置", notes = "获取邮箱端口配置")
+    public Result getMailPortConfig(String mailAccount) throws IOException {
+        if (StrUtil.isBlank(mailAccount)) {
+            return Result.result("参数错误");
+        }
+        LambdaQueryWrapper<MailServerPortConfigEntity> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(MailServerPortConfigEntity::getMailServerSuffix, EmailServiceChecker.getEmailService(mailAccount));
+        queryWrapper.last("limit 1");
+        MailServerPortConfigEntity portConfig = serverPortConfigService.getOne(queryWrapper);
+        return Result.result(portConfig);
+    }
+}

+ 2 - 16
storlead-mail-api/src/main/java/com/storlead/mail/crm/MailApiController.java

@@ -70,7 +70,7 @@ import java.util.stream.Collectors;
  * @create: 2024-05-29 16:02
  */
 @RestController
-@RequestMapping("/mail")
+@RequestMapping("/crm")
 @Api(tags = "020.邮件管理相关接口")
 @Log4j2
 public class MailApiController {
@@ -83,8 +83,7 @@ public class MailApiController {
     private MailAttachmentService mailAttachmentService;
     @Resource
     private SmtpPopSettingsService smtpPopSettingsService;
-    @Resource
-    private MailServerPortConfigService serverPortConfigService;
+
 
     @Resource
     private MailTempAttachmentService tempAttachmentService;
@@ -1088,19 +1087,6 @@ public class MailApiController {
         return new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
     }
 
-    @PostMapping(value = "/mail_port_config")
-    @ApiOperation(value = "获取邮箱端口配置", notes = "获取邮箱端口配置")
-    public Result getMailPortConfig(String mailAccount) throws IOException {
-        if (StrUtil.isBlank(mailAccount)) {
-            return Result.result("参数错误");
-        }
-        LambdaQueryWrapper<MailServerPortConfigEntity> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(MailServerPortConfigEntity::getMailServerSuffix, EmailServiceChecker.getEmailService(mailAccount));
-        queryWrapper.last("limit 1");
-        MailServerPortConfigEntity portConfig = serverPortConfigService.getOne(queryWrapper);
-        return Result.result(portConfig);
-    }
-
 
     private static String formatDate(Date date) {
         if (date == null) return "N/A";

+ 12 - 3
storlead-mail-api/src/main/java/com/storlead/mail/mkt/MktMailApiController.java

@@ -218,11 +218,20 @@ public class MktMailApiController {
     @PostMapping("/detail")
     @ApiOperation("营销邮件详情(含附件)")
     public Result<?> detail(@RequestParam Long id) {
-        Long userId = LoginUserUtil.getCurrentUserId();
-        if (Objects.isNull(userId)) {
+        return getMailDetial(id);
+    }
+
+    @PostMapping(value = "/get_mail_detial")
+    @ApiOperation(value = "获取详情接口")
+    public Result<?> getMailDetial(Long mailId) {
+        if (Objects.isNull(mailId)) {
+            return Result.error("参数错误!");
+        }
+        Long currentUserId = LoginUserUtil.getCurrentUserId();
+        if (Objects.isNull(currentUserId)) {
             return Result.error("未登录");
         }
-        return Result.result(mktMailMessageService.getDetail(id, userId));
+        return Result.result(mktMailMessageService.getDetail(mailId, currentUserId));
     }
 
     @PostMapping("/open_stats")

+ 12 - 1
storlead-mail-api/src/main/java/com/storlead/mail/mkt/MktSmtpPopSettingsApiController.java

@@ -26,7 +26,7 @@ import java.util.Objects;
  */
 @Log4j2
 @RestController
-@RequestMapping("/mail/mkt/account")
+@RequestMapping("/mkt/account")
 @Api(tags = "021.营销邮箱账户")
 public class MktSmtpPopSettingsApiController {
 
@@ -58,6 +58,17 @@ public class MktSmtpPopSettingsApiController {
         return Result.result(list);
     }
 
+    @PostMapping("/personal_mail_account")
+    @ApiOperation("营销邮箱账户列表")
+    public Result<?> getPersonalAccount(@RequestParam(required = false) Long orgId) {
+        Long userId = requireLogin();
+        if (userId == null) {
+            return Result.result(null);
+        }
+        List<SmtpPopSettingsEntity> list = mailAccountBizService.listMktAccounts(userId, orgId);
+        return Result.result(list);
+    }
+
     @PostMapping("/save")
     @ApiOperation("保存/修改营销邮箱")
     public Result<?> save(@RequestBody SmtpPopSettingsEntity entity) {

+ 3 - 3
storlead-mail/storlead-mail-mkt/src/main/java/com/storlead/sales/mail/mkt/service/impl/MktMailMessageServiceImpl.java

@@ -280,9 +280,9 @@ public class MktMailMessageServiceImpl extends MyBaseServiceImpl<MktMailMessageM
         if (entity == null || !Objects.equals(entity.getIsDelete(), CommonConstant.DEL_FLAG_0)) {
             throw new WebException("邮件不存在");
         }
-        if (operatorId != null && entity.getOwnerBy() != null && !Objects.equals(entity.getOwnerBy(), operatorId)) {
-            throw new WebException("无权访问该邮件");
-        }
+//        if (operatorId != null && entity.getOwnerBy() != null && !Objects.equals(entity.getOwnerBy(), operatorId)) {
+//            throw new WebException("无权访问该邮件");
+//        }
         // 发送成功:正式附件;其余状态(草稿/延时/发送中/失败):临时附件
         if (Integer.valueOf(STATUS_SUCCESS).equals(entity.getStatus())) {
             entity.setAttachments(mktMailAttachmentService.listByMailId(id));