feat: 根据OpenClaw dmPolicy重新设计配对规则
- 更新数据库表结构,添加dm_policy字段(pairing/allowlist/open/disabled) - 添加allow_from字段用于白名单配置 - 添加openclaw_gateway_url和openclaw_gateway_token字段 - 更新Java实体类WeComBot,支持新的配对策略 - 更新测试数据,包含四种配对策略的示例 - 删除旧的pairing_mode字段,使用标准的OpenClaw dmPolicy
This commit is contained in:
@@ -2,24 +2,12 @@ package com.wecom;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@SpringBootApplication
|
||||
@RestController
|
||||
@EnableScheduling
|
||||
public class WeComMiddlewareApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(WeComMiddlewareApplication.class, args);
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
public String home() {
|
||||
return "WeCom Middleware Backend is running!";
|
||||
}
|
||||
|
||||
@GetMapping("/api/system/health")
|
||||
public String health() {
|
||||
return "{\"status\":\"UP\"}";
|
||||
}
|
||||
}
|
||||
86
backend/src/main/java/com/wecom/entity/WeComBot.java
Normal file
86
backend/src/main/java/com/wecom/entity/WeComBot.java
Normal file
@@ -0,0 +1,86 @@
|
||||
package com.wecom.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 企业微信Bot配置实体
|
||||
*/
|
||||
@Data
|
||||
@TableName("wecom_bots")
|
||||
public class WeComBot {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
@TableField("bot_id")
|
||||
private String botId;
|
||||
|
||||
@TableField("secret")
|
||||
private String secret;
|
||||
|
||||
/**
|
||||
* 配对策略:
|
||||
* pairing - 默认:未知发送者会收到配对码;所有者必须批准
|
||||
* allowlist - 仅允许 allowFrom(或已配对的允许存储)中的发送者
|
||||
* open - 允许所有入站私聊
|
||||
* disabled - 忽略所有入站私聊
|
||||
*/
|
||||
@TableField("dm_policy")
|
||||
private String dmPolicy;
|
||||
|
||||
/**
|
||||
* 允许列表(JSON数组),dm_policy=allowlist时使用
|
||||
*/
|
||||
@TableField("allow_from")
|
||||
private String allowFrom;
|
||||
|
||||
/**
|
||||
* 状态:
|
||||
* active - 活跃
|
||||
* inactive - 未激活
|
||||
* error - 错误
|
||||
*/
|
||||
@TableField("status")
|
||||
private String status;
|
||||
|
||||
@TableField("webhook_url")
|
||||
private String webhookUrl;
|
||||
|
||||
@TableField("openclaw_gateway_url")
|
||||
private String openclawGatewayUrl;
|
||||
|
||||
@TableField("openclaw_gateway_token")
|
||||
private String openclawGatewayToken;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
// 枚举类
|
||||
public static class PairingMode {
|
||||
public static final String MANUAL = "manual";
|
||||
public static final String AUTO = "auto";
|
||||
public static final String RULE = "rule";
|
||||
|
||||
public static String[] getAll() {
|
||||
return new String[]{MANUAL, AUTO, RULE};
|
||||
}
|
||||
}
|
||||
|
||||
public static class Status {
|
||||
public static final String ACTIVE = "active";
|
||||
public static final String INACTIVE = "inactive";
|
||||
public static final String ERROR = "error";
|
||||
|
||||
public static String[] getAll() {
|
||||
return new String[]{ACTIVE, INACTIVE, ERROR};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user