-- Database schema dump for ryc

-- Table: t_activity
CREATE TABLE t_activity (
  `id` bigint NOT NULL auto_increment,
  `pid` bigint NOT NULL DEFAULT '0',
  `path` varchar(255) NOT NULL,
  `name` varchar(128) NOT NULL,
  `description` text,
  `signup_deadline` datetime NOT NULL,
  `match_time` datetime,
  `address` varchar(255),
  `rating_scheme_id` bigint NOT NULL,
  `player_max` int COMMENT '人数上限',
  `state` int NOT NULL DEFAULT '1' COMMENT '0:未发布， 1：发布：2：关闭',
  `create_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED,
  `create_user_id` bigint,
  `update_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED on update CURRENT_TIMESTAMP,
  `update_user_id` bigint,
  `version` bigint NOT NULL DEFAULT '0'
);

-- Table: t_activity_judge
CREATE TABLE t_activity_judge (
  `id` bigint NOT NULL auto_increment,
  `activity_id` bigint NOT NULL,
  `stage_id` bigint NOT NULL,
  `judge_id` bigint NOT NULL,
  `description` varchar(255),
  `state` int,
  `create_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED,
  `create_user_id` bigint,
  `update_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED on update CURRENT_TIMESTAMP,
  `update_user_id` bigint,
  `version` bigint NOT NULL DEFAULT '0'
);

-- Table: t_activity_player_rating_item
CREATE TABLE t_activity_player_rating_item (
  `id` bigint NOT NULL auto_increment,
  `activity_id` bigint NOT NULL,
  `player_id` bigint NOT NULL,
  `rating_scheme_id` bigint NOT NULL,
  `rating_item_id` bigint NOT NULL,
  `score` decimal(10,2) NOT NULL,
  `feedback` text,
  `create_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED,
  `create_user_id` bigint,
  `update_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED on update CURRENT_TIMESTAMP,
  `update_user_id` bigint,
  `version` bigint NOT NULL DEFAULT '0'
);

-- Table: t_avtivity_player
CREATE TABLE t_avtivity_player (
  `id` bigint NOT NULL auto_increment,
  `activity_id` bigint NOT NULL,
  `player_id` bigint NOT NULL,
  `description` varchar(255),
  `reject_reason` varchar(255),
  `judge_id` bigint COMMENT '评委',
  `feedback` text,
  `total_score` decimal(19,4) COMMENT '低分',
  `rank` varchar(255) COMMENT '名次',
  `create_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED,
  `create_user_id` bigint,
  `update_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED on update CURRENT_TIMESTAMP,
  `update_user_id` bigint,
  `version` bigint NOT NULL DEFAULT '0'
);

-- Table: t_carousel  -- 轮播图
CREATE TABLE t_carousel (
  `id` bigint NOT NULL auto_increment,
  `title` varchar(128) NOT NULL,
  `description` varchar(255),
  `sort_order` int NOT NULL,
  `state` int NOT NULL DEFAULT '1' COMMENT '0:关闭，1：使用',
  `create_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED,
  `create_user_id` bigint,
  `update_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED on update CURRENT_TIMESTAMP,
  `update_user_id` bigint,
  `version` bigint NOT NULL DEFAULT '0'
);

-- Table: t_employee
CREATE TABLE t_employee (
  `id` bigint NOT NULL auto_increment,
  `name` varchar(64) NOT NULL,
  `phone` varchar(32) NOT NULL,
  `password` varchar(128) NOT NULL,
  `status` varchar(16) NOT NULL,
  `state` int NOT NULL,
  `create_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED,
  `create_user_id` bigint,
  `update_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED on update CURRENT_TIMESTAMP,
  `update_user_id` bigint,
  `version` bigint NOT NULL DEFAULT '0',
  `role_code` varchar(32) NOT NULL,
  `user_id` bigint NOT NULL
);

-- Table: t_employee_role
CREATE TABLE t_employee_role (
  `id` bigint NOT NULL auto_increment,
  `employee_id` bigint NOT NULL,
  `role_id` bigint NOT NULL,
  `create_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED,
  `create_user_id` bigint,
  `update_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED on update CURRENT_TIMESTAMP,
  `update_user_id` bigint,
  `version` bigint NOT NULL DEFAULT '0'
);

-- Table: t_judge
CREATE TABLE t_judge (
  `id` bigint NOT NULL auto_increment,
  `name` varchar(64) NOT NULL,
  `user_id` bigint,
  `phone` varchar(32) NOT NULL,
  `gender` int,
  `state` int NOT NULL DEFAULT '1',
  `role_id` bigint,
  `description` varchar(255),
  `create_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED,
  `create_user_id` bigint,
  `update_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED on update CURRENT_TIMESTAMP,
  `update_user_id` bigint,
  `version` bigint NOT NULL DEFAULT '0'
);

-- Table: t_judge_tag
CREATE TABLE t_judge_tag (
  `id` bigint NOT NULL auto_increment,
  `judge_id` bigint NOT NULL,
  `tag_id` bigint NOT NULL,
  `state` int NOT NULL DEFAULT '1',
  `create_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED,
  `create_user_id` bigint,
  `update_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED on update CURRENT_TIMESTAMP,
  `update_user_id` bigint,
  `version` bigint NOT NULL DEFAULT '0'
);

-- Table: t_media
CREATE TABLE t_media (
  `id` int NOT NULL auto_increment,
  `name` varchar(255),
  `target_type` int NOT NULL,
  `target_id` bigint NOT NULL,
  `media_type` int NOT NULL,
  `path` varchar(500) NOT NULL COMMENT '腾讯云的存储桶地址',
  `thumb_path` varchar(500),
  `file_ext` varchar(20) NOT NULL,
  `file_size` int NOT NULL,
  `duration` int COMMENT '视频的长度秒',
  `description` varchar(255),
  `state` varchar(255),
  `create_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED,
  `create_user_id` bigint,
  `update_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED on update CURRENT_TIMESTAMP,
  `update_user_id` bigint,
  `version` bigint NOT NULL DEFAULT '0'
);

-- Table: t_notification_task
CREATE TABLE t_notification_task (
  `id` bigint NOT NULL auto_increment,
  `type` varchar(32) NOT NULL,
  `channel` varchar(64) NOT NULL,
  `target_type` varchar(32) NOT NULL COMMENT '1:学员，2：评委，3：工作人员',
  `target_id` bigint NOT NULL,
  `payload` text COMMENT '消息内容',
  `error_message` varchar(512),
  `retry_count` int NOT NULL,
  `next_retry_at` datetime,
  `state` tinyint(1) NOT NULL DEFAULT '1',
  `create_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED,
  `create_user_id` bigint,
  `update_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED on update CURRENT_TIMESTAMP,
  `update_user_id` bigint,
  `version` bigint NOT NULL DEFAULT '0'
);

-- Table: t_permission
CREATE TABLE t_permission (
  `id` bigint NOT NULL auto_increment,
  `code` varchar(128) NOT NULL,
  `name` varchar(128) NOT NULL,
  `category` varchar(64),
  `description` varchar(255),
  `state` tinyint(1) NOT NULL DEFAULT '1',
  `create_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED,
  `create_user_id` bigint,
  `update_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED on update CURRENT_TIMESTAMP,
  `update_user_id` bigint,
  `version` bigint NOT NULL DEFAULT '0'
);

-- Table: t_player
CREATE TABLE t_player (
  `id` bigint NOT NULL auto_increment,
  `name` varchar(64) NOT NULL,
  `phone` varchar(32) NOT NULL,
  `role_id` bigint NOT NULL,
  `description` varchar(255),
  `gender` int COMMENT '0:女，1：男',
  `education` varchar(32),
  `introduction` text,
  `audit_state` int NOT NULL COMMENT '0等待审核，1：审核通过，2：不通过',
  `reject_reason` varchar(255),
  `final_score` decimal(10,2),
  `state` int NOT NULL,
  `create_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED,
  `create_user_id` bigint,
  `update_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED on update CURRENT_TIMESTAMP,
  `update_user_id` bigint,
  `version` bigint NOT NULL DEFAULT '0',
  `user_id` bigint NOT NULL
);

-- Table: t_rating_item
CREATE TABLE t_rating_item (
  `id` bigint NOT NULL auto_increment,
  `scheme_id` bigint NOT NULL,
  `name` varchar(128) NOT NULL,
  `max_score` int NOT NULL,
  `order_no` int NOT NULL,
  `state` int NOT NULL,
  `create_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED,
  `create_user_id` bigint,
  `update_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED on update CURRENT_TIMESTAMP,
  `update_user_id` bigint,
  `version` bigint NOT NULL DEFAULT '0'
);

-- Table: t_rating_scheme
CREATE TABLE t_rating_scheme (
  `id` bigint NOT NULL auto_increment,
  `name` varchar(128) NOT NULL,
  `description` varchar(512),
  `state` int NOT NULL,
  `create_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED,
  `create_user_id` bigint,
  `update_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED on update CURRENT_TIMESTAMP,
  `update_user_id` bigint,
  `version` bigint NOT NULL DEFAULT '0'
);

-- Table: t_region
CREATE TABLE t_region (
  `id` bigint NOT NULL auto_increment,
  `pid` bigint NOT NULL COMMENT '自关联',
  `name` varchar(64) NOT NULL,
  `code` varchar(32) NOT NULL,
  `level` int NOT NULL,
  `leaf_flag` tinyint(1) NOT NULL DEFAULT '0',
  `full_path` varchar(256),
  `state` int NOT NULL,
  `create_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED,
  `create_user_id` bigint,
  `update_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED on update CURRENT_TIMESTAMP,
  `update_user_id` bigint,
  `version` bigint NOT NULL DEFAULT '0'
);

-- Table: t_role
CREATE TABLE t_role (
  `id` bigint NOT NULL auto_increment,
  `code` varchar(64) NOT NULL,
  `name` varchar(128) NOT NULL,
  `description` varchar(255),
  `state` int NOT NULL,
  `create_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED,
  `create_user_id` bigint,
  `update_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED on update CURRENT_TIMESTAMP,
  `update_user_id` bigint,
  `version` bigint NOT NULL DEFAULT '0'
);

-- Table: t_role_permission
CREATE TABLE t_role_permission (
  `id` int NOT NULL auto_increment,
  `role_id` bigint NOT NULL,
  `permission_id` bigint NOT NULL,
  `create_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED,
  `create_user_id` bigint,
  `update_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED on update CURRENT_TIMESTAMP,
  `update_user_id` bigint,
  `version` bigint NOT NULL DEFAULT '0'
);

-- Table: t_tag
CREATE TABLE t_tag (
  `id` bigint NOT NULL auto_increment,
  `name` varchar(64) NOT NULL,
  `code` varchar(64) NOT NULL,
  `category` varchar(32) NOT NULL,
  `description` varchar(255),
  `state` int NOT NULL,
  `create_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED,
  `create_user_id` bigint,
  `update_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED on update CURRENT_TIMESTAMP,
  `update_user_id` bigint,
  `version` bigint NOT NULL DEFAULT '0'
);

-- Table: t_user
CREATE TABLE t_user (
  `id` bigint NOT NULL auto_increment,
  `name` varchar(255) NOT NULL,
  `gender` int,
  `phone` varchar(20),
  `birthday` date,
  `wx_openid` varchar(50) NOT NULL,
  `wx_unionid` varchar(50) NOT NULL,
  `wx_oa_openid` varchar(50),
  `password` varchar(255),
  `state` int NOT NULL,
  `create_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED,
  `create_user_id` bigint,
  `update_time` datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP' DEFAULT_GENERATED on update CURRENT_TIMESTAMP,
  `update_user_id` bigint,
  `version` bigint NOT NULL DEFAULT '0',
  `mobile` varchar(20)
);
