common.go 2.2 KB
package constant

import (
	"fmt"
	"os"
	"strconv"
)

var SERVICE_NAME = "allied-creation-manufacture"
var SERVICE_ENV = "dev"
var HTTP_PORT int = 8081
var CACHE_PREFIX = "allied-creation-manufacture-dev"
var LOG_LEVEL = "debug"
var LOG_FILE = "app.log"

//天联共创基础模块
var ALLIED_CREATION_BASIC_HOST = "http://localhost:8080" //"http://allied-creation-basic-dev.fjmaimaimai.com"

//天联共创用户模块
var ALLIED_CREATION_USER_HOST = "http://localhost:8081" //"http://allied-creation-user-dev.fjmaimaimai.com"

//天联共创业务模块
var ALLIED_CREATION_COOPERATION_HOST = "http://localhost:8082" // "http://allied-creation-cooperation-dev.fjmaimaimai.com"

var CUSTOMER_ACCOUNT = []int64{3129687560814592, 3129687690100739, 3492238958608384}

const CUSTOMER_ACCOUNT_DELIMITER = ","

/*****   1.数据传输  *****/
const HeaderCompanyId = "companyId"
const HeaderUserId = "userId"
const HeaderOrgId = "orgId"
const HeaderOrgIds = "orgIds"

func init() {
	if os.Getenv("LOG_LEVEL") != "" {
		LOG_LEVEL = os.Getenv("LOG_LEVEL")
	}
	//if os.Getenv("CUSTOMER_ACCOUNT") != "" {
	//	account := os.Getenv("CUSTOMER_ACCOUNT")
	//	accounts := strings.Split(account, CUSTOMER_ACCOUNT_DELIMITER)
	//	var tmpAccounts []int64
	//	for i := range accounts {
	//		v, err := strconv.ParseInt(accounts[i], 10, 64)
	//		if err != nil {
	//			panic(err)
	//		}
	//		tmpAccounts = append(tmpAccounts, v)
	//	}
	//	if len(tmpAccounts) > 0 {
	//		CUSTOMER_ACCOUNT = tmpAccounts
	//	}
	//}

	if os.Getenv("ALLIED_CREATION_BASIC_HOST") != "" {
		ALLIED_CREATION_BASIC_HOST = os.Getenv("ALLIED_CREATION_BASIC_HOST")
	}
	if os.Getenv("ALLIED_CREATION_USER_HOST") != "" {
		ALLIED_CREATION_USER_HOST = os.Getenv("ALLIED_CREATION_USER_HOST")
	}
	if os.Getenv("ALLIED_CREATION_COOPERATION_HOST") != "" {
		ALLIED_CREATION_COOPERATION_HOST = os.Getenv("ALLIED_CREATION_COOPERATION_HOST")
	}
	//if os.Getenv("SMS_SERVE_HOST") != "" {
	//	SMS_SERVE_HOST = os.Getenv("SMS_SERVE_HOST")
	//}

	if os.Getenv("SERVICE_ENV") != "" {
		SERVICE_ENV = os.Getenv("SERVICE_ENV")
	}
	if os.Getenv("HTTP_PORT") != "" {
		HTTP_PORT, _ = strconv.Atoi(os.Getenv("HTTP_PORT"))
	}
	SERVICE_NAME = fmt.Sprintf("%v-%v", SERVICE_NAME, SERVICE_ENV)
	CACHE_PREFIX = SERVICE_NAME
}