var path = require('path');
var ENVINPUT = {
  DB_HOST: process.env.DB_HOST,
  DB_PORT: process.env.DB_PORT,
  DB_USER: process.env.DB_USER,
  DB_PWD: process.env.DB_PWD,
  DB_NAME: process.env.ZC_CHANNEL_WEB_DB_NAME,
  REDIS_HOST: process.env.REDIS_HOST,
  REDIS_PORT: process.env.REDIS_PORT,
  REDIS_PWD: process.env.REDIS_PWD,
  REDIS_DB: process.env.ZC_CHANNEL_WEB_REDIS_DB,
  APP_ENV: process.env.APP_ENV ? process.env.APP_ENV : "dev"
};
var settings = {
  env: ENVINPUT.APP_ENV,
  appKey: "201911251551",
  paasKey: "wx76a324c5d201d1a4",
  secret: "56006077354d48858026c80c0e10bef6",
  salt: "%iatpD1gcxz7iF#B",
  basepath: path.normalize(path.join(__dirname, '../..')),
  port: process.env.NODE_PORT || 4004,
  channelApiUrl: function () {
    if (this.env == "dev") {
      return "http://zcchannel.apps.com:4003";
    } else {
      return "http://zc-channel-service";
    }
  },
  paasUrl: function () {
    if (this.env == "dev") {
      return "http://p.apps.com:4001/";
    } else {
      return "http://open.gongsibao.com/";
    }
  },
  reqEsAddr: function () {
    if (this.env == "dev") {
      var localsettings = require("./localsettings");
      return "http://43.247.184.94:7200/";//localsettings.reqEsDevUrl;
    } else {
      return "http://43.247.184.94:7200/";
    }
  },
  apiconfig: {
    opLogUrl: function () {
      return settings.reqEsAddr() + "bigdata_zc_op_log/_doc?pretty";
    },
    opLogEsIsAdd: function () {
      return 1;
    },
  },

  homePage: function () {
    if (this.env == "dev") {
      var localsettings = require("./localsettings");
      return localsettings.reqHomePageDevUrl;
    } else {
      return "http://boss.gongsibao.com/";
    }
  },
  authUrl: function () {
    if (this.env == "dev") {
      var localsettings = require("./localsettings");
      return localsettings.reqAuthUrl;
    } else {
      return "http://zcchannelweb.gongsibao.com/admin";
    }
  },
  reqMgAddr: function () {
    if (this.env == "dev") {
      var localsettings = require("./localsettings");
      return localsettings.reqMgDevUrl;
    } else {
      return "mongodb://wdy1:123456@43.247.184.94:27017/";
    }
  },
  redis: function () {
    if (this.env == "dev") {
      var localsettings = require("./localsettings");
      return localsettings.redis;
    } else {
      return {
        host: ENVINPUT.REDIS_HOST,
        port: ENVINPUT.REDIS_PORT,
        password: ENVINPUT.REDIS_PWD,
        db: ENVINPUT.REDIS_DB,
      };
    }
  }
};
module.exports = settings;
