功能:新增微信小程序一键登录
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
CREATE TABLE IF NOT EXISTS t_wechat_mini_binding
|
||||
(
|
||||
id BIGINT UNSIGNED NOT NULL COMMENT '微信小程序绑定主键ID(雪花ID)',
|
||||
user_id BIGINT UNSIGNED NOT NULL COMMENT '关联用户ID',
|
||||
app_id VARCHAR(64) NOT NULL COMMENT '微信小程序appId',
|
||||
openid VARCHAR(100) NOT NULL COMMENT '微信小程序openid',
|
||||
unionid VARCHAR(100) NULL COMMENT '微信开放平台unionid',
|
||||
status TINYINT UNSIGNED DEFAULT 1 NULL COMMENT '状态:1-有效,0-失效',
|
||||
create_time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL COMMENT '创建时间',
|
||||
update_time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (id)
|
||||
) COMMENT = '微信小程序账号绑定表';
|
||||
|
||||
DROP PROCEDURE IF EXISTS sp_add_index_if_not_exists;
|
||||
DELIMITER $$
|
||||
CREATE PROCEDURE sp_add_index_if_not_exists(
|
||||
IN p_table_name VARCHAR(64),
|
||||
IN p_index_name VARCHAR(64),
|
||||
IN p_index_sql TEXT
|
||||
)
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM information_schema.statistics
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = p_table_name
|
||||
AND index_name = p_index_name
|
||||
) THEN
|
||||
SET @index_sql = p_index_sql;
|
||||
PREPARE stmt FROM @index_sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
CALL sp_add_index_if_not_exists(
|
||||
't_wechat_mini_binding',
|
||||
'idx_wechat_mini_unionid',
|
||||
'CREATE INDEX idx_wechat_mini_unionid ON t_wechat_mini_binding (unionid)'
|
||||
);
|
||||
|
||||
CALL sp_add_index_if_not_exists(
|
||||
't_wechat_mini_binding',
|
||||
'uk_wechat_mini_app_openid',
|
||||
'ALTER TABLE t_wechat_mini_binding ADD CONSTRAINT uk_wechat_mini_app_openid UNIQUE (app_id, openid)'
|
||||
);
|
||||
|
||||
CALL sp_add_index_if_not_exists(
|
||||
't_wechat_mini_binding',
|
||||
'uk_wechat_mini_app_user',
|
||||
'ALTER TABLE t_wechat_mini_binding ADD CONSTRAINT uk_wechat_mini_app_user UNIQUE (app_id, user_id)'
|
||||
);
|
||||
|
||||
DROP PROCEDURE IF EXISTS sp_add_index_if_not_exists;
|
||||
@@ -193,6 +193,29 @@ create index idx_user_id
|
||||
on t_login_identity (user_id)
|
||||
comment '按用户查询登录标识的索引';
|
||||
|
||||
-- auto-generated definition
|
||||
create table t_wechat_mini_binding
|
||||
(
|
||||
id bigint unsigned auto_increment comment '微信小程序绑定主键ID(雪花ID)'
|
||||
primary key,
|
||||
user_id bigint unsigned not null comment '关联用户ID',
|
||||
app_id varchar(64) not null comment '微信小程序appId',
|
||||
openid varchar(100) not null comment '微信小程序openid',
|
||||
unionid varchar(100) null comment '微信开放平台unionid',
|
||||
status tinyint unsigned default 1 null comment '状态:1-有效,0-失效',
|
||||
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
||||
constraint uk_wechat_mini_app_openid
|
||||
unique (app_id, openid),
|
||||
constraint uk_wechat_mini_app_user
|
||||
unique (app_id, user_id)
|
||||
)
|
||||
comment '微信小程序账号绑定表';
|
||||
|
||||
create index idx_wechat_mini_unionid
|
||||
on t_wechat_mini_binding (unionid)
|
||||
comment '按unionid查询的索引';
|
||||
|
||||
-- auto-generated definition
|
||||
create table t_nail_artist_info
|
||||
(
|
||||
@@ -1327,6 +1350,7 @@ CALL sp_drop_auto_increment_on_id_if_exists('t_coupon');
|
||||
CALL sp_drop_auto_increment_on_id_if_exists('t_coupon_tag');
|
||||
CALL sp_drop_auto_increment_on_id_if_exists('t_effect_diagram');
|
||||
CALL sp_drop_auto_increment_on_id_if_exists('t_login_identity');
|
||||
CALL sp_drop_auto_increment_on_id_if_exists('t_wechat_mini_binding');
|
||||
CALL sp_drop_auto_increment_on_id_if_exists('t_nail_artist_info');
|
||||
CALL sp_drop_auto_increment_on_id_if_exists('t_object_storage_file');
|
||||
CALL sp_drop_auto_increment_on_id_if_exists('t_order');
|
||||
|
||||
Reference in New Issue
Block a user