feat: 项目初始化及当前全部内容提交

This commit is contained in:
2025-07-15 17:37:50 +08:00
parent ec817067f1
commit e78f192d34
622 changed files with 75174 additions and 383 deletions
@@ -0,0 +1,221 @@
# AI服务测试环境配置
server:
port: 9002
spring:
application:
name: emotion-ai
profiles:
active: test
cloud:
nacos:
discovery:
server-addr: ${NACOS_SERVER_ADDR:localhost:8848}
namespace: emotion-test
group: TEST_GROUP
enabled: true
ip: ${SERVER_IP:localhost}
port: ${server.port}
metadata:
version: 1.0.0
environment: test
config:
server-addr: ${NACOS_SERVER_ADDR:localhost:8848}
file-extension: yml
namespace: emotion-test
group: TEST_GROUP
enabled: true
datasource:
url: jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:3306}/emotion_museum?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
username: ${MYSQL_USERNAME:emotion}
password: ${MYSQL_PASSWORD:emotion123}
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
pool-name: EmotionAITestHikariCP
minimum-idle: 3
maximum-pool-size: 15
auto-commit: true
idle-timeout: 30000
max-lifetime: 1800000
connection-timeout: 30000
connection-test-query: SELECT 1
data:
redis:
host: ${REDIS_HOST:localhost}
port: ${REDIS_PORT:6379}
password: ${REDIS_PASSWORD:}
database: 2
timeout: 6000ms
lettuce:
pool:
max-active: 8
max-wait: -1ms
max-idle: 8
min-idle: 2
# MyBatis Plus配置
mybatis-plus:
configuration:
map-underscore-to-camel-case: true
cache-enabled: true
call-setters-on-nulls: true
jdbc-type-for-null: 'null'
log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
global-config:
db-config:
id-type: assign_uuid
logic-delete-field: is_deleted
logic-delete-value: 1
logic-not-delete-value: 0
banner: false
mapper-locations: classpath*:mapper/**/*.xml
# 日志配置
logging:
level:
root: INFO
com.emotionmuseum: INFO
com.emotionmuseum.ai.mapper: DEBUG
org.springframework.ai: INFO
org.springframework.web: INFO
pattern:
console: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%logger{36}] - %msg%n"
file: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%logger{36}] - %msg%n"
file:
name: /data/logs/emotion-museum/ai-service.log
max-size: 100MB
max-history: 30
# 管理端点
management:
endpoints:
web:
exposure:
include: health,info,metrics,prometheus,env,configprops
base-path: /actuator
endpoint:
health:
show-details: always
show-components: always
metrics:
export:
prometheus:
enabled: true
health:
redis:
enabled: true
db:
enabled: true
# COZE AI配置
coze:
api:
token: ${COZE_API_TOKEN:your-coze-api-token}
base-url: https://api.coze.cn
bot-id: 7523042446285439016
workflow-id: 7523047462895796287
timeout: 30000
retry-count: 3
max-tokens: 2000
temperature: 0.7
endpoints:
chat: /v3/chat
bot-info: /v1/bot/get_online_info
conversation: /v1/conversation/create
rate-limit:
requests-per-minute: 60
requests-per-hour: 1000
# Spring AI配置
spring:
ai:
retry:
max-attempts: 3
backoff:
initial-interval: 1000
multiplier: 2
max-interval: 10000
timeout: 30s
# 对话配置
conversation:
max-history: 20
session-timeout: 1800
guest-session-timeout: 600
max-message-length: 2000
auto-save: true
cache:
enabled: true
ttl: 3600
# 情感分析配置
emotion:
analysis:
enabled: true
confidence-threshold: 0.6
cache-results: true
cache-ttl: 1800
categories:
- joy
- sadness
- anger
- fear
- surprise
- disgust
- neutral
# 限流配置
rate-limit:
enabled: true
default-limit: 20
default-window: 60
api-limits:
"/chat": 10
"/emotion/analyze": 30
"/conversation/create": 5
# 缓存配置
cache:
redis:
default-ttl: 3600
conversation-ttl: 1800
emotion-analysis-ttl: 7200
user-session-ttl: 3600
# 安全配置
security:
ignore-urls:
- /actuator/**
- /api/public/**
- /swagger-ui/**
- /v3/api-docs/**
# 文件配置
file:
temp-dir: /tmp/emotion-ai
max-size: 5MB
cleanup-interval: 3600
# 监控告警配置
alert:
enabled: true
thresholds:
api-response-time: 5000
error-rate: 10
coze-api-failure-rate: 20
notification:
enabled: false
# 测试环境特殊配置
test:
debug:
enabled: true
log-requests: true
log-responses: false
log-ai-interactions: true
mock:
enabled: false
coze-api: false
data:
auto-init: true
sample-conversations: true
@@ -0,0 +1,80 @@
# 用户服务 Docker环境配置
server:
port: 9001
spring:
application:
name: emotion-user
profiles:
active: docker
cloud:
nacos:
discovery:
server-addr: ${NACOS_SERVER_ADDR:nacos:8848}
namespace: public
group: DEFAULT_GROUP
config:
server-addr: ${NACOS_SERVER_ADDR:nacos:8848}
file-extension: yml
namespace: public
group: DEFAULT_GROUP
datasource:
url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/emotion_museum?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
username: root
password: 123456
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
pool-name: EmotionUserHikariCP
minimum-idle: 5
maximum-pool-size: 20
auto-commit: true
idle-timeout: 30000
max-lifetime: 1800000
connection-timeout: 30000
data:
redis:
host: ${REDIS_HOST:redis}
port: ${REDIS_PORT:6379}
password:
database: 2
timeout: 6000ms
lettuce:
pool:
max-active: 8
max-wait: -1ms
max-idle: 8
min-idle: 0
# MyBatis Plus配置
mybatis-plus:
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
call-setters-on-nulls: true
jdbc-type-for-null: 'null'
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: assign_uuid
logic-delete-field: isDeleted
logic-delete-value: 1
logic-not-delete-value: 0
banner: false
# 日志配置
logging:
level:
com.emotionmuseum: DEBUG
com.emotionmuseum.user.mapper: DEBUG
pattern:
console: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level [%logger{50}] - %msg%n"
# 管理端点
management:
endpoints:
web:
exposure:
include: health,info,metrics,prometheus
endpoint:
health:
show-details: always
@@ -0,0 +1,205 @@
# 情绪博物馆测试环境配置
# 适用于测试环境部署,使用IP访问,不使用域名
server:
port: 9001
spring:
application:
name: emotion-user
profiles:
active: test
cloud:
nacos:
discovery:
server-addr: ${NACOS_SERVER_ADDR:localhost:8848}
namespace: emotion-test
group: TEST_GROUP
enabled: true
ip: ${SERVER_IP:localhost}
port: ${server.port}
metadata:
version: 1.0.0
environment: test
config:
server-addr: ${NACOS_SERVER_ADDR:localhost:8848}
file-extension: yml
namespace: emotion-test
group: TEST_GROUP
enabled: true
refresh-enabled: true
datasource:
url: jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:3306}/emotion_museum?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
username: ${MYSQL_USERNAME:emotion}
password: ${MYSQL_PASSWORD:emotion123}
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
pool-name: EmotionUserTestHikariCP
minimum-idle: 3
maximum-pool-size: 15
auto-commit: true
idle-timeout: 30000
max-lifetime: 1800000
connection-timeout: 30000
connection-test-query: SELECT 1
data:
redis:
host: ${REDIS_HOST:localhost}
port: ${REDIS_PORT:6379}
password: ${REDIS_PASSWORD:}
database: 1
timeout: 6000ms
lettuce:
pool:
max-active: 8
max-wait: -1ms
max-idle: 8
min-idle: 2
# MyBatis Plus配置
mybatis-plus:
configuration:
map-underscore-to-camel-case: true
cache-enabled: true
call-setters-on-nulls: true
jdbc-type-for-null: 'null'
log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
global-config:
db-config:
id-type: assign_uuid
logic-delete-field: is_deleted
logic-delete-value: 1
logic-not-delete-value: 0
banner: false
mapper-locations: classpath*:mapper/**/*.xml
# 日志配置
logging:
level:
root: INFO
com.emotionmuseum: INFO
com.emotionmuseum.user.mapper: DEBUG
org.springframework.cloud.gateway: INFO
org.springframework.web: INFO
pattern:
console: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%logger{36}] - %msg%n"
file: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%logger{36}] - %msg%n"
file:
name: /data/logs/emotion-museum/user-service.log
max-size: 100MB
max-history: 30
# 管理端点
management:
endpoints:
web:
exposure:
include: health,info,metrics,prometheus,env,configprops
base-path: /actuator
endpoint:
health:
show-details: always
show-components: always
metrics:
export:
prometheus:
enabled: true
health:
redis:
enabled: true
db:
enabled: true
# JWT配置
jwt:
secret: ${JWT_SECRET:emotion-museum-test-secret-key-2025}
expiration: ${JWT_EXPIRATION:7200}
refresh-expiration: ${JWT_REFRESH_EXPIRATION:86400}
# COZE AI配置
coze:
api:
token: ${COZE_API_TOKEN:your-coze-api-token}
base-url: https://api.coze.cn
bot-id: 7523042446285439016
workflow-id: 7523047462895796287
timeout: 30000
retry-count: 3
# 跨域配置
cors:
allowed-origins:
- "http://localhost:3000"
- "http://localhost:8080"
- "http://${SERVER_IP:localhost}"
- "http://${SERVER_IP:localhost}:3000"
- "http://${SERVER_IP:localhost}:8080"
allowed-methods:
- GET
- POST
- PUT
- DELETE
- OPTIONS
allowed-headers:
- "*"
allow-credentials: true
max-age: 3600
# 文件上传配置
file:
upload:
path: /data/uploads/emotion-museum
max-size: 10MB
allowed-types:
- image/jpeg
- image/png
- image/gif
- image/webp
# 缓存配置
cache:
redis:
default-ttl: 3600
user-info-ttl: 1800
conversation-ttl: 7200
# 限流配置
rate-limit:
enabled: true
default-limit: 100
default-window: 60
api-limits:
"/api/auth/login": 10
"/api/auth/register": 5
"/api/ai/chat": 20
# 安全配置
security:
ignore-urls:
- /actuator/**
- /api/auth/login
- /api/auth/register
- /api/public/**
- /swagger-ui/**
- /v3/api-docs/**
# 监控告警配置
alert:
enabled: true
thresholds:
cpu-usage: 80
memory-usage: 85
disk-usage: 90
response-time: 2000
# 测试环境特殊配置
test:
debug:
enabled: true
log-requests: true
log-responses: false
mock:
enabled: false
data:
auto-init: true
sample-data: true
@@ -0,0 +1,79 @@
server:
port: 9001
spring:
application:
name: emotion-user
profiles:
active: dev
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/emotion_museum?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: 123456
hikari:
minimum-idle: 5
maximum-pool-size: 20
idle-timeout: 600000
max-lifetime: 1800000
connection-timeout: 30000
data:
redis:
host: localhost
port: 6379
database: 0
timeout: 3000ms
lettuce:
pool:
max-active: 20
max-idle: 10
min-idle: 5
max-wait: 3000ms
cloud:
nacos:
discovery:
server-addr: localhost:8848
namespace: emotion-dev
group: DEFAULT_GROUP
enabled: false
config:
enabled: false
mybatis-plus:
configuration:
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: assign_uuid
logic-delete-field: deleted
logic-delete-value: 1
logic-not-delete-value: 0
# 监控配置
management:
endpoints:
web:
exposure:
include: health,info,metrics,prometheus
endpoint:
health:
show-details: always
metrics:
export:
prometheus:
enabled: true
# 日志配置
logging:
level:
com.emotionmuseum: debug
com.baomidou.mybatisplus: debug
pattern:
console: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level [%logger{50}] - %msg%n"
# JWT配置
jwt:
secret: emotion-museum-secret-key-2025
expiration: 86400
refresh-expiration: 604800
@@ -0,0 +1,215 @@
# 网关服务测试环境配置
server:
port: 9000
spring:
application:
name: emotion-gateway
profiles:
active: test
cloud:
nacos:
discovery:
server-addr: ${NACOS_SERVER_ADDR:localhost:8848}
namespace: emotion-test
group: TEST_GROUP
enabled: true
ip: ${SERVER_IP:localhost}
port: ${server.port}
metadata:
version: 1.0.0
environment: test
config:
server-addr: ${NACOS_SERVER_ADDR:localhost:8848}
file-extension: yml
namespace: emotion-test
group: TEST_GROUP
enabled: true
gateway:
discovery:
locator:
enabled: true
lower-case-service-id: true
routes:
# 用户服务路由
- id: emotion-user
uri: lb://emotion-user
predicates:
- Path=/api/user/**
filters:
- StripPrefix=2
- name: RequestRateLimiter
args:
redis-rate-limiter.replenishRate: 10
redis-rate-limiter.burstCapacity: 20
key-resolver: "#{@ipKeyResolver}"
# AI服务路由
- id: emotion-ai
uri: lb://emotion-ai
predicates:
- Path=/api/ai/**
filters:
- StripPrefix=2
- name: RequestRateLimiter
args:
redis-rate-limiter.replenishRate: 5
redis-rate-limiter.burstCapacity: 10
key-resolver: "#{@ipKeyResolver}"
# 认证服务路由
- id: emotion-auth
uri: lb://emotion-user
predicates:
- Path=/api/auth/**
filters:
- StripPrefix=2
# 公共API路由
- id: emotion-public
uri: lb://emotion-user
predicates:
- Path=/api/public/**
filters:
- StripPrefix=2
# 健康检查路由
- id: health-check
uri: lb://emotion-gateway
predicates:
- Path=/health
filters:
- SetPath=/actuator/health
# 全局过滤器配置
default-filters:
- name: GlobalRequestLog
- name: GlobalResponseLog
- name: AddResponseHeader
args:
name: X-Response-Server
value: emotion-gateway-test
data:
redis:
host: ${REDIS_HOST:localhost}
port: ${REDIS_PORT:6379}
password: ${REDIS_PASSWORD:}
database: 0
timeout: 6000ms
lettuce:
pool:
max-active: 8
max-wait: -1ms
max-idle: 8
min-idle: 2
# 日志配置
logging:
level:
root: INFO
com.emotionmuseum: INFO
org.springframework.cloud.gateway: INFO
org.springframework.web.reactive: INFO
reactor.netty: INFO
pattern:
console: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%logger{36}] - %msg%n"
file: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%logger{36}] - %msg%n"
file:
name: /data/logs/emotion-museum/gateway-service.log
max-size: 100MB
max-history: 30
# 管理端点
management:
endpoints:
web:
exposure:
include: health,info,metrics,prometheus,gateway,env
base-path: /actuator
endpoint:
health:
show-details: always
show-components: always
gateway:
enabled: true
metrics:
export:
prometheus:
enabled: true
# 跨域配置
cors:
configurations:
'[/**]':
allowed-origins:
- "http://localhost:3000"
- "http://localhost:8080"
- "http://${SERVER_IP:localhost}"
- "http://${SERVER_IP:localhost}:3000"
- "http://${SERVER_IP:localhost}:8080"
allowed-methods:
- GET
- POST
- PUT
- DELETE
- OPTIONS
allowed-headers:
- "*"
allow-credentials: true
max-age: 3600
# 限流配置
rate-limit:
enabled: true
default-replenish-rate: 10
default-burst-capacity: 20
routes:
emotion-user:
replenish-rate: 20
burst-capacity: 40
emotion-ai:
replenish-rate: 5
burst-capacity: 10
# 熔断配置
resilience4j:
circuitbreaker:
instances:
emotion-user:
failure-rate-threshold: 50
wait-duration-in-open-state: 30s
sliding-window-size: 10
minimum-number-of-calls: 5
emotion-ai:
failure-rate-threshold: 60
wait-duration-in-open-state: 60s
sliding-window-size: 10
minimum-number-of-calls: 3
timelimiter:
instances:
emotion-user:
timeout-duration: 10s
emotion-ai:
timeout-duration: 30s
# 安全配置
security:
ignore-urls:
- /actuator/**
- /api/auth/login
- /api/auth/register
- /api/public/**
- /health
jwt:
secret: ${JWT_SECRET:emotion-museum-test-secret-key-2025}
expiration: ${JWT_EXPIRATION:7200}
# 测试环境特殊配置
test:
debug:
enabled: true
log-requests: true
log-responses: false
mock:
enabled: false