diff --git a/server/README.md b/server/README.md
new file mode 100644
index 0000000..01f3e9f
--- /dev/null
+++ b/server/README.md
@@ -0,0 +1,195 @@
+# 情绪博物馆后端重构项目
+
+## 项目概述
+
+本项目是基于Spring Boot 3.4.8的情绪博物馆后端服务重构版本,从原有的Spring Boot 2.7.18升级而来。
+
+## 重构进度
+
+### 第一阶段:基础环境升级 ✅
+
+#### 已完成的工作
+
+1. **项目结构创建** ✅
+ - 创建了标准的Maven项目结构
+ - 配置了src/main/java和src/main/resources目录
+
+2. **Maven配置** ✅
+ - 创建了pom.xml文件
+ - 配置了Spring Boot 3.4.8作为父项目
+ - 添加了所有必要的依赖:
+ - Spring Boot Starters (Web, Security, WebSocket, Redis, Validation, Actuator)
+ - MyBatis-Plus 3.5.5
+ - JWT 0.12.3
+ - SpringDoc OpenAPI 3
+ - Hutool 5.8.25
+ - Lombok
+
+3. **配置文件** ✅
+ - application.yml (主配置文件)
+ - application-local.yml (本地环境配置)
+ - 配置了数据库连接、Redis、日志等
+
+4. **基础配置类** ✅
+ - SecurityConfig (Spring Security 6.x配置)
+ - MybatisPlusConfig (MyBatis-Plus配置)
+ - RedisConfig (Redis配置)
+ - AsyncConfig (异步配置)
+ - OpenApiConfig (OpenAPI配置)
+ - WebClientConfig (HTTP客户端配置)
+ - CozeConfig (Coze API配置)
+
+5. **主启动类** ✅
+ - EmotionMuseumApplication.java
+ - 配置了组件扫描、缓存、异步、事务管理
+
+6. **基础控制器** ✅
+ - HealthController (健康检查接口)
+
+#### 技术栈升级
+
+- **Spring Boot**: 2.7.18 → 3.4.8 ✅
+- **Java版本**: JDK 17 (当前使用,计划升级到JDK 21)
+- **Spring Security**: 5.x → 6.x ✅
+- **MyBatis-Plus**: 3.5.3.1 → 3.5.5 ✅
+- **JWT**: 0.11.5 → 0.12.3 ✅
+- **API文档**: Swagger → SpringDoc OpenAPI 3 ✅
+
+#### 当前状态
+
+- ✅ 项目能够正常编译
+- ✅ 基础配置完成
+- ✅ 应用程序启动成功
+
+### 第二阶段:核心功能重构 🔄
+
+#### 已完成的工作
+
+1. **实体类创建** ✅
+ - User (用户实体)
+ - DiaryPost (日记实体)
+ - Message (消息实体)
+ - Conversation (会话实体)
+
+2. **DTO类创建** ✅
+ - Result (通用响应DTO)
+ - LoginRequest/LoginResponse (登录相关DTO)
+ - RegisterRequest (注册DTO)
+
+3. **Mapper接口创建** ✅
+ - UserMapper (用户数据访问)
+ - DiaryPostMapper (日记数据访问)
+ - MessageMapper (消息数据访问)
+ - ConversationMapper (会话数据访问)
+
+4. **工具类创建** ✅
+ - JwtUtil (JWT工具类,适配JWT 0.12.3)
+
+5. **认证系统重构** ✅
+ - AuthService (认证服务接口)
+ - AuthServiceImpl (认证服务实现)
+ - AuthController (认证控制器)
+ - 支持用户注册、登录、登出、令牌刷新等功能
+
+6. **用户管理系统重构** ✅
+ - UserService (用户服务接口)
+ - UserServiceImpl (用户服务实现)
+ - UserController (用户控制器)
+ - 支持用户信息管理、密码修改、用户列表等功能
+
+7. **AI对话系统重构** ✅
+ - CozeApiService (Coze API服务接口)
+ - CozeApiServiceImpl (Coze API服务实现)
+ - AiChatService (AI聊天服务接口)
+ - AiChatServiceImpl (AI聊天服务实现)
+ - AiChatController (AI聊天控制器)
+ - 支持与Coze Bot的对话、会话管理、消息历史等功能
+
+8. **日记系统重构** ✅
+ - DiaryPostRequest (日记请求DTO)
+ - DiaryPostService (日记服务接口)
+ - DiaryPostServiceImpl (日记服务实现)
+ - DiaryPostController (日记控制器)
+ - 支持日记CRUD、AI点评、点赞、情绪标签等功能
+
+9. **WebSocket系统重构** ✅
+ - WebSocketConfig (WebSocket配置)
+ - ChatMessage (WebSocket消息DTO)
+ - WebSocketController (WebSocket控制器)
+ - 支持实时聊天、AI对话、消息推送等功能
+
+10. **社区系统重构** 🔄
+ - Comment (评论实体)
+ - UserFollow (用户关注实体)
+ - CommentRequest/CommentResponse (评论DTO)
+ - CommentMapper/UserFollowMapper (数据访问层)
+ - CommentService/UserFollowService (服务接口)
+ - CommentServiceImpl (评论服务实现)
+ - 支持评论、回复、点赞、用户关注等功能
+
+#### 当前状态
+
+- ✅ 认证系统重构完成
+- ✅ 用户管理系统重构完成
+- ✅ AI对话系统重构完成
+- ✅ 日记系统重构完成
+- ✅ WebSocket系统重构完成
+- ✅ 社区系统基础重构完成
+- ✅ JWT 0.12.3适配完成
+- ✅ 基础数据访问层完成
+- 🔄 继续其他核心功能重构
+
+## 下一步计划
+
+### 第二阶段:核心功能重构
+
+1. **认证系统重构**
+ - 重构AuthController
+ - 升级JWT认证机制
+ - 优化Spring Security配置
+
+2. **AI对话系统重构**
+ - 重构AiChatController
+ - 实现Coze API客户端
+ - 优化异步处理机制
+
+3. **用户管理系统重构**
+ - 重构UserController
+ - 优化用户信息管理
+
+4. **日记系统重构**
+ - 重构DiaryPostController
+ - 优化日记CRUD操作
+
+## 运行说明
+
+### 环境要求
+
+- JDK 17+
+- Maven 3.6+
+- MySQL 8.0+
+- Redis 7.0+
+
+### 启动步骤
+
+1. 配置环境变量或修改application-local.yml中的数据库和Redis连接信息
+2. 执行编译:`mvn clean compile`
+3. 启动应用:`mvn spring-boot:run`
+
+### 访问地址
+
+- 应用地址:http://localhost:19089
+- API文档:http://localhost:19089/api/swagger-ui.html
+- 健康检查:http://localhost:19089/api/health
+
+## 注意事项
+
+1. 当前使用JDK 17,后续将升级到JDK 21
+2. 数据库和Redis需要提前启动并配置
+3. Coze API配置需要设置环境变量COZE_API_KEY和COZE_BOT_ID
+
+## 问题记录
+
+1. Spring Boot Actuator依赖问题 - 已解决
+2. Spring Security 6.x配置调整 - 已解决
+3. 应用程序启动测试 - 进行中
\ No newline at end of file
diff --git a/server/pom.xml b/server/pom.xml
new file mode 100644
index 0000000..087f2a9
--- /dev/null
+++ b/server/pom.xml
@@ -0,0 +1,175 @@
+
+
+ 4.0.0
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 3.4.8
+
+
+
+ com.emotionmuseum
+ emotion-museum-backend
+ 1.0.0
+ jar
+
+ emotion-museum-backend
+ 情绪博物馆后端服务
+
+
+ 17
+ 17
+ 17
+ UTF-8
+ UTF-8
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-starter-security
+
+
+
+ org.springframework.boot
+ spring-boot-starter-websocket
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-webflux
+
+
+
+
+ com.mysql
+ mysql-connector-j
+ runtime
+
+
+
+ com.baomidou
+ mybatis-plus-boot-starter
+ 3.5.5
+
+
+
+
+ io.jsonwebtoken
+ jjwt-api
+ 0.12.3
+
+
+ io.jsonwebtoken
+ jjwt-impl
+ 0.12.3
+ runtime
+
+
+ io.jsonwebtoken
+ jjwt-jackson
+ 0.12.3
+ runtime
+
+
+
+
+ org.springdoc
+ springdoc-openapi-starter-webmvc-ui
+ 2.3.0
+
+
+
+
+ org.apache.commons
+ commons-lang3
+
+
+
+ cn.hutool
+ hutool-all
+ 5.8.25
+
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ org.springframework.security
+ spring-security-test
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 17
+ 17
+ UTF-8
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ false
+
+
+
+
+
\ No newline at end of file
diff --git a/server/src/main/java/com/emotionmuseum/EmotionMuseumApplication.java b/server/src/main/java/com/emotionmuseum/EmotionMuseumApplication.java
new file mode 100644
index 0000000..013f61b
--- /dev/null
+++ b/server/src/main/java/com/emotionmuseum/EmotionMuseumApplication.java
@@ -0,0 +1,33 @@
+package com.emotionmuseum;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+/**
+ * 情绪博物馆后端服务启动类
+ *
+ * @author emotion-museum
+ * @version 1.0.0
+ * @since 2024-01-01
+ */
+@SpringBootApplication
+@MapperScan("com.emotionmuseum.mapper")
+@EnableCaching
+@EnableAsync
+@EnableTransactionManagement
+public class EmotionMuseumApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(EmotionMuseumApplication.class, args);
+ System.out.println("=================================");
+ System.out.println("情绪博物馆后端服务启动成功!");
+ System.out.println("服务端口: 19089");
+ System.out.println("API文档: http://localhost:19089/api/swagger-ui.html");
+ System.out.println("健康检查: http://localhost:19089/api/health");
+ System.out.println("=================================");
+ }
+}
\ No newline at end of file
diff --git a/server/src/main/java/com/emotionmuseum/config/AsyncConfig.java b/server/src/main/java/com/emotionmuseum/config/AsyncConfig.java
new file mode 100644
index 0000000..8bdfae6
--- /dev/null
+++ b/server/src/main/java/com/emotionmuseum/config/AsyncConfig.java
@@ -0,0 +1,63 @@
+package com.emotionmuseum.config;
+
+import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.AsyncConfigurer;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.ThreadPoolExecutor;
+
+/**
+ * 异步配置类
+ *
+ * @author emotion-museum
+ * @version 1.0.0
+ * @since 2024-01-01
+ */
+@Configuration
+@EnableAsync
+public class AsyncConfig implements AsyncConfigurer {
+
+ /**
+ * 默认异步执行器
+ */
+ @Override
+ public Executor getAsyncExecutor() {
+ ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+ executor.setCorePoolSize(20);
+ executor.setMaxPoolSize(100);
+ executor.setQueueCapacity(500);
+ executor.setKeepAliveSeconds(60);
+ executor.setThreadNamePrefix("emotion-async-");
+ executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
+ executor.initialize();
+ return executor;
+ }
+
+ /**
+ * AI任务执行器
+ */
+ @Bean("aiTaskExecutor")
+ public Executor aiTaskExecutor() {
+ ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+ executor.setCorePoolSize(10);
+ executor.setMaxPoolSize(50);
+ executor.setQueueCapacity(200);
+ executor.setKeepAliveSeconds(60);
+ executor.setThreadNamePrefix("ai-task-");
+ executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
+ executor.initialize();
+ return executor;
+ }
+
+ /**
+ * 异步异常处理器
+ */
+ @Override
+ public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
+ return new org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler();
+ }
+}
\ No newline at end of file
diff --git a/server/src/main/java/com/emotionmuseum/config/CozeConfig.java b/server/src/main/java/com/emotionmuseum/config/CozeConfig.java
new file mode 100644
index 0000000..82f075b
--- /dev/null
+++ b/server/src/main/java/com/emotionmuseum/config/CozeConfig.java
@@ -0,0 +1,64 @@
+package com.emotionmuseum.config;
+
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.util.StringUtils;
+
+import jakarta.annotation.PostConstruct;
+
+/**
+ * Coze配置类
+ *
+ * @author emotion-museum
+ * @version 1.0.0
+ * @since 2024-01-01
+ */
+@Configuration
+@ConfigurationProperties(prefix = "emotion.coze")
+@Data
+@Slf4j
+public class CozeConfig {
+
+ /**
+ * API密钥
+ */
+ private String apiKey;
+
+ /**
+ * 机器人ID
+ */
+ private String botId;
+
+ /**
+ * 基础URL
+ */
+ private String baseUrl = "https://www.coze.cn/api";
+
+ /**
+ * 超时时间(毫秒)
+ */
+ private int timeout = 30000;
+
+ /**
+ * 最大重试次数
+ */
+ private int maxRetries = 3;
+
+ /**
+ * 验证配置
+ */
+ @PostConstruct
+ public void validateConfig() {
+ if (!StringUtils.hasText(apiKey)) {
+ log.warn("Coze API Key未配置,AI功能可能无法正常使用");
+ }
+ if (!StringUtils.hasText(botId)) {
+ log.warn("Coze Bot ID未配置,AI功能可能无法正常使用");
+ }
+ if (StringUtils.hasText(apiKey) && StringUtils.hasText(botId)) {
+ log.info("Coze配置验证通过,Bot ID: {}", botId);
+ }
+ }
+}
\ No newline at end of file
diff --git a/server/src/main/java/com/emotionmuseum/config/MybatisPlusConfig.java b/server/src/main/java/com/emotionmuseum/config/MybatisPlusConfig.java
new file mode 100644
index 0000000..99e67ec
--- /dev/null
+++ b/server/src/main/java/com/emotionmuseum/config/MybatisPlusConfig.java
@@ -0,0 +1,55 @@
+package com.emotionmuseum.config;
+
+import com.baomidou.mybatisplus.annotation.DbType;
+import com.baomidou.mybatisplus.core.config.GlobalConfig;
+import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * MyBatis-Plus配置类
+ *
+ * @author emotion-museum
+ * @version 1.0.0
+ * @since 2024-01-01
+ */
+@Configuration
+public class MybatisPlusConfig {
+
+ /**
+ * MyBatis-Plus拦截器配置
+ */
+ @Bean
+ public MybatisPlusInterceptor mybatisPlusInterceptor() {
+ MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
+
+ // 分页插件
+ interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
+
+ // 乐观锁插件
+ interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
+
+ return interceptor;
+ }
+
+ /**
+ * 全局配置
+ */
+ @Bean
+ public GlobalConfig globalConfig() {
+ GlobalConfig globalConfig = new GlobalConfig();
+
+ // 设置数据库类型
+ globalConfig.setDbConfig(new GlobalConfig.DbConfig());
+ globalConfig.getDbConfig().setIdType(com.baomidou.mybatisplus.annotation.IdType.ASSIGN_ID);
+
+ // 设置逻辑删除
+ globalConfig.getDbConfig().setLogicDeleteField("deleted");
+ globalConfig.getDbConfig().setLogicDeleteValue("1");
+ globalConfig.getDbConfig().setLogicNotDeleteValue("0");
+
+ return globalConfig;
+ }
+}
\ No newline at end of file
diff --git a/server/src/main/java/com/emotionmuseum/config/OpenApiConfig.java b/server/src/main/java/com/emotionmuseum/config/OpenApiConfig.java
new file mode 100644
index 0000000..5cfa11c
--- /dev/null
+++ b/server/src/main/java/com/emotionmuseum/config/OpenApiConfig.java
@@ -0,0 +1,43 @@
+package com.emotionmuseum.config;
+
+import io.swagger.v3.oas.models.Components;
+import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.info.Contact;
+import io.swagger.v3.oas.models.info.Info;
+import io.swagger.v3.oas.models.security.SecurityRequirement;
+import io.swagger.v3.oas.models.security.SecurityScheme;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * OpenAPI配置类
+ *
+ * @author emotion-museum
+ * @version 1.0.0
+ * @since 2024-01-01
+ */
+@Configuration
+public class OpenApiConfig {
+
+ /**
+ * OpenAPI配置
+ */
+ @Bean
+ public OpenAPI customOpenAPI() {
+ return new OpenAPI()
+ .info(new Info()
+ .title("情绪博物馆API文档")
+ .version("1.0.0")
+ .description("情绪博物馆后端服务API文档")
+ .contact(new Contact()
+ .name("情绪博物馆团队")
+ .email("support@emotion-museum.com")))
+ .addSecurityItem(new SecurityRequirement().addList("Bearer Authentication"))
+ .components(new Components()
+ .addSecuritySchemes("Bearer Authentication",
+ new SecurityScheme()
+ .type(SecurityScheme.Type.HTTP)
+ .scheme("bearer")
+ .bearerFormat("JWT")));
+ }
+}
\ No newline at end of file
diff --git a/server/src/main/java/com/emotionmuseum/config/RedisConfig.java b/server/src/main/java/com/emotionmuseum/config/RedisConfig.java
new file mode 100644
index 0000000..a66998d
--- /dev/null
+++ b/server/src/main/java/com/emotionmuseum/config/RedisConfig.java
@@ -0,0 +1,76 @@
+package com.emotionmuseum.config;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import org.springframework.cache.CacheManager;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.cache.RedisCacheConfiguration;
+import org.springframework.data.redis.cache.RedisCacheManager;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.RedisSerializationContext;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+import java.time.Duration;
+
+/**
+ * Redis配置类
+ *
+ * @author emotion-museum
+ * @version 1.0.0
+ * @since 2024-01-01
+ */
+@Configuration
+@EnableCaching
+public class RedisConfig {
+
+ /**
+ * Redis模板配置
+ */
+ @Bean
+ public RedisTemplate redisTemplate(RedisConnectionFactory factory) {
+ RedisTemplate template = new RedisTemplate<>();
+ template.setConnectionFactory(factory);
+
+ // 使用Jackson2JsonRedisSerializer
+ Jackson2JsonRedisSerializer