feat(db): add M8 notification and todo tables

This commit is contained in:
2026-05-25 01:01:34 +08:00
parent 75e6d6d5ec
commit fa2a50e755
7 changed files with 311 additions and 0 deletions
@@ -0,0 +1,5 @@
package cn.craftlabs.platform.api.domain;
public enum TodoPriority {
HIGH, MEDIUM, LOW
}
@@ -0,0 +1,5 @@
package cn.craftlabs.platform.api.domain;
public enum TodoStatus {
PENDING, PROCESSED, IGNORED
}
@@ -0,0 +1,111 @@
package cn.craftlabs.platform.api.persistence.todo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.time.OffsetDateTime;
@TableName("platform_notification_config")
public class PlatformNotificationConfig {
@TableId(type = IdType.AUTO)
private Long id;
@TableField("role_code")
private String roleCode;
@TableField("channel_email")
private Boolean channelEmail;
@TableField("channel_wecom")
private Boolean channelWecom;
@TableField("channel_in_app")
private Boolean channelInApp;
@TableField("event_type")
private String eventType;
@TableField("aggregation_rule")
private String aggregationRule;
@TableField("created_at")
private OffsetDateTime createdAt;
@TableField("updated_at")
private OffsetDateTime updatedAt;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getRoleCode() {
return roleCode;
}
public void setRoleCode(String roleCode) {
this.roleCode = roleCode;
}
public Boolean getChannelEmail() {
return channelEmail;
}
public void setChannelEmail(Boolean channelEmail) {
this.channelEmail = channelEmail;
}
public Boolean getChannelWecom() {
return channelWecom;
}
public void setChannelWecom(Boolean channelWecom) {
this.channelWecom = channelWecom;
}
public Boolean getChannelInApp() {
return channelInApp;
}
public void setChannelInApp(Boolean channelInApp) {
this.channelInApp = channelInApp;
}
public String getEventType() {
return eventType;
}
public void setEventType(String eventType) {
this.eventType = eventType;
}
public String getAggregationRule() {
return aggregationRule;
}
public void setAggregationRule(String aggregationRule) {
this.aggregationRule = aggregationRule;
}
public OffsetDateTime getCreatedAt() {
return createdAt;
}
public void setCreatedAt(OffsetDateTime createdAt) {
this.createdAt = createdAt;
}
public OffsetDateTime getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(OffsetDateTime updatedAt) {
this.updatedAt = updatedAt;
}
}
@@ -0,0 +1,7 @@
package cn.craftlabs.platform.api.persistence.todo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface PlatformNotificationConfigMapper extends BaseMapper<PlatformNotificationConfig> {}
@@ -0,0 +1,140 @@
package cn.craftlabs.platform.api.persistence.todo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.time.OffsetDateTime;
@TableName("platform_todo_item")
public class PlatformTodoItem {
@TableId(type = IdType.AUTO)
private Long id;
@TableField("todo_type")
private String todoType;
private String title;
@TableField("source_id")
private Long sourceId;
@TableField("source_type")
private String sourceType;
private String priority;
private String status;
@TableField("assigned_role")
private String assignedRole;
@TableField("assigned_user_id")
private String assignedUserId;
@TableField("created_at")
private OffsetDateTime createdAt;
@TableField("processed_at")
private OffsetDateTime processedAt;
private String remark;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getTodoType() {
return todoType;
}
public void setTodoType(String todoType) {
this.todoType = todoType;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Long getSourceId() {
return sourceId;
}
public void setSourceId(Long sourceId) {
this.sourceId = sourceId;
}
public String getSourceType() {
return sourceType;
}
public void setSourceType(String sourceType) {
this.sourceType = sourceType;
}
public String getPriority() {
return priority;
}
public void setPriority(String priority) {
this.priority = priority;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getAssignedRole() {
return assignedRole;
}
public void setAssignedRole(String assignedRole) {
this.assignedRole = assignedRole;
}
public String getAssignedUserId() {
return assignedUserId;
}
public void setAssignedUserId(String assignedUserId) {
this.assignedUserId = assignedUserId;
}
public OffsetDateTime getCreatedAt() {
return createdAt;
}
public void setCreatedAt(OffsetDateTime createdAt) {
this.createdAt = createdAt;
}
public OffsetDateTime getProcessedAt() {
return processedAt;
}
public void setProcessedAt(OffsetDateTime processedAt) {
this.processedAt = processedAt;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
@@ -0,0 +1,7 @@
package cn.craftlabs.platform.api.persistence.todo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface PlatformTodoItemMapper extends BaseMapper<PlatformTodoItem> {}
@@ -0,0 +1,36 @@
-- V8__notification_todo.sql
-- M8:待办事项表
CREATE TABLE platform_todo_item (
id BIGSERIAL PRIMARY KEY,
todo_type VARCHAR(64) NOT NULL,
title VARCHAR(512) NOT NULL,
source_id BIGINT,
source_type VARCHAR(64),
priority VARCHAR(16) NOT NULL DEFAULT 'MEDIUM',
status VARCHAR(32) NOT NULL DEFAULT 'PENDING',
assigned_role VARCHAR(64),
assigned_user_id VARCHAR(256),
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
processed_at TIMESTAMP WITH TIME ZONE,
remark TEXT
);
CREATE INDEX idx_todo_status ON platform_todo_item(status);
CREATE INDEX idx_todo_type ON platform_todo_item(todo_type);
CREATE INDEX idx_todo_role ON platform_todo_item(assigned_role);
-- M8:通知配置表
CREATE TABLE platform_notification_config (
id BIGSERIAL PRIMARY KEY,
role_code VARCHAR(64),
channel_email BOOLEAN DEFAULT FALSE,
channel_wecom BOOLEAN DEFAULT FALSE,
channel_in_app BOOLEAN DEFAULT TRUE,
event_type VARCHAR(64) NOT NULL,
aggregation_rule VARCHAR(64) DEFAULT 'NONE',
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_notif_config_role ON platform_notification_config(role_code);
CREATE INDEX idx_notif_config_event ON platform_notification_config(event_type);