common.go 1017 字节
package constant

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

var SERVICE_NAME = "allied-creation-user"
var SERVICE_ENV = "dev"
var CACHE_PREFIX = "allied-creation-user-dev"
var LOG_LEVEL = "debug"

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

const CUSTOMER_ACCOUNT_DELIMITER = ","

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

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
		}
	}
	CACHE_PREFIX = fmt.Sprintf("%v-%v", SERVICE_NAME, SERVICE_ENV)
}