-- MySQL dump 10.13  Distrib 5.7.44, for Linux (x86_64)
--
-- Host: localhost    Database: sonic-bear
-- ------------------------------------------------------
-- Server version	5.7.44-log

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `app_client`
--

DROP TABLE IF EXISTS `app_client`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `app_client` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `code` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '编码',
  `desc` varchar(256) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '描述',
  `allow_account_types` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '[]' COMMENT '允许登陆的账号类型',
  `session_alive` int(11) NOT NULL COMMENT 'session存活时间,单位为分钟',
  `session_expired` int(11) NOT NULL COMMENT 'session过期时间,单位为分钟',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `edit_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `udx_client_code` (`code`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='客户端';
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `user`
--

DROP TABLE IF EXISTS `user`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `user_id` bigint(20) NOT NULL COMMENT '用户ID（至少15位）',
  `id_card` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'ID编号',
  `head_image` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '用户头像',
  `nickname` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '昵称',
  `birthday` datetime DEFAULT NULL COMMENT '生日',
  `sex` tinyint(4) DEFAULT NULL COMMENT '性别（0 男、1 女、2 未知）',
  `account_type` tinyint(4) DEFAULT '1' COMMENT '账号类型（1 用户、2 后台）',
  `account_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '账户状态（0 正常、1 禁用、2 锁定）',
  `last_access_time` datetime DEFAULT NULL COMMENT '最后访问时间',
  `is_delete` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否删除（0 否、1 是）',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `edit_id` bigint(20) NOT NULL COMMENT '编辑人',
  `edit_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '编辑时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `_uqe_user_user_id` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=93 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `user_access_log`
--

DROP TABLE IF EXISTS `user_access_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user_access_log` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) NOT NULL COMMENT 'id',
  `client_code` varchar(16) COLLATE utf8mb4_bin DEFAULT NULL,
  `access_time` timestamp NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_user_access_log_user_id_access_time` (`user_id`,`access_time`) USING BTREE,
  KEY `idx_user_access_log_access_time` (`access_time`)
) ENGINE=InnoDB AUTO_INCREMENT=1510 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `user_commonly_used_log`
--

DROP TABLE IF EXISTS `user_commonly_used_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user_commonly_used_log` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `user_id` bigint(20) DEFAULT NULL COMMENT '用户ID',
  `data_type` int(10) DEFAULT NULL COMMENT '数据类型（1 IP地址、2 设备号）',
  `data_value` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '数据值',
  `use_count` int(20) DEFAULT NULL COMMENT '使用次数',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `edit_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '编辑时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `_uqe_user_commonly_used_log_user_id_type_value` (`user_id`,`data_type`,`data_value`),
  KEY `_idx_user_commonly_used_log_user_id_value` (`user_id`,`data_value`)
) ENGINE=InnoDB AUTO_INCREMENT=591 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户常用日志';
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `user_nickname_pool`
--

DROP TABLE IF EXISTS `user_nickname_pool`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user_nickname_pool` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `user_id` bigint(20) NOT NULL COMMENT '用户ID（普通用户ID、AI用户ID）',
  `user_type` tinyint(4) NOT NULL COMMENT '用户类型（1 USER、2 AI）',
  `nickname` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '昵称',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `_uqe_user_nickname_pool_user_id_user_type` (`user_id`,`user_type`),
  UNIQUE KEY `_idx_user_nickname_pool_nickname` (`nickname`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=709 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户昵称数据池';
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `user_session`
--

DROP TABLE IF EXISTS `user_session`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user_session` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `token` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '登陆授权码',
  `user_id` bigint(20) NOT NULL COMMENT '用户ID',
  `account_type` varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '登陆的账号类型',
  `client_code` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '客户端编码',
  `login_type` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '登录类型（账号密码、三方、手机号验证码）',
  `status` varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'ENABLED' COMMENT 'session 状态，默认为有效',
  `user_agent` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '客户端设备信息',
  `extra` varchar(1024) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '{}' COMMENT '扩展数据，json字符串',
  `device_id` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '设备ID',
  `ip` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'IP地址',
  `last_access_time` timestamp NOT NULL COMMENT 'session 最后一次访问时间',
  `expire_time` timestamp NOT NULL COMMENT 'session 过期/结束时间',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'session 创建时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `udx_user_session_token` (`token`),
  KEY `idx_user_session_user_client` (`user_id`,`client_code`),
  KEY `_idx_user_sesseion_expire_time` (`expire_time`) USING BTREE,
  KEY `_idx_user_sesseion_create_time` (`create_time`),
  KEY `idx_user_session_user_client_status` (`user_id`,`client_code`,`status`),
  KEY `_idx_user_session_ip` (`ip`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=751 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户会话信息';
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `user_third`
--

DROP TABLE IF EXISTS `user_third`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user_third` (
  `id` bigint(20) NOT NULL COMMENT '主键ID',
  `user_id` bigint(20) DEFAULT NULL COMMENT '用户ID',
  `third_type` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '三方类型（DISCORD、GOOGLE、APPLE）',
  `open_id` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '三方ID',
  `nickname` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '昵称',
  `email` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '邮箱',
  `is_delete` tinyint(4) DEFAULT NULL COMMENT '是否删除（0 否、1 是）',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `edit_id` bigint(20) DEFAULT NULL COMMENT '编辑人',
  `edit_time` datetime DEFAULT NULL COMMENT '编辑时间',
  PRIMARY KEY (`id`),
  KEY `_idx_user_third_user_id` (`user_id`),
  KEY `_idx_user_third_open_id` (`open_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2025-11-13  2:20:41
