model

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiJson

type ApiJson struct {
	Code   int         `json:"code"`
	Status bool        `json:"status"`
	Msg    string      `json:"msg"`
	Data   interface{} `json:"data"`
}

func ApiResponse

func ApiResponse(code int, status bool, objects interface{}, msg string) *ApiJson

func ErrorBuildJWT

func ErrorBuildJWT(errs ...error) *ApiJson

ErrorBuildJWT 生成凭证错误

func ErrorDeleteDatabase

func ErrorDeleteDatabase(errs ...error) *ApiJson

ErrorDeleteDatabase 删除数据库失败

func ErrorIncompleteData

func ErrorIncompleteData(errs ...error) *ApiJson

ErrorIncompleteData 数据不完整

func ErrorInsertDatabase

func ErrorInsertDatabase(errs ...error) *ApiJson

ErrorInsertDatabase 插入数据库失败

func ErrorInternalServer

func ErrorInternalServer(errs ...error) *ApiJson

ErrorInternalServer 服务器内部错误

func ErrorInvalidData

func ErrorInvalidData(errs ...error) *ApiJson

ErrorInvalidData 数据解析失败

func ErrorNoPermissions

func ErrorNoPermissions(errs ...error) *ApiJson

ErrorNoPermissions 账号权限不足

func ErrorNotFound

func ErrorNotFound(errs ...error) *ApiJson

ErrorNotFound 未找到数据记录

func ErrorQueryDatabase

func ErrorQueryDatabase(errs ...error) *ApiJson

ErrorQueryDatabase 查询数据库失败

func ErrorUnauthorized

func ErrorUnauthorized(errs ...error) *ApiJson

ErrorUnauthorized 未认证登录

func ErrorUpdateDatabase

func ErrorUpdateDatabase(errs ...error) *ApiJson

ErrorUpdateDatabase 更新数据库失败

func ErrorValidation

func ErrorValidation(errs ...error) *ApiJson

ErrorValidation 数据检验失败

func ErrorVerification

func ErrorVerification(errs ...error) *ApiJson

ErrorVerification 认证失败

func Fail

func Fail(objects interface{}, msg string) *ApiJson

Fail 业务失败

func Success

func Success(objects interface{}, msg string) *ApiJson

Success 成功

func SuccessCreate

func SuccessCreate(objects interface{}, msg string) *ApiJson

SuccessCreate 成功创建资源

func SuccessPaged

func SuccessPaged(entries interface{}, total uint, msg string) *ApiJson

SuccessPaged 成功

func SuccessUpdate

func SuccessUpdate(objects interface{}, msg string) *ApiJson

SuccessUpdate 成功更新/删除资源

type AuthInfo

type AuthInfo struct {
	User  uint
	Name  string
	Role  string
	IP    string
	Other map[string]any
}

type BaseModel

type BaseModel struct {
	gorm.Model
	CreatedBy uint
	UpdatedBy uint
}

type Page

type Page struct {
	Entries interface{} `json:"entries"`
	Total   uint        `json:"total"`
}

func PagedData

func PagedData(entries interface{}, total uint) *Page

type PageParam

type PageParam struct {
	OrderBy string `json:"order_by" url:"order_by" validate:"omitempty,order_by"` // 排序字段 (默认为ID正序) 只接受`{field} {asc|desc}`格式 (e.g. `id desc`)
	Offset  uint   `json:"offset" url:"offset"`                                   // 偏移量 (默认为0)
	Limit   uint   `json:"limit" url:"limit"`                                     // 每页记录数 (默认为50)
}

Jump to

Keyboard shortcuts

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