core

package module
v0.7.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2021 License: Apache-2.0 Imports: 25 Imported by: 9

Documentation

Index

Constants

View Source
const (
	ResponseStatusCodeSuccess        = 0
	ResponseStatusCodeServerError    = 1
	ResponseStatusCodeNotAuth        = 2
	ResponseStatusCodeFieldTypeError = 3
	ResponseStatusCodeOtherError     = -1
)
View Source
const (
	UserTypeTeacher = 1
	UserTypeStudent = 2
)
View Source
const (
	UserGenderMan   = 1
	UserGenderWoman = 2
	UserGenderOther = -1
)
View Source
const (
	QuestionLevelBasic       = 0
	QuestionLevelNormal      = 1
	QuestionLevelDifficult   = 2
	QuestionLevelChallenging = 3
)
View Source
const (
	QuestionTypeSingle   = 0
	QuestionTypeMultiple = 1
	QuestionTypeJudge    = 2
)
View Source
const (
	FileTypeJPG = iota
	FileTypePNG
	FileTypePPT
	FileTypeXLS
	FileTypeDOC
	FileTypePPTX
	FileTypeXLSX
	FileTypeDOCX
	FileTypePDF
	FileTypeMP3
	FileTypeMP4
	FileTypeZIP
)
View Source
const (
	LogDebug int = iota
	LogInfo
	LogWarning
	LogError
)
View Source
const DefTokenCert string = "96be053dab04"
View Source
const DefaultPassword = "1234567890"
View Source
const TokenCookieName = "AuthToken"
View Source
const TokenHeader string = "3c6b9fc1"
View Source
const TokenSplitCharacter string = "."
View Source
const TokenTimeout = int64(7 * 24 * time.Hour / time.Second)

Variables

View Source
var (
	FlagHelp          bool
	FlagVersion       bool
	FlagUseSqlite     bool
	FlagUsePG         bool
	FlagSqliteDB      string
	FlagPgAddr        string
	FlagPgPort        int
	FlagPgDB          string
	FlagPgUser        string
	FlagPgPassword    string
	FlagPgSSLMode     string
	FlagPgSSLCert     string
	FlagPgSSLKey      string
	FlagPgSSLRootCert string
	FlagLogLevel      int
)
View Source
var (
	BuildTag  string
	BuildGo   string
	BuildTime string
)
View Source
var (
	FlagHttpListen  string
	FlagGRPCListen  string
	FlagPPROFEnable bool
	FlagPPROFListen string
	FlagLogWithUDP  bool
	FlagLogAddr     string
	FlagTokenCert   string
)

Functions

func Base64ToString

func Base64ToString(v string) (c string, err error)

func GenUUID

func GenUUID() string

36

func GetGormLogLevel added in v0.7.0

func GetGormLogLevel() logger.LogLevel

func IsDuplicateKeyErr added in v0.7.0

func IsDuplicateKeyErr(err error) bool

IsDuplicateKeyErr 返回是否为重复的唯一约束错误, 一般用于 Create, 仅适用于 PostgreSQL

func IsForeignKeyErr added in v0.7.0

func IsForeignKeyErr(err error) bool

IsForeignKeyErr 返回是否为外键要关联的记录不存在错误, 仅适用于 PostgreSQL

func NewTokenCert

func NewTokenCert(str string) *string

func ParseUUID

func ParseUUID(uuidStr string) (uuid.UUID, error)

func PrintPromptInfo added in v0.6.7

func PrintPromptInfo(message ...string)

func PrintPromptWarning added in v0.6.7

func PrintPromptWarning(message ...string)

func PublicFlag added in v0.2.0

func PublicFlag(tagVer string, goVer string, timeVer string)

func PublicServerFlag added in v0.4.0

func PublicServerFlag()

func PublicVersion added in v0.4.0

func PublicVersion()

func ReadTokenFromMetadata added in v0.7.0

func ReadTokenFromMetadata(md metadata.MD) (string, error)

func SprintPromptInfo added in v0.6.7

func SprintPromptInfo(message ...string) string

func SprintPromptWarning added in v0.6.7

func SprintPromptWarning(message ...string) string

func StartPPOFDebug

func StartPPOFDebug(server http.Server, showHelp bool)

func StringToBase64

func StringToBase64(v string) (c string)

func StringToMD5

func StringToMD5(v string) (c string)

32

func StringToSha1

func StringToSha1(v string) (c string)

40

func StringToSha256

func StringToSha256(v string) (c string)

64

func StringToSha512

func StringToSha512(v string) (c string)

128

func TimestampToUTC8String

func TimestampToUTC8String(timestamp int64) string

func TimestampToUTCString

func TimestampToUTCString(timestamp int64) string

func UTC8StringToTimestamp

func UTC8StringToTimestamp(str string) (int64, error)

func UTCStringToTimestamp

func UTCStringToTimestamp(str string) (int64, error)

func VerifyToken

func VerifyToken(v string, tokenCert *string) error

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger(level int) *Logger

func NewUDPLogger

func NewUDPLogger(level int, addr *net.UDPAddr, maxBytes int) (*Logger, error)

func (*Logger) Debug

func (logger *Logger) Debug(msg string)

func (*Logger) Error

func (logger *Logger) Error(msg string)

func (*Logger) Info

func (logger *Logger) Info(msg string)

func (*Logger) Print added in v0.1.1

func (logger *Logger) Print(values ...interface{})

Print: Interface for GORM debug log

func (*Logger) Printf added in v0.7.0

func (logger *Logger) Printf(msg string, data ...interface{})

func (*Logger) Warning added in v0.4.8

func (logger *Logger) Warning(msg string)

type Token

type Token struct {
	Timestamp int64  `json:"timestamp"`
	LifeCycle int64  `json:"lifeCycle"`
	AccountID uint32 `json:"accountID"`
	Name      string `json:"name"`
	Gender    int32  `json:"gender"`
	Type      int32  `json:"type"`
	IsManager bool   `json:"isManager"`
}

func NewToken

func NewToken() *Token

func UnpackTokenFromMetadata added in v0.7.0

func UnpackTokenFromMetadata(md metadata.MD) (*Token, error)

func (*Token) PackToken

func (token *Token) PackToken(tokenCert *string) string

func (*Token) UnpackToken

func (token *Token) UnpackToken(v string, tokenCert *string) error

Directories

Path Synopsis
protobufs
v1/pb
Package pb is a reverse proxy.
Package pb is a reverse proxy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL