/*
 Navicat Premium Dump SQL

 Source Server         : 本地
 Source Server Type    : MySQL
 Source Server Version : 80406 (8.4.6)
 Source Host           : localhost:3306
 Source Schema         : pet_companion

 Target Server Type    : MySQL
 Target Server Version : 80406 (8.4.6)
 File Encoding         : 65001

 Date: 18/01/2026 18:18:22
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for t_background
-- ----------------------------
DROP TABLE IF EXISTS `t_background`;
CREATE TABLE `t_background`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `resource_url` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `resource_type` int NULL DEFAULT NULL,
  `visibility` int NULL DEFAULT NULL,
  `bgm_url` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `is_locked` tinyint(1) NULL DEFAULT NULL,
  `lock_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `price_points` int NULL DEFAULT NULL,
  `created_at` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  `category` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'default',
  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `thumbnail` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `ix_t_background_id`(`id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of t_background
-- ----------------------------
INSERT INTO `t_background` VALUES (3, '123', '/uploads/2/db678e29-fb5a-4e3b-b1a3-11917180ae98.jpg', 1, 1, NULL, 0, '', 0, '2026-01-18 16:50:25', '2026-01-18 16:50:25', 'default', '123', '/uploads/2/db678e29-fb5a-4e3b-b1a3-11917180ae98.jpg');
INSERT INTO `t_background` VALUES (7, '1232', '/uploads/2/6b438350-cf7d-436d-b3d3-e9cc95a9a402.mp4', 2, 1, NULL, 0, '', 0, '2026-01-18 17:06:57', '2026-01-18 17:06:57', 'default', '1233', '/uploads/2/6b438350-cf7d-436d-b3d3-e9cc95a9a402.mp4');

-- ----------------------------
-- Table structure for t_background_pet_config
-- ----------------------------
DROP TABLE IF EXISTS `t_background_pet_config`;
CREATE TABLE `t_background_pet_config`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `background_id` bigint NOT NULL,
  `pet_id` bigint NOT NULL,
  `coordinate_x` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `coordinate_y` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `scale` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `scene_prompt` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL,
  `hello_message` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `sort_order` int NULL DEFAULT NULL,
  `created_at` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `background_id`(`background_id` ASC, `pet_id` ASC) USING BTREE,
  INDEX `ix_t_background_pet_config_id`(`id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of t_background_pet_config
-- ----------------------------
INSERT INTO `t_background_pet_config` VALUES (1, 4, 5, '70.00', '60.00', '1.00', '当前场景是温馨的卧室，你可以随意撒娇。', '主人，你终于来看我了...', 0, '2026-01-18 16:57:19', '2026-01-18 16:57:19');
INSERT INTO `t_background_pet_config` VALUES (2, 5, 6, '30.00', '50.00', '0.80', '当前场景是海边沙滩，你可以感受到海风和阳光。', '汪汪！欢迎来到海边！', 0, '2026-01-18 16:57:19', '2026-01-18 16:57:19');
INSERT INTO `t_background_pet_config` VALUES (3, 6, 7, '50.00', '40.00', '1.20', '当前场景是宁静的森林，周围有鸟儿歌唱。', '这里是我们的秘密花园呢...', 0, '2026-01-18 16:57:19', '2026-01-18 16:57:19');

-- ----------------------------
-- Table structure for t_chat_log
-- ----------------------------
DROP TABLE IF EXISTS `t_chat_log`;
CREATE TABLE `t_chat_log`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `user_id` bigint NOT NULL,
  `trace_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `pet_id` bigint NOT NULL,
  `bg_id` bigint NOT NULL,
  `user_msg` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL,
  `ai_msg` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL,
  `tokens_input` int NULL DEFAULT NULL,
  `tokens_output` int NULL DEFAULT NULL,
  `duration_ms` int NULL DEFAULT NULL,
  `conversation_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `created_at` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `ix_t_chat_log_id`(`id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of t_chat_log
-- ----------------------------

-- ----------------------------
-- Table structure for t_pet
-- ----------------------------
DROP TABLE IF EXISTS `t_pet`;
CREATE TABLE `t_pet`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `avatar` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `global_prompt` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `tts_voice_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `tts_speed` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `tts_volume` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `status` int NULL DEFAULT NULL,
  `created_at` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `ix_t_pet_id`(`id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of t_pet
-- ----------------------------
INSERT INTO `t_pet` VALUES (1, '小橘猫', 'https://cdn.example.com/pets/orange_cat.png', '你是一只傲娇的橘猫，每句话结尾都要带\'喵\'。', 'tencent_1001', '1.00', '1.00', 1, '2026-01-18 16:56:24', '2026-01-18 16:56:24');
INSERT INTO `t_pet` VALUES (2, '哈士奇', 'https://cdn.example.com/pets/husky.png', '你是一只活泼的哈士奇，说话很兴奋，经常用\'汪\'结尾。', 'tencent_1002', '1.10', '0.90', 1, '2026-01-18 16:56:24', '2026-01-18 16:56:24');
INSERT INTO `t_pet` VALUES (3, '布偶猫', 'https://cdn.example.com/pets/ragdoll_cat.png', '你是一只温柔的布偶猫，说话轻柔，很有礼貌。', 'tencent_1003', '0.90', '0.80', 1, '2026-01-18 16:56:24', '2026-01-18 16:56:24');
INSERT INTO `t_pet` VALUES (4, '柯基', 'https://cdn.example.com/pets/corgi.png', '你是一只可爱的柯基，喜欢卖萌，说话很有趣。', 'tencent_1004', '1.05', '0.95', 1, '2026-01-18 16:56:24', '2026-01-18 16:56:24');
INSERT INTO `t_pet` VALUES (5, '小橘猫', 'https://cdn.example.com/pets/orange_cat.png', '你是一只傲娇的橘猫，每句话结尾都要带\'喵\'。', 'tencent_1001', '1.00', '1.00', 1, '2026-01-18 16:57:19', '2026-01-18 16:57:19');
INSERT INTO `t_pet` VALUES (6, '哈士奇', 'https://cdn.example.com/pets/husky.png', '你是一只活泼的哈士奇，说话很兴奋，经常用\'汪\'结尾。', 'tencent_1002', '1.10', '0.90', 1, '2026-01-18 16:57:19', '2026-01-18 16:57:19');
INSERT INTO `t_pet` VALUES (7, '布偶猫', 'https://cdn.example.com/pets/ragdoll_cat.png', '你是一只温柔的布偶猫，说话轻柔，很有礼貌。', 'tencent_1003', '0.90', '0.80', 1, '2026-01-18 16:57:19', '2026-01-18 16:57:19');
INSERT INTO `t_pet` VALUES (8, '柯基', 'https://cdn.example.com/pets/corgi.png', '你是一只可爱的柯基，喜欢卖萌，说话很有趣。', 'tencent_1004', '1.05', '0.95', 1, '2026-01-18 16:57:19', '2026-01-18 16:57:19');

-- ----------------------------
-- Table structure for t_system_config
-- ----------------------------
DROP TABLE IF EXISTS `t_system_config`;
CREATE TABLE `t_system_config`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `config_key` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `config_value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `created_at` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `config_key`(`config_key` ASC) USING BTREE,
  INDEX `ix_t_system_config_id`(`id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of t_system_config
-- ----------------------------

-- ----------------------------
-- Table structure for t_user
-- ----------------------------
DROP TABLE IF EXISTS `t_user`;
CREATE TABLE `t_user`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `openid` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `phone` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `username` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `password_hash` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `nickname` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `avatar` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `uid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `status` int NULL DEFAULT NULL,
  `created_at` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  `role` int NULL DEFAULT 1 COMMENT '1:普通用户, 2:管理员',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uid`(`uid` ASC) USING BTREE,
  UNIQUE INDEX `ix_t_user_openid`(`openid` ASC) USING BTREE,
  UNIQUE INDEX `ix_t_user_phone`(`phone` ASC) USING BTREE,
  INDEX `ix_t_user_id`(`id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of t_user
-- ----------------------------
INSERT INTO `t_user` VALUES (1, NULL, '13800138002', NULL, 'a04d7eccc493f3323a4de63c0735cfc8$1dbdb814ba94d7e843939057ef3248e077cee2757f6dbfbce4c21ee7473771ff', '测试用户', NULL, 'user_97e021d4', 1, '2026-01-17 14:05:25', '2026-01-17 14:05:25', 1);
INSERT INTO `t_user` VALUES (2, NULL, '19922573675', NULL, '29e503283442b60700e799b5b16567a0$c0ca67b5b5893381f2aa7207ab4d7ec73f60802f7532168d98973a21df8f5896', 'test', NULL, 'user_db4d0323', 1, '2026-01-17 14:10:40', '2026-01-17 20:52:31', 2);
INSERT INTO `t_user` VALUES (3, NULL, '13800138000', NULL, 'b695c471beab3b0b42d40e400b2a97b4$da116ecf2bbeb74d5838a631ecfed47c4fb2c72cbc1a5121619880d050f37a84', '测试用户', NULL, 'user_cc7c4c16', 1, '2026-01-17 14:40:42', '2026-01-17 14:40:42', 1);
INSERT INTO `t_user` VALUES (4, NULL, '13800138888', NULL, '716535158397484de3575fe243bbbd16$3fb2050a686bfa9067a7f130496e034f48203c5d57a4c2907403d123930e2a15', '管理员', NULL, 'admin_user_001', 1, '2026-01-17 15:00:56', '2026-01-17 15:00:56', 2);
INSERT INTO `t_user` VALUES (5, NULL, NULL, 'admin', '6adac9375fe9de52308066fd339ba955$d7839c2893486ca6023f7ceed8313e53c4a4b76824f6c3999fb00f8a23e49295', 'Administrator', NULL, '28ce3c627c0f4f81a2e04e1822c07445', 1, '2026-01-18 15:17:18', '2026-01-18 15:17:18', 2);

-- ----------------------------
-- Table structure for t_user_background_relation
-- ----------------------------
DROP TABLE IF EXISTS `t_user_background_relation`;
CREATE TABLE `t_user_background_relation`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `user_id` bigint NOT NULL,
  `background_id` bigint NOT NULL,
  `is_default` tinyint(1) NULL DEFAULT NULL,
  `created_at` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `user_id`(`user_id` ASC, `background_id` ASC) USING BTREE,
  INDEX `ix_t_user_background_relation_id`(`id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of t_user_background_relation
-- ----------------------------

-- ----------------------------
-- Table structure for t_user_session
-- ----------------------------
DROP TABLE IF EXISTS `t_user_session`;
CREATE TABLE `t_user_session`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `user_id` bigint NOT NULL,
  `session_token` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `refresh_token` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `expires_at` datetime NOT NULL,
  `created_at` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `session_token`(`session_token` ASC) USING BTREE,
  UNIQUE INDEX `refresh_token`(`refresh_token` ASC) USING BTREE,
  INDEX `ix_t_user_session_id`(`id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of t_user_session
-- ----------------------------

-- ----------------------------
-- Table structure for t_user_wallet
-- ----------------------------
DROP TABLE IF EXISTS `t_user_wallet`;
CREATE TABLE `t_user_wallet`  (
  `user_id` bigint NOT NULL AUTO_INCREMENT,
  `daily_quota` int NULL DEFAULT NULL,
  `extra_quota` int NULL DEFAULT NULL,
  `total_consumed` int NULL DEFAULT NULL,
  `last_reset_time` date NULL DEFAULT NULL,
  `created_at` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`user_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of t_user_wallet
-- ----------------------------
INSERT INTO `t_user_wallet` VALUES (1, 20, 0, 0, '2026-01-17', '2026-01-17 14:05:25', '2026-01-17 14:05:25');
INSERT INTO `t_user_wallet` VALUES (2, 20, 0, 0, '2026-01-17', '2026-01-17 14:10:40', '2026-01-17 14:10:40');
INSERT INTO `t_user_wallet` VALUES (3, 20, 0, 0, '2026-01-17', '2026-01-17 14:40:42', '2026-01-17 14:40:42');

SET FOREIGN_KEY_CHECKS = 1;
