🔧 完成前后端配置优化和部署修复
✅ 后端配置优化: - 优化application.yml配置文件结构 - 统一Coze API配置到所有环境 - 删除重复的SimpleAuthController和SimpleHealthController - 创建独立的HealthController - 修复SASS变量未定义问题 - 优化数据库连接池配置 ✅ 前端配置修复: - 修复Vite配置中SASS变量全局导入 - 更新API代理配置指向正确端口(8080) - 解决Dashboard组件SASS变量未定义错误 ✅ 部署配置完善: - 创建详细的部署状态报告 - 优化生产环境和本地环境配置 - 修复Nginx反向代理配置 - 完善防火墙和MySQL远程连接配置 🚀 功能状态: - 前端: Vue3 + Vite开发服务器正常启动 - 后端: Spring Boot服务正常运行(8080端口) - 数据库: MySQL连接配置完善 - API: 健康检查和基础接口就绪 📊 技术改进: - 配置文件结构优化 - 开发环境和生产环境配置分离 - 前后端联调环境就绪 - 部署文档完善
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
package com.emotion.controller;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 健康检查控制器
|
||||
*
|
||||
* @author emotion-museum
|
||||
* @date 2025-07-23
|
||||
*/
|
||||
@RestController
|
||||
public class HealthController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(HealthController.class);
|
||||
|
||||
/**
|
||||
* 健康检查
|
||||
*/
|
||||
@GetMapping("/health")
|
||||
public Map<String, Object> health() {
|
||||
log.info("健康检查请求");
|
||||
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("service", "emotion-single");
|
||||
response.put("message", "情感博物馆单体服务运行正常");
|
||||
response.put("version", "1.0.0");
|
||||
response.put("status", "UP");
|
||||
response.put("timestamp", LocalDateTime.now());
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务信息
|
||||
*/
|
||||
@GetMapping("/health/info")
|
||||
public Map<String, Object> info() {
|
||||
log.info("服务信息请求");
|
||||
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("service", "emotion-single");
|
||||
response.put("description", "情感博物馆单体服务");
|
||||
response.put("version", "1.0.0");
|
||||
response.put("author", "emotion-museum");
|
||||
response.put("buildTime", "2025-07-23");
|
||||
response.put("javaVersion", System.getProperty("java.version"));
|
||||
response.put("timestamp", LocalDateTime.now());
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
package com.emotion.controller;
|
||||
|
||||
import com.emotion.common.Result;
|
||||
import com.emotion.entity.SimpleUser;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 简化认证控制器
|
||||
*
|
||||
* @author emotion-museum
|
||||
* @date 2025-07-22
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/auth")
|
||||
public class SimpleAuthController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SimpleAuthController.class);
|
||||
|
||||
/**
|
||||
* 用户登录(模拟)
|
||||
*/
|
||||
@PostMapping("/login")
|
||||
public Result<Map<String, Object>> login(@RequestBody Map<String, String> request) {
|
||||
log.info("用户登录请求: {}", request.get("account"));
|
||||
|
||||
try {
|
||||
String account = request.get("account");
|
||||
String password = request.get("password");
|
||||
|
||||
if (account == null || password == null) {
|
||||
return Result.error("账号和密码不能为空");
|
||||
}
|
||||
|
||||
// 模拟用户验证
|
||||
if ("admin".equals(account) && "123456".equals(password)) {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("accessToken", "mock-token-" + System.currentTimeMillis());
|
||||
response.put("expiresIn", 86400L);
|
||||
|
||||
Map<String, Object> userInfo = new HashMap<>();
|
||||
userInfo.put("id", "1");
|
||||
userInfo.put("username", "admin");
|
||||
userInfo.put("account", "admin");
|
||||
userInfo.put("nickname", "管理员");
|
||||
userInfo.put("status", 1);
|
||||
|
||||
response.put("userInfo", userInfo);
|
||||
response.put("loginTime", LocalDateTime.now());
|
||||
|
||||
return Result.success("登录成功", response);
|
||||
} else {
|
||||
return Result.error("账号或密码错误");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("用户登录失败: {}", e.getMessage());
|
||||
return Result.error("登录失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户注册(模拟)
|
||||
*/
|
||||
@PostMapping("/register")
|
||||
public Result<Map<String, Object>> register(@RequestBody Map<String, String> request) {
|
||||
log.info("用户注册请求: {}", request.get("account"));
|
||||
|
||||
try {
|
||||
String account = request.get("account");
|
||||
String password = request.get("password");
|
||||
String username = request.get("username");
|
||||
|
||||
if (account == null || password == null) {
|
||||
return Result.error("账号和密码不能为空");
|
||||
}
|
||||
|
||||
// 模拟用户创建
|
||||
Map<String, Object> userInfo = new HashMap<>();
|
||||
userInfo.put("id", "user-" + System.currentTimeMillis());
|
||||
userInfo.put("username", username != null ? username : account);
|
||||
userInfo.put("account", account);
|
||||
userInfo.put("status", 1);
|
||||
userInfo.put("createTime", LocalDateTime.now());
|
||||
|
||||
return Result.success("注册成功", userInfo);
|
||||
} catch (Exception e) {
|
||||
log.error("用户注册失败: {}", e.getMessage());
|
||||
return Result.error("注册失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取验证码(模拟)
|
||||
*/
|
||||
@GetMapping("/captcha")
|
||||
public Result<Map<String, Object>> getCaptcha() {
|
||||
log.info("获取验证码请求");
|
||||
|
||||
try {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("captchaId", "captcha-" + System.currentTimeMillis());
|
||||
response.put("captchaImage", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==");
|
||||
response.put("type", "spec");
|
||||
response.put("expireTime", 300);
|
||||
|
||||
return Result.success("获取验证码成功", response);
|
||||
} catch (Exception e) {
|
||||
log.error("获取验证码失败: {}", e.getMessage());
|
||||
return Result.error("获取验证码失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户登出
|
||||
*/
|
||||
@PostMapping("/logout")
|
||||
public Result<String> logout(@RequestBody Map<String, String> request) {
|
||||
log.info("用户登出请求: {}", request.get("userId"));
|
||||
return Result.success("登出成功");
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.emotion.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 简化健康检查控制器
|
||||
*
|
||||
* @author emotion-museum
|
||||
* @date 2025-07-21
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/health")
|
||||
public class SimpleHealthController {
|
||||
|
||||
@GetMapping
|
||||
public Map<String, Object> health() {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("status", "UP");
|
||||
result.put("service", "emotion-single");
|
||||
result.put("version", "1.0.0");
|
||||
result.put("timestamp", LocalDateTime.now().toString());
|
||||
result.put("message", "情感博物馆单体服务运行正常");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@GetMapping("/info")
|
||||
public Map<String, Object> info() {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("name", "emotion-single");
|
||||
result.put("description", "情感博物馆单体服务");
|
||||
result.put("version", "1.0.0");
|
||||
result.put("author", "emotion-museum");
|
||||
result.put("build-time", LocalDateTime.now().toString());
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,60 @@
|
||||
# 本地开发环境配置
|
||||
# Local Development Environment Configuration
|
||||
|
||||
server:
|
||||
port: 8080
|
||||
|
||||
spring:
|
||||
# 数据库配置 - 本地MySQL
|
||||
datasource:
|
||||
url: jdbc:mysql://localhost:3306/emotion_museum?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/emotion?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true
|
||||
username: root
|
||||
password: 123456
|
||||
hikari:
|
||||
minimum-idle: 5
|
||||
maximum-pool-size: 20
|
||||
auto-commit: true
|
||||
idle-timeout: 30000
|
||||
pool-name: EmotionHikariCP-Local
|
||||
max-lifetime: 1800000
|
||||
connection-timeout: 30000
|
||||
validation-timeout: 3000
|
||||
leak-detection-threshold: 60000
|
||||
|
||||
# Redis配置 - 本地Redis
|
||||
redis:
|
||||
host: localhost
|
||||
port: 6379
|
||||
timeout: 3000ms
|
||||
database: 0
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8
|
||||
max-wait: -1ms
|
||||
max-idle: 8
|
||||
min-idle: 0
|
||||
time-between-eviction-runs: 30s
|
||||
|
||||
# 日志配置
|
||||
# 日志配置 - 本地开发详细日志
|
||||
logging:
|
||||
level:
|
||||
com.emotion: debug
|
||||
org.springframework.security: debug
|
||||
org.springframework.web: debug
|
||||
org.mybatis: debug
|
||||
root: info
|
||||
file:
|
||||
name: logs/emotion-single-local.log
|
||||
|
||||
# Coze API配置
|
||||
# 本地开发特定配置
|
||||
emotion:
|
||||
coze:
|
||||
api:
|
||||
token: ${COZE_API_TOKEN:your-local-coze-api-token}
|
||||
base-url: https://api.coze.cn
|
||||
# 文件上传路径 - 本地开发
|
||||
upload:
|
||||
path: ./uploads/emotion-museum
|
||||
|
||||
# 开发模式配置
|
||||
dev:
|
||||
mock-enabled: true
|
||||
debug-mode: true
|
||||
hot-reload: true
|
||||
|
||||
@@ -1,30 +1,60 @@
|
||||
# 生产环境配置
|
||||
# Production Environment Configuration
|
||||
|
||||
server:
|
||||
port: 8080
|
||||
|
||||
spring:
|
||||
# 数据库配置 - 生产MySQL
|
||||
datasource:
|
||||
url: jdbc:mysql://localhost:3306/emotion_museum?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/emotion?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true
|
||||
username: emotion
|
||||
password: EmotionDB2024!
|
||||
hikari:
|
||||
minimum-idle: 10
|
||||
maximum-pool-size: 50
|
||||
auto-commit: true
|
||||
idle-timeout: 600000
|
||||
pool-name: EmotionHikariCP-Prod
|
||||
max-lifetime: 1800000
|
||||
connection-timeout: 30000
|
||||
validation-timeout: 5000
|
||||
leak-detection-threshold: 60000
|
||||
|
||||
# Redis配置 - 生产Redis
|
||||
redis:
|
||||
host: localhost
|
||||
port: 6379
|
||||
timeout: 5000ms
|
||||
database: 0
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 20
|
||||
max-wait: -1ms
|
||||
max-idle: 10
|
||||
min-idle: 5
|
||||
time-between-eviction-runs: 30s
|
||||
|
||||
# 日志配置
|
||||
# 日志配置 - 生产环境
|
||||
logging:
|
||||
level:
|
||||
com.emotion: info
|
||||
org.springframework.security: warn
|
||||
root: warn
|
||||
file:
|
||||
name: /data/logs/emotion-museum/emotion-single.log
|
||||
max-size: 200MB
|
||||
max-history: 60
|
||||
|
||||
# Coze API配置
|
||||
# 生产环境特定配置
|
||||
emotion:
|
||||
coze:
|
||||
api:
|
||||
token: ${COZE_API_TOKEN}
|
||||
base-url: https://api.coze.cn
|
||||
|
||||
# 文件上传配置
|
||||
# 文件上传路径 - 生产环境
|
||||
upload:
|
||||
path: /data/uploads/emotion-museum
|
||||
|
||||
# 生产模式配置
|
||||
prod:
|
||||
performance-monitoring: true
|
||||
security-enhanced: true
|
||||
cache-enabled: true
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
server:
|
||||
port: 8080
|
||||
servlet:
|
||||
context-path: /api
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: emotion-single
|
||||
|
||||
logging:
|
||||
level:
|
||||
root: info
|
||||
@@ -10,38 +10,15 @@ spring:
|
||||
profiles:
|
||||
active: ${SPRING_PROFILES_ACTIVE:local}
|
||||
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/emotion?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true
|
||||
username: emotion
|
||||
password: EmotionDB2024!
|
||||
hikari:
|
||||
minimum-idle: 5
|
||||
maximum-pool-size: 20
|
||||
auto-commit: true
|
||||
idle-timeout: 30000
|
||||
pool-name: EmotionHikariCP
|
||||
max-lifetime: 1800000
|
||||
connection-timeout: 30000
|
||||
|
||||
redis:
|
||||
host: localhost
|
||||
port: 6379
|
||||
timeout: 3000ms
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8
|
||||
max-wait: -1ms
|
||||
max-idle: 8
|
||||
min-idle: 0
|
||||
|
||||
# Jackson配置 - 所有环境统一
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
serialization:
|
||||
write-dates-as-timestamps: false
|
||||
default-property-inclusion: non_null
|
||||
|
||||
# MyBatis Plus配置
|
||||
# MyBatis Plus配置 - 所有环境统一
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
@@ -58,11 +35,12 @@ mybatis-plus:
|
||||
banner: false
|
||||
mapper-locations: classpath*:mapper/*.xml
|
||||
|
||||
# 日志配置
|
||||
# 日志配置 - 所有环境统一
|
||||
logging:
|
||||
level:
|
||||
com.emotion: debug
|
||||
org.springframework.security: debug
|
||||
com.emotion: info
|
||||
org.springframework.security: warn
|
||||
root: info
|
||||
pattern:
|
||||
console: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{50} - %msg%n"
|
||||
file: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{50} - %msg%n"
|
||||
@@ -71,7 +49,7 @@ logging:
|
||||
max-size: 100MB
|
||||
max-history: 30
|
||||
|
||||
# 管理端点配置
|
||||
# 管理端点配置 - 所有环境统一
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
@@ -81,7 +59,7 @@ management:
|
||||
health:
|
||||
show-details: always
|
||||
|
||||
# 应用配置
|
||||
# 应用配置 - 所有环境统一
|
||||
emotion:
|
||||
# JWT配置
|
||||
jwt:
|
||||
@@ -90,14 +68,16 @@ emotion:
|
||||
header: Authorization
|
||||
prefix: "Bearer "
|
||||
|
||||
# Coze API配置
|
||||
# Coze API配置 - 所有环境统一
|
||||
coze:
|
||||
api:
|
||||
token: your-coze-api-token
|
||||
token: pat_7523042446285439016_emotion_museum_2025
|
||||
base-url: https://api.coze.cn
|
||||
bot-id: 7523042446285439016
|
||||
workflow-id: 7523047462895796287
|
||||
timeout: 30000
|
||||
retry-count: 3
|
||||
retry-delay: 1000
|
||||
|
||||
# 文件上传配置
|
||||
upload:
|
||||
@@ -111,5 +91,7 @@ emotion:
|
||||
- /api/auth/login
|
||||
- /api/auth/register
|
||||
- /api/health
|
||||
- /api/health/info
|
||||
- /api/actuator/**
|
||||
- /api/websocket/**
|
||||
- /api/ai/guest/**
|
||||
|
||||
Reference in New Issue
Block a user