server:
  port: 8080
  servlet:
    context-path: /
    encoding:
      charset: UTF-8
      enabled: true
      force: true
  compression:
    enabled: true
    mime-types: text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json
    min-response-size: 1024

spring:
  profiles:
    active: ${SPRING_PROFILES_ACTIVE:dev}
  application:
    name: stdproject-backend
  main:
    allow-bean-definition-overriding: true
  datasource:
    url: ${DB_URL:jdbc:mysql://121.37.111.42:3306/gisbi-demodb?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true}
    username: ${DB_USERNAME:root}
    password: ${DB_PASSWORD:mysql_F8ysiK@2024}
    driver-class-name: com.mysql.cj.jdbc.Driver
    # HikariCP连接池配置
    hikari:
      pool-name: StdProjectHikariCP
      minimum-idle: 5
      maximum-pool-size: 20
      auto-commit: true
      idle-timeout: 30000
      max-lifetime: 1800000
      connection-timeout: 30000
      connection-test-query: SELECT 1
#    url: jdbc:sqlite:D:/Trae_space/StdProject/backend/db/project.db
#    username: # SQLite 不需要用户名
#    password: # SQLite 不需要密码
#    driver-class-name: org.sqlite.JDBC
#    hikari:
#      pool-name: StdProjectHikariCP
#      minimum-idle: 5
#      maximum-pool-size: 20
#      auto-commit: true
#      idle-timeout: 30000
#      max-lifetime: 1800000
#      connection-timeout: 30000
#      connection-test-query: SELECT 1

  cache:
    jcache:
      config: classpath:ehcache.xml # 指定Ehcache配置文件路径
  security:
    cors:
      allowed-origins: ${CORS_ALLOWED_ORIGINS:http://localhost:3000,http://localhost:8080}
      max-age: ${CORS_MAX_AGE:3600} # 预检请求的缓存时间（秒）
    jwt:
      enabled: ${JWT_ENABLED:true} # 控制是否启用JWT认证
      secret: ${JWT_SECRET:YourJWTSecretKeyForStdProjectBackendApplicationWhichIsVeryLongAndSecure2024!@#$%^&*()}
      expiration-ms: ${JWT_EXPIRATION:1800000} # Token 过期时间 (例如: 24小时)
      refresh-expiration-ms: ${JWT_REFRESH_EXPIRATION:1800000} # 刷新Token过期时间 (例如: 30分钟)

mybatis-plus:
  mapper-locations: classpath*:/mapper/**/*.xml # MyBatis Mapper XML文件位置
  type-aliases-package: com.stdproject.entity
  global-config:
    db-config:
      id-type: ASSIGN_ID # ID生成策略，assign_id 表示手动分配ID，通常使用雪花算法等
      table-prefix: ${DB_TABLE_PREFIX:} # 如果表名有统一前缀，可以在这里配置
      logic-delete-field: deleted # 逻辑删除字段名
      logic-delete-value: 1 # 逻辑删除值
      logic-not-delete-value: 0 # 逻辑未删除值
    banner: false # 关闭MyBatis-Plus启动横幅
  configuration:
    map-underscore-to-camel-case: true # 开启驼峰命名转换
    cache-enabled: true # 开启二级缓存
    lazy-loading-enabled: true # 开启延迟加载
    multiple-result-sets-enabled: true # 开启多结果集
    use-column-label: true # 使用列标签
    use-generated-keys: true # 使用生成的主键
    auto-mapping-behavior: partial # 自动映射行为
    default-executor-type: simple # 默认执行器类型
    default-statement-timeout: 25000 # 默认语句超时时间
    log-impl: ${MYBATIS_LOG_IMPL:org.apache.ibatis.logging.nologging.NoLoggingImpl} # SQL日志实现

logging:
  config: classpath:logback-spring.xml # Logback配置文件
  level:
    root: ${LOG_LEVEL_ROOT:INFO}
    com.stdproject: ${LOG_LEVEL_APP:DEBUG}
    org.springframework.security: ${LOG_LEVEL_SECURITY:WARN}
    org.hibernate.SQL: ${LOG_LEVEL_SQL:WARN}
    org.hibernate.type.descriptor.sql.BasicBinder: ${LOG_LEVEL_SQL_PARAMS:WARN}
  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"

springdoc:
  api-docs:
    path: /v3/api-docs
    enabled: ${SWAGGER_ENABLED:true}
  swagger-ui:
    path: /swagger-ui.html
    enabled: ${SWAGGER_UI_ENABLED:true}
    operations-sorter: alpha
    tags-sorter: alpha
    try-it-out-enabled: true
    filter: true
  default-consumes-media-type: application/json
  default-produces-media-type: application/json
  show-actuator: ${SWAGGER_SHOW_ACTUATOR:true}
  packages-to-scan: com.stdproject.controller

# 管理端点配置
management:
  endpoints:
    web:
      exposure:
        include: ${ACTUATOR_ENDPOINTS:health,info,metrics}
      base-path: /actuator
  endpoint:
    health:
      show-details: ${ACTUATOR_HEALTH_DETAILS:when-authorized}
    info:
      enabled: true
  info:
    env:
      enabled: true
    java:
      enabled: true
    os:
      enabled: true

# 应用信息配置
info:
  app:
    name: ${spring.application.name}
    description: StdProject Backend Application
    version: 1.0.0
    encoding: UTF-8
    java:
      version: ${java.version}

---
# 开发环境配置
spring:
  config:
    activate:
      on-profile: dev
  security:
    jwt:
      enabled: false
logging:
  level:
    com.stdproject: DEBUG
    org.hibernate.SQL: DEBUG
    org.hibernate.type.descriptor.sql.BasicBinder: TRACE
mybatis-plus:
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #org.apache.ibatis.logging.nologging.NoLoggingImpl
springdoc:
  swagger-ui:
    enabled: true

---
# 生产环境配置
spring:
  config:
    activate:
      on-profile: prod
  security:
    jwt:
      enabled: true
logging:
  level:
    root: WARN
    com.stdproject: INFO
    org.springframework.security: ERROR
mybatis-plus:
  configuration:
    log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
springdoc:
  api-docs:
    enabled: false
  swagger-ui:
    enabled: false
management:
  endpoints:
    web:
      exposure:
        include: health,info
