feat(channel): add channel-common SPI, channel tables, subject/account APIs and WeCom callback placeholder
This commit is contained in:
22
backend/mci-channel-common/pom.xml
Normal file
22
backend/mci-channel-common/pom.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.sino</groupId>
|
||||
<artifactId>sino-mci-parent</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>mci-channel-common</artifactId>
|
||||
<name>mci-channel-common</name>
|
||||
<description>Channel adapter SPI and shared models</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.sino.mci.channel.common.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class CallbackPayload {
|
||||
|
||||
private String channelType;
|
||||
private String eventType;
|
||||
private String rawBody;
|
||||
private Map<String, Object> normalized;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.sino.mci.channel.common.dto;
|
||||
|
||||
import com.sino.mci.channel.common.model.AccountType;
|
||||
import com.sino.mci.channel.common.model.ChannelType;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class ChannelInitRequest {
|
||||
|
||||
private ChannelType channelType;
|
||||
private AccountType accountType;
|
||||
private Long subjectId;
|
||||
private Map<String, Object> config;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.sino.mci.channel.common.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class ChannelInitResult {
|
||||
|
||||
private boolean success;
|
||||
private String accountId;
|
||||
private String accountName;
|
||||
private String qrCodeUrl;
|
||||
private String message;
|
||||
private Map<String, Object> extra;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.sino.mci.channel.common.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class SendMessageRequest {
|
||||
|
||||
private String conversationId;
|
||||
private String receiverId;
|
||||
private String contentType;
|
||||
private Map<String, Object> content;
|
||||
private Map<String, Object> extra;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.sino.mci.channel.common.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SendMessageResult {
|
||||
|
||||
private boolean success;
|
||||
private String channelMessageId;
|
||||
private String message;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.sino.mci.channel.common.model;
|
||||
|
||||
public enum AccountType {
|
||||
WECOM_INTERNAL(1, "企微内部账号"),
|
||||
WECOM_AGENT(2, "企微应用"),
|
||||
WECHAT_PERSONAL(3, "pywechat 个人号"),
|
||||
DINGTALK_BOT(4, "钉钉机器人"),
|
||||
FEISHU_BOT(5, "飞书机器人");
|
||||
|
||||
private final int code;
|
||||
private final String label;
|
||||
|
||||
AccountType(int code, String label) {
|
||||
this.code = code;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public static AccountType of(int code) {
|
||||
for (AccountType type : values()) {
|
||||
if (type.code == code) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.sino.mci.channel.common.model;
|
||||
|
||||
public enum ChannelType {
|
||||
WECOM,
|
||||
WECHAT_PERSONAL,
|
||||
DINGTALK,
|
||||
FEISHU,
|
||||
IVR
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.sino.mci.channel.common.spi;
|
||||
|
||||
import com.sino.mci.channel.common.dto.CallbackPayload;
|
||||
import com.sino.mci.channel.common.dto.ChannelInitRequest;
|
||||
import com.sino.mci.channel.common.dto.ChannelInitResult;
|
||||
import com.sino.mci.channel.common.dto.SendMessageRequest;
|
||||
import com.sino.mci.channel.common.dto.SendMessageResult;
|
||||
import com.sino.mci.channel.common.model.ChannelType;
|
||||
|
||||
public interface ChannelAdapter {
|
||||
|
||||
ChannelType getChannelType();
|
||||
|
||||
ChannelInitResult initAccount(ChannelInitRequest request);
|
||||
|
||||
SendMessageResult sendMessage(SendMessageRequest request);
|
||||
|
||||
CallbackPayload parseCallback(String rawBody);
|
||||
}
|
||||
Reference in New Issue
Block a user