app

package
v0.0.0-...-352e39c Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GormContext string = "Ctx_Gorm" // Gorm Context 标识
	GinContext  string = "Ctx_Gin"  // Gin Context 标识
)

Context 标识定义

View Source
const (
	GinTime    = "Gin_Time" // Gin请求时间,服务端接收到请求时间
	GinBody    = "Gin_Body" // Gin请求内容,请求体解密后内容
	GinData    = "Gin_Data" // Gin请求内容,请求体原始内容,未解密
	GinLogger  = "Gin_Log"  // 是否记录请求日志
	GinEncrypt = "Gin_Aes"  // 是否进行AES加密
	GinUserID  = "Gin_Uid"  // 当前请求用户ID
)

Gin 标识定义

View Source
const (
	GinSignError        int8 = 10 // 签名校验错误
	GinTimeError        int8 = 11 // 客户端时间错误
	GinVersionError     int8 = 12 // 客户端版本过低
	GinServerClosed     int8 = 13 // 服务端暂停服务
	GinParamError       int8 = 14 // 参数校验失败
	GinAuthError        int8 = 15 // 身份鉴权失败
	GinActionError      int8 = 16 // 无接口操作权限
	GinDataError        int8 = 17 // 无数据操作权限
	GinNotFound         int8 = 18 // 未找到匹配接口
	GinMustParam        int8 = 19 // 缺少必要参数
	GinApiStop          int8 = 20 // 接口已停用
	GinApiLock          int8 = 21 // 请求业务处理中
	GinSysError         int8 = 22 // 系统处理异常
	GinTransactionError int8 = 99 // 数据处理异常
)

Gin 错误定义

View Source
const (
	AuditNone   int8 = 0 // 未提交审核
	AuditWait   int8 = 1 // 已提交审核
	AuditPass   int8 = 2 // 已通过审核
	AuditReject int8 = 3 // 已驳回审核
	AuditCancel int8 = 9 // 已撤销审核
)

审核状态

View Source
const (
	PlatformID uint64 = 1 // 平台ID
	GuestID    uint64 = 0 // 访客ID
)

内置用户ID

View Source
const (
	UserTypeEmployee int8 = 1 // 平台用户,工作人员用户
	UserTypeMember   int8 = 2 // 注册用户,外部注册用户
)

用户类型

Variables

View Source
var IDWorker = x.SnowfIDWorker(1, 1671033600000) // 2022-12-15 00:00:00.000

Trans 翻译器

Functions

This section is empty.

Types

type ApiError

type ApiError struct {
	ErrCode int8
	Message string
	Origin  error
}

ApiError 接口错误

func (*ApiError) Error

func (e *ApiError) Error() string

type GormJSON

type GormJSON json.RawMessage

GormJSON defined JSON data type, need to implement driver.Valuer, sql.Scanner interface

func (*GormJSON) GormDBDataType

func (j *GormJSON) GormDBDataType(db *gorm.DB, _ *schema.Field) string

GormDBDataType gorm dao data type

func (*GormJSON) GormDataType

func (j *GormJSON) GormDataType() string

GormDataType gorm common data type

func (*GormJSON) GormValue

func (j *GormJSON) GormValue(_ context.Context, db *gorm.DB) clause.Expr

func (*GormJSON) MarshalJSON

func (j *GormJSON) MarshalJSON() ([]byte, error)

MarshalJSON to output non base64 encoded []byte

func (*GormJSON) Scan

func (j *GormJSON) Scan(value any) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (*GormJSON) String

func (j *GormJSON) String() string

func (*GormJSON) UnmarshalJSON

func (j *GormJSON) UnmarshalJSON(b []byte) error

UnmarshalJSON to deserialize []byte

func (*GormJSON) Value

func (j *GormJSON) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type MySQLError

type MySQLError struct {
	Message string
	SQL     string
	Origin  error
}

MySQLError 数据库错误

func (*MySQLError) Error

func (e *MySQLError) Error() string

type Pager

type Pager struct {
	Page  int   `json:"page" binding:"gte=1" label:"分页页码"`
	Size  int   `json:"size" binding:"gte=1,lte=10000" label:"加载数量"`
	Time  int64 `json:"time" binding:"gte=0" label:"加载首页时间"`
	Pages int   `json:"pages" label:"总页码"`
	Rows  int   `json:"rows" label:"总记录数"`
}

Pager 分页信息

func (*Pager) GenQuery

func (p *Pager) GenQuery() *Query

GenQuery 生成分页查询对象

type Query

type Query struct {
	SQL   string // 业务SQL语句
	Param []any  // 业务SQL参数
	Order string // Order 语句
	Page  int    // 当前分页
	Size  int    // 分页数量
	Time  int64  // 初次查询时间
	Pages int    // 总页码
	Rows  int    // 总记录数
}

Query SQL查询对象

func (*Query) AddOrder

func (q *Query) AddOrder(order string) *Query

AddOrder 添加语句

func (*Query) AddParam

func (q *Query) AddParam(param any) *Query

AddParam 添加参数

func (*Query) AddSQL

func (q *Query) AddSQL(sql string) *Query

AddSQL 添加语句

func (*Query) AddSQLParam

func (q *Query) AddSQLParam(sql string, param ...any) *Query

AddSQLParam 添加语句和参数

func (*Query) GenPager

func (q *Query) GenPager() *Pager

GenPager 生成分页结果

type RedisError

type RedisError struct {
	Message string
	Command string
	Origin  error
}

RedisError Redis 错误

func (*RedisError) Error

func (e *RedisError) Error() string

type Result

type Result struct {
	Status *status `json:"stat"`
	Data   any     `json:"data,omitempty"`
}

Result 接口响应体

func Fail

func Fail(error int8) *Result

Fail 响应失败

func Succ

func Succ() *Result

Succ 响应成功

func (*Result) SetAttr

func (r *Result) SetAttr(key string, value any) *Result

SetAttr 设置响应数据,单个字段

func (*Result) SetError

func (r *Result) SetError(err error) *Result

SetError 设置Error错误

func (*Result) SetItem

func (r *Result) SetItem(item any) *Result

SetItem 设置响应数据,单条

func (*Result) SetItems

func (r *Result) SetItems(items any) *Result

SetItems 设置响应数据,多条

func (*Result) SetMessage

func (r *Result) SetMessage(message string) *Result

SetMessage 设置响应信息

func (*Result) SetPagerItems

func (r *Result) SetPagerItems(pager *Pager, items any) *Result

SetPagerItems 设置分页响应数据

func (*Result) SetSummPagerItems

func (r *Result) SetSummPagerItems(pager *Pager, summ any, items any) *Result

SetSummPagerItems 设置分页和统计响应数据

Jump to

Keyboard shortcuts

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