Files
hyapi-server/config.yaml

647 lines
20 KiB
YAML
Raw Normal View History

2026-04-21 22:36:48 +08:00
# HYAPI Server Configuration
# 🎯 统一配置文件,包含所有默认配置值
app:
name: "HYAPI Server"
version: "1.0.0"
env: "development"
server:
host: "0.0.0.0"
port: "8080"
mode: "debug"
read_timeout: 30s
write_timeout: 30s
idle_timeout: 120s
database:
host: "localhost"
port: "15432"
user: "postgres"
password: "Qm8kZ3nR7pL4wT9y"
name: "hyapi_dev"
sslmode: "disable"
timezone: "Asia/Shanghai"
max_open_conns: 50
max_idle_conns: 20
conn_max_lifetime: 300s
auto_migrate: true
redis:
host: "localhost"
port: "16379"
password: ""
db: 0
pool_size: 10
min_idle_conns: 3
max_retries: 3
dial_timeout: 5s
read_timeout: 3s
write_timeout: 3s
cache:
default_ttl: 3600s
cleanup_interval: 600s
max_size: 1000
# 🚀 日志系统配置 - 基于 Zap 官方推荐
logger:
# 基础配置
level: "info" # 日志级别: debug, info, warn, error, fatal, panic
format: "json" # 输出格式: json, console
output: "file" # 输出方式: stdout, stderr, file
log_dir: "logs" # 日志目录
use_daily: true # 是否按日分包
use_color: false # 是否使用彩色输出仅console格式有效
# 文件配置
max_size: 100 # 单个文件最大大小(MB)
max_backups: 5 # 最大备份文件数
max_age: 30 # 最大保留天数
compress: true # 是否压缩
# 高级功能
enable_level_separation: true # 是否启用按级别分文件
enable_request_logging: true # 是否启用请求日志
enable_performance_log: true # 是否启用性能日志
# 开发环境配置
development: true # 是否为开发环境
sampling: false # 是否启用采样
# 各级别配置(按级别分文件时使用)
level_configs:
debug:
max_size: 50 # 50MB
max_backups: 3
max_age: 7 # 7天
compress: true
info:
max_size: 100 # 100MB
max_backups: 5
max_age: 30 # 30天
compress: true
warn:
max_size: 100 # 100MB
max_backups: 5
max_age: 30 # 30天
compress: true
error:
max_size: 200 # 200MB
max_backups: 10
max_age: 90 # 90天
compress: true
fatal:
max_size: 100 # 100MB
max_backups: 10
max_age: 365 # 1年
compress: true
panic:
max_size: 100 # 100MB
max_backups: 10
max_age: 365 # 1年
compress: true
# 全面日志配置
comprehensive_logging:
enable_request_logging: true
enable_response_logging: true
enable_request_body_logging: true # 开发环境记录请求体
enable_error_logging: true
enable_business_logging: true
enable_performance_logging: true
max_body_size: 10240 # 10KB
exclude_paths: ["/health", "/metrics", "/favicon.ico", "/swagger"]
jwt:
secret: "JwT8xR4mN9vP2sL7kH3oB6yC1zA5uF0qE9tW"
expires_in: 168h
refresh_expires_in: 168h
api:
domain: "api.haiyudata.com"
# public_base_url: "" # 可选,无尾斜杠;空则按 https://{domain} 推导;环境变量 API_PUBLIC_BASE_URL 优先
sms:
# 短信服务商tencent默认、aliyunmock_enabled=true 时不走云厂商
provider: "tencent"
tencent_cloud:
secret_id: "AKIDPCwVzUovoefbP4YzDEQOAi27wZx72i9h" # 腾讯云 API 密钥 SecretId建议用环境变量覆盖
secret_key: "MTu87tSv6NqX2JMAE4QYR4tVtCHBrHSO" # SecretKey
region: "ap-guangzhou"
endpoint: "sms.tencentcloudapi.com" # 可空,默认 sms.tencentcloudapi.com
sms_sdk_app_id: "1401111903" # 短信 SdkAppId
sign_name: "海宇数科广东横琴科技" # 短信签名
template_id: "2631130" # 验证码模板 ID单变量验证码
# 低余额与欠费为两套模板(变量顺序一般为:企业名、时间、金额)
low_balance_template_id: "2631956" # 余额不足预警
arrears_template_id: "2631956" # 欠费预警
balance_alert_template_id: "2631956" # 可选:若上面两项未配,则两类告警共用此模板 ID兼容旧配置
# 阿里云provider=aliyun 时使用)
access_key_id: "LTAI5tKGB3TVJbMHSoZN3yr9"
access_key_secret: "OCQ30GWp4yENMjmfOAaagksE18bp65"
endpoint_url: "dysmsapi.aliyuncs.com"
sign_name: "海南海宇大数据"
template_code: "SMS_302641455"
# 阿里云余额预警模板 CODE低余额与欠费共用可空则默认 SMS_500565339
balance_alert_template_code: ""
code_length: 6
expire_time: 5m
mock_enabled: false
# 签名验证配置(用于防止接口被刷)
signature_enabled: true # 是否启用签名验证
signature_secret: "HyApi2024SMSSecretKey!@#$%^&*()_+QWERTYUIOP" # 签名密钥(请修改为复杂密钥)
# 滑块验证码配置
2026-04-23 21:17:24 +08:00
captcha_enabled: false # 是否启用滑块验证码
2026-04-21 22:36:48 +08:00
captcha_secret: "" # 阿里云验证码密钥加密模式时需要可选EKEY
captcha_endpoint: "captcha.cn-shanghai.aliyuncs.com" # 阿里云验证码服务Endpoint
scene_id: "wynt39to" # 阿里云验证码场景ID
rate_limit:
daily_limit: 10
hourly_limit: 5
min_interval: 60s
# 邮件服务配置 - QQ邮箱
email:
host: "smtp.qq.com"
port: 587
username: "1726850085@qq.com"
password: "kqnumdccomvlehjg"
from_email: "1726850085@qq.com"
use_ssl: true
timeout: 10s
domain: "console.haiyudata.com"
# 存储服务配置 - 七牛云
storage:
access_key: "your-qiniu-access-key"
secret_key: "your-qiniu-secret-key"
bucket: "your-bucket-name"
domain: "https://your-domain.com"
# OCR服务配置 - 百度智能云
ocr:
api_key: "your-baidu-api-key"
secret_key: "your-baidu-secret-key"
ratelimit:
requests: 7500
window: 70s
# 每日请求限制配置
daily_ratelimit:
max_requests_per_day: 300 # 每日最大请求次数
max_requests_per_ip: 15 # 每个IP每日最大请求次数
key_prefix: "daily_limit" # Redis键前缀
ttl: 24h # 键过期时间
max_concurrent: 8 # 最大并发请求数
# 安全配置
enable_ip_whitelist: false # 是否启用IP白名单
ip_whitelist: # IP白名单列表
- "192.168.1.*" # 内网IP段
- "10.0.0.*" # 内网IP段
- "127.0.0.1" # 本地回环
enable_ip_blacklist: true # 是否启用IP黑名单
ip_blacklist: # IP黑名单列表
- "0.0.0.0" # 无效IP
- "255.255.255.255" # 广播IP
enable_user_agent: false # 是否检查User-Agent
blocked_user_agents: # 被阻止的User-Agent
- "bot" # 机器人
- "crawler" # 爬虫
- "spider" # 蜘蛛
- "scraper" # 抓取器
- "curl" # curl工具
- "wget" # wget工具
- "python" # Python脚本
- "java" # Java脚本
- "go-http-client" # Go HTTP客户端
- "LangShen"
enable_referer: true # 是否检查Referer
allowed_referers: # 允许的Referer
- "https://console.haiyudata.com" # 天元API控制台
- "https://consoletest.haiyudata.com" # 天元API测试控制台
enable_proxy_check: false # 是否检查代理
enable_geo_block: false # 是否启用地理位置阻止
blocked_countries: # 被阻止的国家/地区
- "XX" # 示例国家代码
monitoring:
metrics_enabled: true
metrics_port: "9090"
tracing_enabled: true
tracing_endpoint: "http://localhost:4317"
sample_rate: 0.1
health:
enabled: true
interval: 30s
timeout: 10s
resilience:
circuit_breaker_enabled: true
circuit_breaker_threshold: 5
circuit_breaker_timeout: 60s
retry_max_attempts: 3
retry_initial_delay: 100ms
retry_max_delay: 5s
development:
debug: true
enable_profiler: true
enable_cors: true
cors_allowed_origins: "http://localhost:5173,https://consoletest.haiyudata.com,https://console.haiyudata.com"
cors_allowed_methods: "GET,POST,PUT,PATCH,DELETE,OPTIONS"
cors_allowed_headers: "Origin,Content-Type,Accept,Authorization,X-Requested-With,Access-Id"
# 企业微信配置
wechat_work:
webhook_url: "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=1fdabca0-298a-43d6-8794-6b4caf15e176"
secret: ""
# ===========================================
# 📝 e签宝服务配置
# ===========================================
esign:
app_id: "7439073138"
app_secret: "d76e27fdd169b391e09262a0959dac5c"
server_url: "https://smlopenapi.esign.cn"
template_id: "9f7a3f63cc5a48b085b127ba027d234d"
contract:
name: "海宇数据API合作协议"
expire_days: 7
retry_count: 3
auth:
org_auth_modes: ["PSN_MOBILE3"]
default_auth_mode: "PSN_MOBILE3"
psn_auth_modes: ["PSN_MOBILE3", "PSN_IDCARD"]
willingness_auth_modes: ["CODE_SMS"]
redirect_url: "https://console.haiyudata.com/certification/callback/auth"
sign:
auto_finish: true
sign_field_style: 1
client_type: "ALL"
redirect_url: "https://console.haiyudata.com/certification/callback/sign"
# ===========================================
# 💰 钱包配置
# ===========================================
wallet:
default_credit_limit: 50.00
min_amount: "100.00" # 生产环境最低充值金额
max_amount: "100000.00" # 单次最高充值金额
recharge_bonus_enabled: true # 是否启用充值赠送,设为 false 时仅展示商务洽谈提示
api_store_recharge_tip: "" # 关闭赠送时展示的提示文案,为空则使用默认文案
# 支付宝充值赠送配置
alipay_recharge_bonus:
- recharge_amount: 1000.00 # 充值1000元
bonus_amount: 50.00 # 赠送50元
- recharge_amount: 5000.00 # 充值5000元
bonus_amount: 300.00 # 赠送300元
- recharge_amount: 10000.00 # 充值10000元
bonus_amount: 800.00 # 赠送800元
# 余额预警配置
balance_alert:
default_enabled: true # 默认启用余额预警
default_threshold: 200.00 # 默认预警阈值
alert_cooldown_hours: 24 # 预警冷却时间(小时)
# ===========================================
# 🌍 西部数据配置
# ===========================================
westdex:
url: "https://apimaster.westdex.com.cn/api/invoke"
key: "121a1e41fc1690dd6b90afbcacd80cf4"
secret_id: "449159"
secret_second_id: "296804"
# 西部数据日志配置
logging:
enabled: true
log_dir: "logs/external_services"
service_name: "westdex"
use_daily: true
enable_level_separation: true
# 各级别配置
level_configs:
info:
max_size: 100
max_backups: 5
max_age: 30
compress: true
error:
max_size: 200
max_backups: 10
max_age: 90
compress: true
warn:
max_size: 100
max_backups: 5
max_age: 30
compress: true
# ===========================================
# 🌍 羽山配置
# ===========================================
yushan:
url: https://api.yushanshuju.com/credit-gw/service
api_key: "4c566c4a4b543164535455685655316c"
acct_id: "YSSJ843926726"
# 羽山日志配置
logging:
enabled: true
log_dir: "logs/external_services"
service_name: "yushan"
use_daily: true
enable_level_separation: true
# 各级别配置
level_configs:
info:
max_size: 100
max_backups: 5
max_age: 30
compress: true
error:
max_size: 200
max_backups: 10
max_age: 90
compress: true
warn:
max_size: 100
max_backups: 5
max_age: 30
compress: true
# ===========================================
# 💰 支付宝支付配置
# ===========================================
alipay:
is_production: true
notify_url: "https://console.haiyudata.com/api/v1/finance/alipay/callback"
return_url: "https://console.haiyudata.com/api/v1/finance/alipay/return"
# ===========================================
# 💰 微信支付配置
# ===========================================
Wxpay:
2026-04-23 21:17:24 +08:00
mch_id: "1111281099"
mch_certificate_serial_number: "5E6FBBCB4C6C5378BEBA85D151A258CE0BE33A77"
mch_apiv3_key: "7s9KpG2tR8aZcX5bN3mQ6wE4dF1hJ7Lq"
2026-04-21 22:36:48 +08:00
mch_private_key_path: "resources/etc/wxetc_cert/apiclient_key.pem"
2026-04-23 21:17:24 +08:00
mch_public_key_id: "PUB_KEY_ID_0111112810992026042300381743000200"
2026-04-21 22:36:48 +08:00
mch_public_key_path: "resources/etc/wxetc_cert/pub_key.pem"
notify_url: "https://console.haiyudata.com/api/v1/pay/wechat/callback"
refund_notify_url: "https://console.haiyudata.com/api/v1/wechat/refund_callback"
# ===========================================
# 🔍 天眼查配置
# ===========================================
tianyancha:
base_url: http://open.api.tianyancha.com/services
api_key: e6a43dc9-786e-4a16-bb12-392b8201d8e2
# ===========================================
# ☁️ 阿里云配置
# ===========================================
alicloud:
host: "https://kzidcardv1.market.alicloudapi.com"
app_code: "d55b58829efb41c8aa8e86769cba4844"
# ===========================================
# 🔍 智查金控配置
# ===========================================
zhicha:
url: "https://www.zhichajinkong.com/dataMiddle/api/handle"
app_id: "4b78fff61ab8426f"
app_secret: "1128f01b94124ae899c2e9f2b1f37681"
encrypt_key: "af4ca0098e6a202a5c08c413ebd9fd62"
# 智查金控日志配置
logging:
enabled: true
log_dir: "logs/external_services"
service_name: "zhicha"
use_daily: true
enable_level_separation: true
# 各级别配置
level_configs:
info:
max_size: 100
max_backups: 5
max_age: 30
compress: true
error:
max_size: 200
max_backups: 10
max_age: 90
compress: true
warn:
max_size: 100
max_backups: 5
max_age: 30
compress: true
# ===========================================
# 🌐 木子数据配置
# ===========================================
muzi:
url: "https://carv.m0101.com/magic/carv/pubin/service"
app_id: "713014138179585"
app_secret: "bd4090ac652c404c80e90ebbdcd6ba1d"
timeout: 60s
logging:
enabled: true
log_dir: "logs/external_services"
service_name: "muzi"
use_daily: true
enable_level_separation: true
level_configs:
info:
max_size: 50
max_backups: 3
max_age: 7
compress: true
error:
max_size: 100
max_backups: 5
max_age: 30
compress: true
# ===========================================
# 🎯 行为数据配置
# ===========================================
xingwei:
url: "https://sjztyh.chengdaoji.cn/dataCenterManageApi/manage/interface/doc/api/handle"
api_id: "jGtqla2FQv1zuXuH"
api_key: "iR1qS9725N4JA70gwlwohqT3ogl2zBf3"
# 行为数据日志配置
logging:
enabled: true
log_dir: "logs/external_services"
service_name: "xingwei"
use_daily: true
enable_level_separation: true
# 各级别配置
level_configs:
info:
max_size: 100
max_backups: 5
max_age: 30
compress: true
error:
max_size: 200
max_backups: 10
max_age: 90
compress: true
warn:
max_size: 100
max_backups: 5
max_age: 30
compress: true
# ===========================================
# ✨ 极光配置
# ===========================================
jiguang:
url: "http://api.jiguangcloud.com/jg-open-api-gateway/api"
app_id: "66ZA28w5" # 请替换为实际的 appId
app_secret: "e5261d0f6f003ae7b9fc1b0255b21761bb618d56" # 请替换为实际的 appSecret
sign_method: "hmac" # 签名方法md5 或 hmac默认 hmac
timeout: 60s # 请求超时时间,默认 60 秒
# 极光日志配置
logging:
enabled: true
log_dir: "logs/external_services"
service_name: "jiguang"
use_daily: true
enable_level_separation: true
# 各级别配置
level_configs:
info:
max_size: 100
max_backups: 5
max_age: 30
compress: true
error:
max_size: 200
max_backups: 10
max_age: 90
compress: true
warn:
max_size: 100
max_backups: 5
max_age: 30
compress: true
# ===========================================
# 📄 PDF生成服务配置
# ===========================================
pdfgen:
# 服务地址配置
development_url: "http://pdfg.haiyudata.com" # 开发环境服务地址
production_url: "http://101.43.41.217:15990" # 生产环境服务地址
# API路径配置
api_path: "/api/v1/generate/guangzhou" # PDF生成API路径
# 超时配置
timeout: 120s # 请求超时时间120秒
# 缓存配置
cache:
ttl: 24h # 缓存过期时间24小时
cache_dir: "" # 缓存目录(空则使用默认目录)
max_size: 0 # 最大缓存大小0表示不限制单位字节
# ===========================================
# ✨ 数脉配置走实时接口
# ===========================================
shumai:
url: "https://api.shumaidata.com"
app_id: "pIfqx8MsoTOjhbB762qi5BfkjJ4D7w0O"
app_secret: "BnJWo61hUgNEa5fqBCueiT1IZ1e0DxPU"
# ===========================================
# ✨ 数脉子账号配置走政务
# ===========================================
# 走政务接口使用这个
app_id2: "AwZZRzWkArtFDO2lDcT2jHfuoo9n35Tq"
app_secret2: "nCXN6fKLImjfvzI12hj8O1CMl1gJeaWh"
sign_method: "md5" # 签名方法md5 或 hmac默认 hmac
timeout: 60s # 请求超时时间,默认 60 秒
# 数脉日志配置
logging:
enabled: true
log_dir: "logs/external_services"
service_name: "shumai"
use_daily: true
enable_level_separation: true
# 各级别配置
level_configs:
info:
max_size: 100
max_backups: 5
max_age: 30
compress: true
error:
max_size: 200
max_backups: 10
max_age: 90
compress: true
warn:
max_size: 100
max_backups: 5
max_age: 30
compress: true
# ===========================================
# ✨ 数据宝配置走实时接口
# ===========================================
shujubao:
url: "https://api.chinadatapay.com"
app_secret: "iOk0ALBX0BSdTSTf"
sign_method: "md5" # 签名方法md5 或 hmac默认 hmac
timeout: 60s # 请求超时时间,默认 60 秒
# 数据宝日志配置
logging:
enabled: true
log_dir: "logs/external_services"
service_name: "shujubao"
use_daily: true
enable_level_separation: true
# 各级别配置
level_configs:
info:
max_size: 100
max_backups: 5
max_age: 30
compress: true
error:
max_size: 200
max_backups: 10
max_age: 90
compress: true
warn:
max_size: 100
max_backups: 5
max_age: 30
compress: true