修复了数据库启动相关的问题
Change-Id: If16797ad92f9a40a34c3bf632aa13c1f45e522aa
diff --git a/src/main/resources/mapper/PostRatingMapper.xml b/src/main/resources/mapper/PostRatingMapper.xml
index 097eeb8..bb13dd4 100644
--- a/src/main/resources/mapper/PostRatingMapper.xml
+++ b/src/main/resources/mapper/PostRatingMapper.xml
@@ -1,5 +1,10 @@
-<insert id="insertOrUpdate">
- INSERT INTO post_ratings (user_id, post_id, rating)
- VALUES (#{userId}, #{postId}, #{rating})
- ON DUPLICATE KEY UPDATE rating = VALUES(rating)
-</insert>
\ No newline at end of file
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.example.mapper.PostRatingMapper">
+ <insert id="insertOrUpdate">
+ INSERT INTO post_ratings (user_id, post_id, rating)
+ VALUES (#{userId}, #{postId}, #{rating})
+ ON DUPLICATE KEY UPDATE rating = VALUES(rating)
+ </insert>
+</mapper>
\ No newline at end of file
diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql
index 4a3621e..e5faa3f 100644
--- a/src/main/resources/schema.sql
+++ b/src/main/resources/schema.sql
@@ -57,7 +57,7 @@
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_calculated` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后热度计算时间',
`average_rating` DECIMAL(3,2) DEFAULT 0.00 COMMENT '帖子平均评分',
- `rating_count` INT DEFAULT 0 COMMENT '总评分人数';
+ `rating_count` INT DEFAULT 0 COMMENT '总评分人数',
FOREIGN KEY (`user_id`) REFERENCES `users`(`user_id`),
FOREIGN KEY (`torrent_id`) REFERENCES `torrents`(`torrent_id`),
INDEX `idx_hot_score` (`hot_score`), -- 新增热度索引
@@ -147,7 +147,7 @@
PRIMARY KEY (`user_id`, `post_id`), -- 确保每个用户对同一帖子只能评分一次
FOREIGN KEY (`user_id`) REFERENCES `users`(`user_id`),
FOREIGN KEY (`post_id`) REFERENCES `posts`(`post_id`),
- INDEX idx_post_ratings_post_id ON post_ratings (post_id)
+ INDEX idx_post_ratings_post_id (post_id)
);
CREATE TABLE IF NOT EXISTS `reports` (
@@ -167,7 +167,7 @@
CREATE TABLE IF NOT EXISTS `user_signin` (
`signin_id` BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT '签到记录ID',
- `user_id` BIGINT NOT NULL COMMENT '用户ID',
+ `user_id` INT NOT NULL COMMENT '用户ID',
`signin_date` DATE NOT NULL COMMENT '签到日期',
FOREIGN KEY (`user_id`) REFERENCES `users`(`user_id`) ON DELETE CASCADE,
UNIQUE KEY `unique_user_daily_signin` (`user_id`, `signin_date`) -- 唯一约束:用户每日只能签到一次