golang-api-server/docs/Task1.md

38 lines
2.5 KiB
Markdown
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.

给当前Golang系统 增加 postgresql 的支持可以切换mysql或者postgresql(通过config yaml配置 主数据源)。
然后将以下移动端用户信息表给我改成postgresql的建表格式加上COMMENT信息,并增加对应的代码Entity、Service、Mapper、Controller
要求 系统要兼容mysql/postgresql 切换使用目前只有两个表t_user、t_platform_user你需要帮我在docs/ 下建立 sql文件夹储存 mysql以及postgresql的建表语句。
```
CREATE TABLE t_user (
id BIGSERIAL PRIMARY KEY, -- 全局唯一用户ID自增
username VARCHAR(50) COMMENT '用户名(可选,后台管理用)',
nickname VARCHAR(100) COMMENT '用户昵称(各平台统一)',
avatar_url VARCHAR(500) COMMENT '用户头像URL',
phone VARCHAR(20) UNIQUE COMMENT '手机号脱敏存储如138****1234',
gender TINYINT COMMENT '性别0-未知1-男2-女',
status TINYINT DEFAULT 1 COMMENT '状态0-禁用1-正常',
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
deleted TINYINT DEFAULT 0 COMMENT '软删除0-未删1-已删'
);
COMMENT ON TABLE t_user IS '用户基础信息表';
CREATE TABLE t_platform_user (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL COMMENT '关联t_user.id',
platform_type TINYINT NOT NULL COMMENT '平台类型1-微信小程序2-抖音小程序3-支付宝小程序',
platform_openid VARCHAR(100) NOT NULL COMMENT '平台唯一标识微信openid/抖音open_id',
platform_unionid VARCHAR(100) COMMENT '平台统一标识微信unionid多小程序互通用',
platform_session_key VARCHAR(100) COMMENT '平台会话密钥微信session_key加密存储',
platform_extra JSONB COMMENT '平台扩展字段如抖音的user_name、微信的city等',
last_login_time TIMESTAMP COMMENT '最后登录时间',
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
deleted TINYINT DEFAULT 0,
-- 联合唯一索引同一平台的openid不能重复
UNIQUE (platform_type, platform_openid),
-- 外键关联用户表
CONSTRAINT fk_platform_user_user_id FOREIGN KEY (user_id) REFERENCES t_user(id) ON DELETE CASCADE
);
COMMENT ON TABLE t_platform_user IS '平台用户关联表(微信/抖音小程序用户信息)';
```