diff --git a/auth/src/main/resources/application.yml b/auth/src/main/resources/application.yml index 865307a73..e67599e64 100644 --- a/auth/src/main/resources/application.yml +++ b/auth/src/main/resources/application.yml @@ -26,7 +26,9 @@ spring: register-enabled: ${NACOS_REGISTER_ENABLED:true} group: ${NACOS_GROUP:BAIYUE} namespace: ${NACOS_NAMESPACE:public} - config.namespace: ${NACOS_NAMESPACE:public} + config: + namespace: ${NACOS_NAMESPACE:public} + encode: UTF-8 baiyue.security: jwt-secret: ${JWT_SECRET:change-me-to-at-least-32-bytes-long-before-start} internal-service-token: ${INTERNAL_SERVICE_TOKEN:change-me-to-an-internal-token-at-least-32-bytes-long} diff --git a/config/nacos/local/baiyue-common.yml b/config/nacos/local/baiyue-common.yml index 293f4136d..1ee127f26 100644 --- a/config/nacos/local/baiyue-common.yml +++ b/config/nacos/local/baiyue-common.yml @@ -1,4 +1,3 @@ -# 头程本地公共配置。生产环境不得直接使用本文件中的本地默认密钥。 baiyue: deployment: region-code: ${REGION_CODE:CN} @@ -32,6 +31,9 @@ spring: client.config.default: connect-timeout: 3000 read-timeout: 5000 +logging: + file: + path: ${LOG_PATH:./logs} server.shutdown: graceful management: endpoints.web.exposure.include: health,info,prometheus @@ -42,7 +44,6 @@ mybatis-plus: configuration: map-underscore-to-camel-case: true call-setters-on-nulls: true - log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl global-config: banner: false db-config: @@ -50,17 +51,6 @@ mybatis-plus: logic-delete-field: deleted logic-delete-value: 1 logic-not-delete-value: 0 -logging: - level: - com.baiyue.auth.mapper: ${MYBATIS_SQL_LOG_LEVEL:DEBUG} - com.baiyue.iam.mapper: ${MYBATIS_SQL_LOG_LEVEL:DEBUG} - com.baiyue.order.mapper: ${MYBATIS_SQL_LOG_LEVEL:DEBUG} - com.baiyue.firstleg.mapper: ${MYBATIS_SQL_LOG_LEVEL:DEBUG} - com.baiyue.warehouse.mapper: ${MYBATIS_SQL_LOG_LEVEL:DEBUG} - com.baiyue.file.mapper: ${MYBATIS_SQL_LOG_LEVEL:DEBUG} - com.baiyue.print.mapper: ${MYBATIS_SQL_LOG_LEVEL:DEBUG} - com.baiyue.audit.mapper: ${MYBATIS_SQL_LOG_LEVEL:DEBUG} - com.baiyue.eventbridge.mapper: ${MYBATIS_SQL_LOG_LEVEL:DEBUG} springdoc: api-docs.enabled: ${SWAGGER_ENABLED:true} swagger-ui.enabled: ${SWAGGER_ENABLED:true} diff --git a/config/nacos/local/gateway.yml b/config/nacos/local/gateway.yml index 38bedb7c3..c31d6422d 100644 --- a/config/nacos/local/gateway.yml +++ b/config/nacos/local/gateway.yml @@ -1,3 +1,11 @@ springdoc: api-docs.enabled: ${SWAGGER_ENABLED:true} swagger-ui.enabled: ${SWAGGER_ENABLED:true} +baiyue: + cors: + allowed-origins: ${CORS_ALLOWED_ORIGINS:http://localhost:5173,http://localhost:5174,http://127.0.0.1:5173,http://127.0.0.1:5174} + allowed-methods: ${CORS_ALLOWED_METHODS:GET,POST,PUT,PATCH,DELETE,OPTIONS} + allowed-headers: ${CORS_ALLOWED_HEADERS:*} + exposed-headers: ${CORS_EXPOSED_HEADERS:X-Request-Id,X-Trace-Id} + allow-credentials: ${CORS_ALLOW_CREDENTIALS:true} + max-age: ${CORS_MAX_AGE:3600} diff --git a/config/nacos/local/order-service.yml b/config/nacos/local/order-service.yml index 13bb3220a..f46a32771 100644 --- a/config/nacos/local/order-service.yml +++ b/config/nacos/local/order-service.yml @@ -4,5 +4,4 @@ spring.datasource: username: ${ORDER_DB_USERNAME:root} password: ${ORDER_DB_PASSWORD:123456} baiyue.clients: - # 默认留空并使用 Nacos 的 warehouse-service 实例;仅独立端口回归时显式设置直连 URL。 warehouse.url: ${WAREHOUSE_SERVICE_URL:} diff --git a/iam/src/main/resources/application.yml b/iam/src/main/resources/application.yml index dad2da71f..bdd188882 100644 --- a/iam/src/main/resources/application.yml +++ b/iam/src/main/resources/application.yml @@ -21,6 +21,7 @@ spring: namespace: ${NACOS_NAMESPACE:public} config: namespace: ${NACOS_NAMESPACE:public} + encode: UTF-8 baiyue: clients: auth: diff --git a/order/src/main/resources/application.yml b/order/src/main/resources/application.yml index f80a6c630..eee2d3faa 100644 --- a/order/src/main/resources/application.yml +++ b/order/src/main/resources/application.yml @@ -19,7 +19,9 @@ spring: register-enabled: ${NACOS_REGISTER_ENABLED:true} group: ${NACOS_GROUP:BAIYUE} namespace: ${NACOS_NAMESPACE:public} - config.namespace: ${NACOS_NAMESPACE:public} + config: + namespace: ${NACOS_NAMESPACE:public} + encode: UTF-8 management.endpoints.web.exposure.include: health,info,prometheus baiyue: diff --git a/scripts/local-env.ps1 b/scripts/local-env.ps1 index 8d4a40c25..0ed1a611c 100644 --- a/scripts/local-env.ps1 +++ b/scripts/local-env.ps1 @@ -1,6 +1,7 @@ $env:NACOS_SERVER_ADDR = '127.0.0.1:8848' $env:NACOS_NAMESPACE = 'public' $env:NACOS_GROUP = 'BAIYUE' +$env:SPRING_CLOUD_NACOS_CONFIG_ENCODE = 'UTF-8' $env:REDIS_HOST = '127.0.0.1' $env:REDIS_PORT = '6379' $env:SPRING_DATA_REDIS_HOST = '127.0.0.1' diff --git a/scripts/publish-local-nacos-config.ps1 b/scripts/publish-local-nacos-config.ps1 index e982df016..7f249c4ce 100644 --- a/scripts/publish-local-nacos-config.ps1 +++ b/scripts/publish-local-nacos-config.ps1 @@ -12,7 +12,7 @@ $publishUrl = "http://$ServerAddr/nacos/v1/cs/configs" $health = Invoke-WebRequest -UseBasicParsing -Uri $healthUrl -TimeoutSec 5 if ($health.StatusCode -ne 200 -or $health.Content.Trim() -ne 'OK') { - throw "Local Nacos is not ready: $healthUrl" + throw "Nacos not ready: $healthUrl" } $files = Get-ChildItem -LiteralPath $configRoot -File -Filter '*.yml' | Sort-Object Name @@ -32,9 +32,13 @@ foreach ($file in $files) { $body.tenant = $Namespace } + $pairs = foreach ($entry in $body.GetEnumerator()) { + [uri]::EscapeDataString([string]$entry.Key) + '=' + [uri]::EscapeDataString([string]$entry.Value) + } + $form = $pairs -join '&' $result = Invoke-RestMethod -Method Post -Uri $publishUrl ` -ContentType 'application/x-www-form-urlencoded; charset=UTF-8' ` - -Body $body -TimeoutSec 10 + -Body $form -TimeoutSec 10 if ([string]$result -ne 'true') { throw "Publish failed: $($file.Name), Nacos response: $result" } @@ -42,4 +46,4 @@ foreach ($file in $files) { Write-Host "Published $($file.Name) -> $Namespace / $Group" } -Write-Host "Local first-leg Nacos configuration published: $published items." +Write-Host "Published local Nacos configuration: $published items." diff --git a/warehouse/src/main/resources/application.yml b/warehouse/src/main/resources/application.yml index 21beccf0e..e1e8d062d 100644 --- a/warehouse/src/main/resources/application.yml +++ b/warehouse/src/main/resources/application.yml @@ -19,7 +19,9 @@ spring: register-enabled: ${NACOS_REGISTER_ENABLED:true} group: ${NACOS_GROUP:BAIYUE} namespace: ${NACOS_NAMESPACE:public} - config.namespace: ${NACOS_NAMESPACE:public} + config: + namespace: ${NACOS_NAMESPACE:public} + encode: UTF-8 baiyue: security: jwt-secret: ${JWT_SECRET:change-me-to-at-least-32-bytes-long-before-start}