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

29 lines
1.5 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_app (
id bigint unsigned NOT NULL AUTO_INCREMENT,
name varchar(128) NOT NULL DEFAULT '' COMMENT '应用名称',
app_id varchar(64) NOT NULL COMMENT '小程序 AppID',
app_secret varchar(512) NOT NULL DEFAULT '' COMMENT 'AppSecret(AES-256-GCM 加密存储)',
qrcode_url varchar(512) NOT NULL DEFAULT '' COMMENT '小程序码图片地址(供官网/H5等其他端调取)',
enabled tinyint NOT NULL DEFAULT 0 COMMENT '1=启用 0=停用',
auto_bind tinyint NOT NULL DEFAULT 1 COMMENT '1=手机号命中身份后自动绑定小程序',
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_app_appid (app_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='微信小程序多应用配置';
INSERT INTO yz_platform_wechat_mini_app (name, app_id, app_secret, enabled, auto_bind, remark)
SELECT COALESCE(NULLIF(c.remark, ''), '默认小程序'), c.app_id, c.app_secret, c.enabled, c.auto_bind, c.remark
FROM yz_platform_wechat_mini_config c
WHERE c.app_id <> ''
AND NOT EXISTS (
SELECT 1 FROM (SELECT 1 FROM yz_platform_wechat_mini_app x WHERE x.app_id = c.app_id) t
);
SELECT id, name, app_id, enabled, auto_bind, remark, qrcode_url
FROM yz_platform_wechat_mini_app
WHERE delete_time IS NULL;