Back to godoc.org
gitee.com/WisdomClassroom/core

Package core

v0.7.1
Latest Go to latest

The highest tagged major version is .

Published: 1 day ago | License: Apache-2.0 | Module: gitee.com/WisdomClassroom/core

Index

Constants

const (
	UserTypeManager = iota
	UserTypeTeacher
	UserTypeStudent
)
const (
	UserGenderOther = iota
	UserGenderMan
	UserGenderWoman
)
const (
	QuestionLevelBasic = iota
	QuestionLevelNormal
	QuestionLevelDifficult
	QuestionLevelChallenging
)
const (
	QuestionTypeSingle = iota
	QuestionTypeMultiple
	QuestionTypeJudge
)
const (
	FileTypeJPG = iota
	FileTypePNG
	FileTypePPT
	FileTypeXLS
	FileTypeDOC
	FileTypePPTX
	FileTypeXLSX
	FileTypeDOCX
	FileTypePDF
	FileTypeMP3
	FileTypeMP4
	FileTypeZIP
)
const (
	LogDebug int = iota
	LogInfo
	LogWarning
	LogError
)
const DefTokenCert string = "96be053dab04"
const DefaultPassword = "1234567890"
const TokenHeader string = "3c6b9fc1"
const TokenSplitCharacter string = "."
const TokenTimeout = int64(7 * 24 * time.Hour / time.Second)

Variables

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
)
var (
	BuildTag  string
	BuildGo   string
	BuildTime string
)
var (
	FlagHttpListen  string
	FlagGRPCListen  string
	FlagPPROFEnable bool
	FlagPPROFListen string
	FlagLogWithUDP  bool
	FlagLogAddr     string
	FlagTokenCert   string
)

func Base64ToString

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

func GenUUID

func GenUUID() string

36

func GetGormLogLevel

func GetGormLogLevel() logger.LogLevel

func IsDuplicateKeyErr

func IsDuplicateKeyErr(err error) bool

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

func IsForeignKeyErr

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

func PrintPromptInfo(message ...string)

func PrintPromptWarning

func PrintPromptWarning(message ...string)

func PublicFlag

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

func PublicServerFlag

func PublicServerFlag()

func PublicVersion

func PublicVersion()

func ReadTokenFromMetadata

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

func SprintPromptInfo

func SprintPromptInfo(message ...string) string

func SprintPromptWarning

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

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

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

Print: Interface for GORM debug log

func (*Logger) Printf

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

func (*Logger) Warning

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

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

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier