用户,分区,作品的增删改查,根据作者查所有作品的接口,根据用户查还有多少任务没做,帖子和评论的增删改查,并优化了测试文件的结构
Change-Id: I4266495b6465fcbdf5705f02a59d2ae9fa54cbda
diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql
index a36d6ea..53bd187 100644
--- a/src/main/resources/schema.sql
+++ b/src/main/resources/schema.sql
@@ -23,6 +23,37 @@
FOREIGN KEY (`followed_id`) REFERENCES `user`(`user_id`)
);
+-- 新增任务表
+CREATE TABLE `task` (
+ `task_id` INT AUTO_INCREMENT PRIMARY KEY,
+ `user_id` INT NOT NULL,
+ `type` VARCHAR(50) NOT NULL, -- "seed", "post", "comment"
+ `completed` BOOLEAN NOT NULL DEFAULT FALSE,
+ FOREIGN KEY (`user_id`) REFERENCES `user`(`user_id`)
+);
+
+-- 新增帖子表
+CREATE TABLE `post` (
+ `post_id` BIGINT AUTO_INCREMENT PRIMARY KEY,
+ `user_id` INT NOT NULL,
+ `title` VARCHAR(255) NOT NULL,
+ `content` TEXT NOT NULL,
+ `create_time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ `views` INT DEFAULT 0,
+ FOREIGN KEY (`user_id`) REFERENCES `user`(`user_id`)
+);
+
+-- 新增评论表
+CREATE TABLE `comment` (
+ `comment_id` BIGINT AUTO_INCREMENT PRIMARY KEY,
+ `post_id` BIGINT NOT NULL,
+ `user_id` INT NOT NULL,
+ `content` TEXT NOT NULL,
+ `create_time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ FOREIGN KEY (`post_id`) REFERENCES `post`(`post_id`),
+ FOREIGN KEY (`user_id`) REFERENCES `user`(`user_id`)
+);
+
-- 插入语句使用反引号包裹表名和列名
INSERT INTO `user` (
`username`, `email`, `password`, `registration_date`, `identification_number`, `role`