schema

package
v0.0.0-...-364eef1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Demo

type Demo struct {
	ID        uint64    `json:"id"`                      // 唯一标识
	Code      string    `json:"code" binding:"required"` // 编号
	Name      string    `json:"name" binding:"required"` // 名称
	Memo      string    `json:"memo"`                    // 备注
	Status    int       `json:"status"`                  // 状态(1:启用 2:禁用)
	Creator   uint64    `json:"creator"`                 // 创建者
	CreatedAt time.Time `json:"created_at"`              // 创建时间
	UpdatedAt time.Time `json:"updated_at"`              // 更新时间
}

Demo DemoManage对象

type DemoQueryOptions

type DemoQueryOptions struct {
	OrderFields  []*OrderField // 排序字段
	SelectFields []string      // 查询字段
}

DemoQueryOptions 查询可选参数项

type DemoQueryParam

type DemoQueryParam struct {
	PaginationParam
}

DemoQueryParam 查询条件

type DemoQueryResult

type DemoQueryResult struct {
	Data       Demos
	PageResult *PaginationResult
}

DemoQueryResult 查询结果

type Demos

type Demos []*Demo

Demos DemoManage列表

type ErrorItem

type ErrorItem struct {
	Code    int    `json:"code"`    // 错误码
	Message string `json:"message"` // 错误信息
}

ErrorItem 响应错误项

type ErrorResult

type ErrorResult struct {
	Error ErrorItem `json:"error"` // 错误项
}

ErrorResult 响应错误

type IDResult

type IDResult struct {
	ID uint64 `json:"id"`
}

IDResult 响应唯一标识

func NewIDResult

func NewIDResult(id uint64) *IDResult

NewIDResult 创建响应唯一标识实例

type ListResult

type ListResult struct {
	List       interface{}       `json:"list"`
	Pagination *PaginationResult `json:"pagination,omitempty"`
}

ListResult 响应列表数据

type OrderDirection

type OrderDirection int

OrderDirection 排序方向

const (
	// OrderByASC 升序排序
	OrderByASC OrderDirection = iota + 1
	// OrderByDESC 降序排序
	OrderByDESC
)

type OrderField

type OrderField struct {
	Key       string         // 字段名(字段名约束为小写蛇形)
	Direction OrderDirection // 排序方向
}

OrderField 排序字段

func NewOrderField

func NewOrderField(key string, d OrderDirection) *OrderField

NewOrderField 创建排序字段

func NewOrderFieldWithKeys

func NewOrderFieldWithKeys(keys []string, directions ...map[int]OrderDirection) []*OrderField

NewOrderFieldWithKeys 创建排序字段(默认升序排序),可指定不同key的排序规则 keys 需要排序的key directions 排序规则,按照key的索引指定,索引默认从0开始

func NewOrderFields

func NewOrderFields(orderFields ...*OrderField) []*OrderField

NewOrderFields 创建排序字段列表

type PaginationParam

type PaginationParam struct {
	Pagination bool `form:"-"`                                     // 是否使用分页查询
	OnlyCount  bool `form:"-"`                                     // 是否仅查询count
	Current    int  `form:"current,default=1"`                     // 当前页
	PageSize   int  `form:"pageSize,default=10" binding:"max=100"` // 页大小
}

PaginationParam 分页查询条件

func (PaginationParam) GetCurrent

func (a PaginationParam) GetCurrent() int

GetCurrent 获取当前页

func (PaginationParam) GetPageSize

func (a PaginationParam) GetPageSize() int

GetPageSize 获取页大小

type PaginationResult

type PaginationResult struct {
	Total    int64 `json:"total"`
	Current  int   `json:"current"`
	PageSize int   `json:"pageSize"`
}

PaginationResult 分页查询结果

type StatusResult

type StatusResult struct {
	Status StatusText `json:"status"` // 状态(OK)
}

StatusResult 响应状态

type StatusText

type StatusText string

StatusText 定义状态文本

const (
	OKStatus    StatusText = "OK"
	ErrorStatus StatusText = "ERROR"
	FailStatus  StatusText = "FAIL"
)

定义HTTP状态文本常量

func (StatusText) String

func (t StatusText) String() string

Jump to

Keyboard shortcuts

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