Files
tyapi-server/config.yaml
2025-08-28 00:50:30 +08:00

407 lines
13 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# TYAPI Server Configuration
# 🎯 统一配置文件,包含所有默认配置值
app:
name: "TYAPI 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: "5432"
user: "postgres"
password: "Pg9mX4kL8nW2rT5y"
name: "tyapi_dev"
sslmode: "disable"
timezone: "Asia/Shanghai"
max_open_conns: 25
max_idle_conns: 10
conn_max_lifetime: 300s
auto_migrate: true
redis:
host: "localhost"
port: "6379"
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.tianyuanapi.com"
sms:
access_key_id: "LTAI5tKGB3TVJbMHSoZN3yr9"
access_key_secret: "OCQ30GWp4yENMjmfOAaagksE18bp65"
endpoint_url: "dysmsapi.aliyuncs.com"
sign_name: "天远数据"
template_code: "SMS_474525324"
code_length: 6
expire_time: 5m
mock_enabled: false
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.tianyuanapi.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: 5000
window: 60s
# 每日请求限制配置
daily_ratelimit:
max_requests_per_day: 200 # 每日最大请求次数
max_requests_per_ip: 10 # 每个IP每日最大请求次数
key_prefix: "daily_limit" # Redis键前缀
ttl: 24h # 键过期时间
max_concurrent: 5 # 最大并发请求数
# 安全配置
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: true # 是否检查User-Agent
blocked_user_agents: # 被阻止的User-Agent
- "bot" # 机器人
- "crawler" # 爬虫
- "spider" # 蜘蛛
- "scraper" # 抓取器
- "curl" # curl工具
- "wget" # wget工具
- "python" # Python脚本
- "java" # Java脚本
- "go-http-client" # Go HTTP客户端
enable_referer: true # 是否检查Referer
allowed_referers: # 允许的Referer
- "https://console.tianyuanapi.com" # 天元API控制台
- "https://consoletest.tianyuanapi.com" # 天元API测试控制台
enable_proxy_check: true # 是否检查代理
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: "https://consoletest.tianyuanapi.com,https://console.tianyuanapi.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: ""
secret: ""
# ===========================================
# 📝 e签宝服务配置
# ===========================================
esign:
app_id: "7439073138"
app_secret: "d76e27fdd169b391e09262a0959dac5c"
server_url: "https://smlopenapi.esign.cn"
template_id: "1fd7ed9c6d134d1db7b5af9582633d76"
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.tianyuanapi.com/certification/callback/auth"
sign:
auto_finish: true
sign_field_style: 1
client_type: "ALL"
redirect_url: "https://console.tianyuanapi.com/certification/callback/sign"
# ===========================================
# 💰 钱包配置
# ===========================================
wallet:
default_credit_limit: 50.00
min_amount: "100.00" # 生产环境最低充值金额
max_amount: "100000.00" # 单次最高充值金额
# 支付宝充值赠送配置
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元
# ===========================================
# 🌍 西部数据配置
# ===========================================
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:
app_id: "2021004181633376"
private_key: "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCC2GNEWrQUg6FVHBdlDcgL1SA1KmRI8IHgSJGvXEsgfo3g62aa5usFXHVz5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KtYEWal2+WhSWvq32MpgUIsasQZKyid6TMf0MEIFDL5s+7QEsEZejhc5zESWNN3qNHd5rX5ktBygArkadXC7XqhpLHxAoGBAJ0dJEKNTZDLjKiMCoAVgT/cTcdkRFGst4tn4tkTTqDCzWJ5di++Geg173i86aMQ7ndlb2fcP1qb1hW5Fy9pq7Eu3zVFNZB9k6TZqIlSJ2VK4IPiYY9C/UpgGCNcdzEqqMxc1Cmkcrq1AtE8tVmc0Mutgnw7Pj2JKkx91yLU32TBAoGAKxssUdTLuf5Z5oFgzpoSES9qwc1h6jlMfsouDzHcZf0aYintD6Vby7SVul5540qYkDkNs0YZ3uZu74LHfoBaWJjYIIVAMSMX+3AtBpQUyYluex64V/g60t+0sFuDWqMvSPU7mZcv6+KIP6vW56GeYdhHf4JqttdIHm9SgkoJjjY="
alipay_public_key: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2CqoCp95w/JV3RT/gzF4/8QmVT1HQNaeW7yUp+mA7x9AbjvlTW/+eRn6oGAL/XhZLjvHD0XjKLVKX0MJVS1aUQHEHEbOJN4Eu8II45OavD4iZISa7Kp9V6AM+i4qTyaeV2wNDnGxHQBaLVUGCfMR+56EK2YpORdE1H9uy72SSQseVb3bmpsV9EW/IJNmcVL/ut3uA1JWAoRmzlQ7ekxg7p8AYXzYPEHQr1tl7W+M4zv9wO9GKZCxIqMA8U3RP5npPfRaCfIRGzXzCqFEEUvWuidOB7frsvN4jiPD07qpL2Bi9LM1X/ee2kC/oM8Uhd7ERZhG8MbZfijZKxgrsDKBcwIDAQAB"
is_production: true
notify_url: "https://console.tianyuanapi.com/api/v1/finance/alipay/callback"
return_url: "https://console.tianyuanapi.com/api/v1/finance/alipay/return"
# ===========================================
# 🔍 天眼查配置
# ===========================================
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