Documentation ¶
Index ¶
- Variables
- func ArrayContains[T ArrayType](arr *Array[T], e T) bool
- func ArrayDelete[T ArrayType](arr *Array[T], e T) bool
- func ArrayDeleteMany[T ArrayType](arr *Array[T], e ...T)
- func ArrayIndexOf[T ArrayType](arr *Array[T], e T) int
- func ArrayJoin(arr *Array[string], sep string) string
- func CheckPassword(origin, password string) (isValid bool, err error)
- func CheckUploadHash(uploadId, targetId int64, hash string) (bool, error)
- func CheckUploadToken(account string, ts int64, id int64, mod int8, path string, token string) (bool, error)
- func CreateCaptcha(num int) string
- func CreatePassword(password string) (string, error)
- func CreateUploadToken(account string, ts int64, id int64, mod int8, path string) (string, error)
- func EnsureCountNoError(count int64, err error)
- func EnsureFoundNoError(found bool, err error)
- func EnsureIgnoreFirstNoError(count any, err error)
- func EnsureNoError(err error)
- func FormatEmail(email string) string
- func FormatPhone(phone string) string
- func GenerateHMAC(text string, key string) (string, error)
- func GetEnv(name EnvKey) string
- func GetEnvBool(name EnvKey) bool
- func GetEnvBoolDefault(name EnvKey, defaultValue bool) bool
- func GetEnvDefault(name EnvKey, defaultValue string) string
- func GetEnvInt[T int | uint | int64 | uint64](name EnvKey) T
- func GetEnvIntDefault[T int | uint | int64 | uint64](name EnvKey, defaultValue T) T
- func InitSnowflake(node int64) error
- func MakeUploadHash(uploadId, targetId int64) (string, error)
- func ResolveCmd(cmd string) string
- func SnowCode() string
- func SnowId() int64
- func SnowWithPrefix(prefix string, id *int64) string
- func Spawn(cmd string, args []string, opt *SpawnOptions) (spawnOutput, error)
- func SpawnSimple(cmd string, args []string) (spawnOutput, error)
- func SqlColAs(field string, field2 string) string
- func SqlDeleted() string
- func SqlNotDeleted() string
- func SqlWhereEq(field string) string
- func SqlWhereGt(field string) string
- func SqlWhereIsNull(field string) string
- func SqlWhereLike(field string) string
- func SqlWherePrefix(field string) string
- func TimeStamp() string
- func Uuid() string
- func ValueOf[T any](value *T) T
- func ValueTo[T any](value T) *T
- func VerifyHMAC(HMAC string, text string, key string) (bool, error)
- func WithRecover(fn func() error) (err error)
- type Array
- func (arr *Array[T]) Concat(next Array[T])
- func (arr *Array[T]) Filter(f func(any any) bool) Array[T]
- func (arr *Array[T]) ForEach(f func(e any))
- func (arr *Array[T]) Insert(i int, e ...T)
- func (arr *Array[T]) Pop() any
- func (arr *Array[T]) Push(e ...T)
- func (arr *Array[T]) Remove(i int)
- func (arr *Array[T]) Shift() *T
- func (arr *Array[T]) Unshift(e ...T)
- type ArrayType
- type ClientErrorCode
- type Data
- type DeleteStatus
- type EnvGetter
- func (getter *EnvGetter) Bool() bool
- func (getter *EnvGetter) Int() (r int)
- func (getter *EnvGetter) Int64() (r int64)
- func (getter *EnvGetter) KeyName() string
- func (getter *EnvGetter) Kind() reflect.Kind
- func (getter *EnvGetter) String() string
- func (getter *EnvGetter) UInt() (r uint)
- func (getter *EnvGetter) UInt64() (r uint64)
- func (getter *EnvGetter) Value() any
- type EnvKey
- type Error
- func (e *Error) Clone() *Error
- func (e *Error) Error() string
- func (e *Error) GetError() error
- func (e *Error) GinError() (int, error)
- func (e *Error) JsonError() (int, interface{})
- func (e *Error) Panic()
- func (e *Error) PanicError(err error)
- func (e *Error) WithCode(code string) *Error
- func (e *Error) WithMessage(message string) *Error
- func (e *Error) WithStack(stack error) *Error
- type PageInfo
- type Runner
- type ServerErrorCode
- type SpawnOptions
- type SqlFieldType
- func (s SqlFieldType) Eq(value any) (string, any)
- func (s SqlFieldType) Gt(value any) (string, any)
- func (s SqlFieldType) Gte(value any) (string, any)
- func (s SqlFieldType) IsNull() string
- func (s SqlFieldType) Like(value any) (string, any)
- func (s SqlFieldType) Lt(value any) (string, any)
- func (s SqlFieldType) Lte(value any) (string, any)
- func (s SqlFieldType) Neq(value any) (string, any)
- func (s SqlFieldType) NotIsNull() string
- func (s SqlFieldType) OrderAsc() string
- func (s SqlFieldType) OrderDesc() string
- func (s SqlFieldType) Prefix(value any) (string, any)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // 200 Success = NewError(http.StatusOK, http.StatusText(http.StatusOK)) // 500 InternalServerError = NewError(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError)) NotImplemented = NewError(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) // 400 BadRequest = NewError(http.StatusBadRequest, http.StatusText(http.StatusBadRequest)) // 客户端请求错误 NotFound = NewError(http.StatusNotFound, http.StatusText(http.StatusNotFound)) // 服务器不可访问 Forbidden = NewError(http.StatusForbidden, http.StatusText(http.StatusForbidden)) // 禁止访问 )
View Source
var ( ErrInputParamsInvalid ClientErrorCode = "input.paramsInvalid" // 参数错误 ErrDataDuplicate ServerErrorCode = "data.duplicate" // 数据重复 ErrDataExists ServerErrorCode = "data.exists" // 数据已存在 ErrDataNoFound ServerErrorCode = "data.notFound" // 数据不存在 ErrAuthAccessTokenInvalid ClientErrorCode = "auth.accessTokenInvalid" // 访问令牌错误 ErrAuthLoginFail ServerErrorCode = "auth.loginFail" // 登录失败 ErrAuthRefreshTokenInvalid ServerErrorCode = "auth.refreshTokenInvalid" // 刷新令牌失败 )
Functions ¶
func ArrayContains ¶
func ArrayDelete ¶
func ArrayDeleteMany ¶
func ArrayIndexOf ¶
func CheckPassword ¶
func CheckUploadToken ¶
func CreateCaptcha ¶
func CreatePassword ¶
func CreateUploadToken ¶
func EnsureCountNoError ¶
func EnsureFoundNoError ¶
func EnsureNoError ¶
func EnsureNoError(err error)
func FormatEmail ¶
func FormatPhone ¶
func GetEnvBool ¶
func GetEnvBoolDefault ¶
func GetEnvDefault ¶
func GetEnvIntDefault ¶
func InitSnowflake ¶
func MakeUploadHash ¶
func ResolveCmd ¶
func SnowWithPrefix ¶
func SpawnSimple ¶
func SqlDeleted ¶
func SqlDeleted() string
func SqlNotDeleted ¶
func SqlNotDeleted() string
func SqlWhereEq ¶
func SqlWhereGt ¶
func SqlWhereIsNull ¶
func SqlWhereLike ¶
func SqlWherePrefix ¶
func WithRecover ¶
Types ¶
type Array ¶
type Array[T any] []T
数组定义
func GetDbStructKeys ¶
func GetStructKeys ¶
func GetXormStructKeys ¶
type ClientErrorCode ¶
type ClientErrorCode string
客户端错误
func (ClientErrorCode) Error ¶
func (code ClientErrorCode) Error() *Error
func (ClientErrorCode) Panic ¶
func (code ClientErrorCode) Panic()
func (ClientErrorCode) PanicError ¶
func (code ClientErrorCode) PanicError(err error)
type DeleteStatus ¶
type DeleteStatus int8
const ( DeleteStatusDefault DeleteStatus = 0 DeleteStatusDeleted DeleteStatus = 1 DeleteStatusDroped DeleteStatus = 2 )
type EnvGetter ¶
type EnvGetter struct { Key EnvKey // contains filtered or unexported fields }
func GetterDefault ¶
type Error ¶
type Error struct { StatusCode int `json:"-"` Code string `json:"code"` Message string `json:"message"` Stack error `json:"-"` }
错误
func ClientError ¶
func ClientError(code ClientErrorCode) *Error
func ServerError ¶
func ServerError(code ServerErrorCode) *Error
func (*Error) PanicError ¶
func (*Error) WithMessage ¶
type PageInfo ¶
type ServerErrorCode ¶
type ServerErrorCode string
服务端错误
func (ServerErrorCode) Error ¶
func (code ServerErrorCode) Error() *Error
func (ServerErrorCode) Panic ¶
func (code ServerErrorCode) Panic()
func (ServerErrorCode) PanicError ¶
func (code ServerErrorCode) PanicError(err error)
type SpawnOptions ¶
type SpawnOptions struct { // 使用程序std输入输入 SystemStdout bool }
type SqlFieldType ¶ added in v1.0.8
type SqlFieldType string
func Field ¶ added in v1.0.8
func Field(field string) SqlFieldType
func (SqlFieldType) IsNull ¶ added in v1.0.8
func (s SqlFieldType) IsNull() string
func (SqlFieldType) NotIsNull ¶ added in v1.0.8
func (s SqlFieldType) NotIsNull() string
func (SqlFieldType) OrderAsc ¶ added in v1.0.8
func (s SqlFieldType) OrderAsc() string
xorm.OrderBy field asc
func (SqlFieldType) OrderDesc ¶ added in v1.0.8
func (s SqlFieldType) OrderDesc() string
xorm.OrderBy field desc
Click to show internal directories.
Click to hide internal directories.