Files
yunzerwebsiteallinone/go/docs/sql/create_wechat_mini_template.sql
T
2026-11-16 17:22:50 +08:00

33 lines
1.8 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
CREATE TABLE IF NOT EXISTS yz_platform_wechat_mini_template (
id bigint unsigned NOT NULL AUTO_INCREMENT,
app_id varchar(64) NOT NULL COMMENT '小程序 AppID',
code varchar(64) NOT NULL COMMENT '场景码 notice/approval/schedule...',
template_id varchar(128) NOT NULL DEFAULT '' COMMENT '微信订阅消息模板 ID',
title varchar(255) NOT NULL DEFAULT '' COMMENT '场景名称',
page varchar(255) NOT NULL DEFAULT '' COMMENT '点击消息跳转的小程序页面',
fields text NULL COMMENT 'JSON:微信字段键 → 语义变量名映射',
enabled tinyint NOT NULL DEFAULT 1 COMMENT '1=启用 0=停用',
remark varchar(255) NOT NULL DEFAULT '' COMMENT '备注',
create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
update_time datetime NULL COMMENT '更新时间',
delete_time datetime NULL COMMENT '软删时间',
PRIMARY KEY (id),
UNIQUE KEY uk_mini_tpl_app_code (app_id, code)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='小程序订阅消息模板';
CREATE TABLE IF NOT EXISTS yz_platform_wechat_mini_subscribe (
id bigint unsigned NOT NULL AUTO_INCREMENT,
identity_id bigint unsigned NOT NULL COMMENT '身份 ID(yz_auth_identity.id)',
app_id varchar(64) NOT NULL COMMENT '小程序 AppID',
template_id varchar(128) NOT NULL COMMENT '微信订阅消息模板 ID',
remain int NOT NULL DEFAULT 0 COMMENT '剩余可发送次数(一次性订阅)',
create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
update_time datetime NULL COMMENT '更新时间',
PRIMARY KEY (id),
UNIQUE KEY uk_mini_sub_identity_tpl (identity_id, app_id, template_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='小程序订阅消息授权记录';
SELECT id, app_id, code, template_id, title, page, enabled FROM yz_platform_wechat_mini_template
WHERE delete_time IS NULL;