CREATE TABLE IF NOT EXISTS `platform_sms`
(
    `id`       INTEGER      NOT NULL auto_increment COMMENT '主键',
    `mobile`   VARCHAR(255) NOT NULL COMMENT '中国大陆手机号',
    `code`     VARCHAR(255) NOT NULL COMMENT '6位数字',
    `sendTime` datetime COMMENT '未发送或发送失败为空',
    `deadTime` datetime COMMENT '未发送或发送失败为空',
    `error`    VARCHAR(255),
    `remark`   VARCHAR(255) COMMENT '注册|修改手机号',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB COMMENT '短信验证码表';

CREATE TABLE IF NOT EXISTS `platform_store_account`
(
    storeId      int auto_increment
        primary key,
    mobile       varchar(255) not null comment '中国大陆手机号',
    password     varchar(255) not null comment 'HS512 加密',
    status       int          not null comment '枚举值、详看数据字典编码',
    registerDate datetime     not null comment 'yyyy-MM-dd',
    nickname     varchar(255) not null comment '待确定格式',
    sex          int          not null comment '枚举值、详看数据字典编码',
    avatar       varchar(255) null comment '待确定存储格式',
    loginDate    datetime     null comment 'yyyy-MM-dd',
    constraint platform_store_account_mobile_uindex
        unique (mobile)
)
    comment '店家账号表';


# TODO:熟悉框架建立的表，后面可能要再调整
create table platform_address
(
    id          bigint auto_increment
        primary key,
    create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
    consignee   varchar(10)                        not null comment '收货人',
    phone       varchar(11)                        not null comment '电话',
    province    varchar(10)                        not null comment '省',
    city        varchar(10)                        not null comment '市',
    area        varchar(10)                        not null comment '区',
    address     varchar(50)                        not null comment '详细地址',
    is_default  tinyint(1)                         not null comment '是否默认',
    create_by   varchar(64)                        null,
    update_by   varchar(64)                        null,
    remark      varchar(500)                       null,
    update_time datetime                           null,
    user_id     bigint                             null comment '关联用户',
    constraint platform_address_sys_user_user_id_fk
        foreign key (user_id) references sys_user (user_id)
)
    comment '收货地址表';


# TODO:熟悉框架建立的表，后面可能要再调整
create table platform_follower
(
    id          bigint auto_increment
        primary key,
    create_time datetime default CURRENT_TIMESTAMP not null,
    following   bigint                             not null comment '关注的人',
    follower    bigint                             not null comment '粉丝',
    constraint follower_user_id
        foreign key (follower) references sys_user (user_id),
    constraint following_user_id
        foreign key (following) references sys_user (user_id)
)
    comment '粉丝表';


select max(deadTime)
from platform_sms;
