/**
 * 应用配置文件 - 业务配置
 * 包含数据库、端口、第三方服务等配置
 */

const env = process.env.NODE_ENV || 'development';

module.exports = {
  // 环境配置
  env,

  // 端口配置
  port: {
    node: 9097,  // Node服务端口
    web: 9000    // 前端服务端口
  },

  // 数据库配置
  db: {
    "username": "autoaiworksys",
    "password": "tRWZXxH6a4AdnXf6",
    "database": "autoaiworksys",
    "host": "192.144.167.231",
    "port": 3306,
    "dialect": "mysql"
  },

  // Redis配置
  redis: {
    host: process.env.REDIS_HOST || 'localhost',
    port: process.env.REDIS_PORT || 6379,
    password: process.env.REDIS_PASSWORD || '',
    db: process.env.REDIS_DB || 0,
    keyPrefix: 'autowork:',  // key前缀
    ttl: 60 * 60 * 24 * 7    // 默认过期时间(7天)
  },
  oos: {
    "accessKeyId": "LTAI5tENEdLxFU7Ne9wGazsk",
    "accessKeySecret": "nvfvDfz2tLcOH8XE3EQpXsnBFpVyK5",
    region: 'oss-cn-beijing',
    bucket: 'light22600',
    timeout: 30 * 60 * 1000  // OSS 请求超时时间：30分钟（适用于大文件上传）
  },

  // 分页配置
  pagination: {
    defaultPageSize: 20,
    maxPageSize: 100
  },

  // 文件上传配置
  upload: {
    path: './upload',
    maxFileSize: 200 * 1024 * 1024,  // 200MB
    allowedTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/msword']
  },

  // 日志配置
  log: {
    path: './logs',
    level: env === 'development' ? 'debug' : 'info',
    maxFiles: '14d',  // 保留14天日志
    maxSize: '20m'    // 单文件最大20MB
  },

  // 白名单URL - 不需要token验证的接口
  "allowUrls": ["/admin_api/sys_user/login", "/admin_api/sys_user/authorityMenus", "/admin_api/sys_user/register", "/api/user/loginByWeixin", "/file/", "/sys_file/", "/admin_api/win_data/viewLogInfo", "/api/user/wx_auth", '/api/docs', 'api/swagger.json', 'payment/notify', 'payment/refund-notify', 'wallet/transfer_notify', 'user/sms/send', 'user/sms/verify', '/api/version/check','/api/file/upload_file_to_oss_by_auto_work','/api/version/create', '/admin_api/invite/register', '/admin_api/invite/send-sms'],


  // AI服务配置
  ai: {
    "apiKey": "sk-c83cdb06a6584f99bb2cd6e8a5ae3bbc",
    "baseUrl": "https://dashscope.aliyuncs.com/api/v1"
  },

  // MQTT配置
  mqtt: {
    host: process.env.MQTT_HOST || 'localhost',
    port: process.env.MQTT_PORT || 1883,
    username: process.env.MQTT_USERNAME || '',
    password: process.env.MQTT_PASSWORD || '',
    clientId: 'autowork-' + Math.random().toString(16).substr(2, 8)
  },

  // 定时任务配置
  schedule: {
    enabled: true,
    timezone: 'Asia/Shanghai'
  },
  qq_map_key: "7AXBZ-Z7M3V-BZQPK-53TUZ-2QLC6-RAFKU",


};
