feat(X-Pack): 消息通信策略

This commit is contained in:
fit2cloud-chenyw 2024-04-24 21:20:02 +08:00
parent 79d66ff537
commit 710ebaa588
8 changed files with 86 additions and 57 deletions

@ -1 +1 @@
Subproject commit 50699c9a2be31a1896e3d355013bbc0c1c20cd6a
Subproject commit 188b57250c4220e1972ee15da0bf416d6ce3e1fc

View File

@ -0,0 +1,13 @@
package io.dataease.api.communicate.api;
import io.dataease.api.communicate.dto.MessageDTO;
import io.swagger.v3.oas.annotations.Hidden;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@Hidden
public interface CommunicateApi {
@PostMapping("/send")
void send(@RequestBody MessageDTO dto);
}

View File

@ -0,0 +1,27 @@
package io.dataease.api.communicate.dto;
import io.dataease.constant.MessageEnum;
import lombok.Data;
import java.io.File;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;
@Data
public class MessageDTO implements Serializable {
@Serial
private static final long serialVersionUID = -1499402825211940277L;
private List<String> recipientList;
private String title;
private byte[] content;
private List<File> fileList;
private List<MessageFile> messageFileList;
private MessageEnum messageEnum;
}

View File

@ -0,0 +1,17 @@
package io.dataease.api.communicate.dto;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
public class MessageFile implements Serializable {
@Serial
private static final long serialVersionUID = 7140452847688399889L;
private String fileName;
private byte[] body;
}

View File

@ -1,9 +1,7 @@
package io.dataease.api.email;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.dataease.api.email.dto.EmailDTO;
import io.dataease.api.system.vo.SettingItemVO;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
@ -28,7 +26,4 @@ public interface EmailApi {
@PostMapping("/setting/validate")
void validate(@RequestBody List<SettingItemVO> settingItemVOS);
@PostMapping("/send")
@Hidden
void send(@RequestBody EmailDTO dto);
}

View File

@ -1,35 +0,0 @@
package io.dataease.api.email.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import java.io.File;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class EmailDTO implements Serializable {
@Serial
private static final long serialVersionUID = 3599154848839436838L;
private List<String> recipientList;
private String from;
private String subject;
private byte[] content;
private List<File> fileList;
private List<EmailFile> emailFiles;
public boolean existFile() {
return CollectionUtils.isNotEmpty(fileList) || CollectionUtils.isNotEmpty(emailFiles);
}
}

View File

@ -1,16 +0,0 @@
package io.dataease.api.email.dto;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
public class EmailFile implements Serializable {
@Serial
private static final long serialVersionUID = -3898069299109267651L;
private String fileName;
private byte[] fileByte;
}

View File

@ -0,0 +1,28 @@
package io.dataease.constant;
import java.util.Arrays;
public enum MessageEnum {
INNER(0), EMAIL(1), WECOM(2), DINGTALK(3), LARK(4), LARKSUITE(5);
private Integer flag;
public Integer getFlag() {
return flag;
}
public void setFlag(Integer flag) {
this.flag = flag;
}
MessageEnum(Integer flag) {
this.flag = flag;
}
MessageEnum() {
}
public static MessageEnum fromValue(Integer flag) {
return Arrays.stream(values()).filter(v -> v.flag.equals(flag)).findFirst().get();
}
}