61 lines
1.3 KiB
Go
61 lines
1.3 KiB
Go
package global
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"github.com/baidubce/bce-sdk-go/services/bos"
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/go-redis/redis"
|
|
"go.uber.org/zap"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
var (
|
|
ServerSettings ServerConfig
|
|
Db *gorm.DB
|
|
RootRouter *gin.RouterGroup
|
|
Logger *zap.SugaredLogger
|
|
HttpClient map[string]*http.Client
|
|
Redis *redis.Client
|
|
BosClient *bos.Client
|
|
)
|
|
|
|
func GetListenOn() string {
|
|
return fmt.Sprintf("%s:%d", ServerSettings.Listen, ServerSettings.Port)
|
|
}
|
|
|
|
func GetHttpClient(key string) (*http.Client, error) {
|
|
client := HttpClient[string(key)]
|
|
if client == nil {
|
|
return nil, errors.New("Not fount the http client: " + key)
|
|
}
|
|
return client, nil
|
|
}
|
|
|
|
const (
|
|
CHINA_NCOV_STATISTIC_URL = "https://api.inews.qq.com/newsqa/v1/query/inner/publish/modules/list?modules=statisGradeCityDetail,diseaseh5Shelf"
|
|
ENV_NOLOG = "nolog"
|
|
TOKEN_EXPIRE_DAYS = 15
|
|
FACKER_HOST = "http://myhost.fallen-angle.com:5000/"
|
|
|
|
REGISTER_REDIS_KEY = "register_key"
|
|
CHANGEPWD_REDIS_KEY = "changepwd_key"
|
|
)
|
|
|
|
var (
|
|
ID_ROLE_MAP = map[int]string{
|
|
0: "SYSTEM",
|
|
4: "VOLUNTEER",
|
|
8: "WORKER",
|
|
12: "ADMIN",
|
|
}
|
|
ROLE_ID_MAP = map[string]int{
|
|
"SYSTEM": 0,
|
|
"VOLUNTEER": 4,
|
|
"WORKER": 8,
|
|
"ADMIN": 12,
|
|
}
|
|
)
|