Documentation ¶
Index ¶
- Constants
- Variables
- func BadRequest(resp *restful.Response, err error)
- func BindData(req *restful.Request, data interface{}) error
- func BindQuery(req *restful.Request, data interface{}) error
- func CommonOptions(req *restful.Request) []client.Option
- func Created(resp *restful.Response, data interface{})
- func Forbidden(resp *restful.Response, data interface{})
- func IsNotFound(err error) bool
- func ListCommonQuery(rb *restful.RouteBuilder) *restful.RouteBuilder
- func NoContent(resp *restful.Response, data interface{})
- func NotFound(resp *restful.Response, data interface{})
- func NotFoundOrBadRequest(resp *restful.Response, err error)
- func OK(resp *restful.Response, data interface{})
- func OrderOption(req *restful.Request) []client.Option
- func PageSizeOption(req *restful.Request) client.Option
- func ParseError(err error) interface{}
- func PreloadOption(req *restful.Request) client.Option
- func ScopeBelongM2M(ownerModel, selfModel, viaModel interface{}, cond *Cond, ...) func(tx *gorm.DB) *gorm.DB
- func ScopeBelongViaField(model, selfmodel interface{}, cond *Cond, relfield string) func(tx *gorm.DB) *gorm.DB
- func ScopeCondition(conds []*Cond, model interface{}) func(tx *gorm.DB) *gorm.DB
- func ScopeFields(model interface{}, fields []string) func(tx *gorm.DB) *gorm.DB
- func ScopeOmitAssociations(tx *gorm.DB) *gorm.DB
- func ScopeOrder(req *restful.Request, valid []string) func(tx *gorm.DB) *gorm.DB
- func ScopePageSize(req *restful.Request) func(tx *gorm.DB) *gorm.DB
- func ScopePreload(req *restful.Request, validPreloads []string) func(tx *gorm.DB) *gorm.DB
- func ScopeSearch(req *restful.Request, model interface{}, fields []string) func(tx *gorm.DB) *gorm.DB
- func ScopeTable(model interface{}) func(tx *gorm.DB) *gorm.DB
- func SearchOption(req *restful.Request) client.Option
- func ServiceUnavailable(resp *restful.Response, err error)
- func Unauthorized(resp *restful.Response, data interface{})
- func WhereOptions(req *restful.Request, queryWhiteList []string) []client.Option
- type Cond
- type ConditionOperator
- type ListBase
- type PageData
- type PageFilterFunc
- type PageSortFunc
- type RelationCondition
- type RespBase
- type Response
Constants ¶
View Source
const ( MessageOK = "ok" MessageNotFound = "not found" MessageError = "err" MessageForbidden = "forbidden" )
View Source
const ( ASC = "ASC" DESC = "DESC" )
Variables ¶
View Source
var ( NoopPageFilterFunc = func(i int) bool { return true } NoopPageSortFunc = func(i, j int) bool { return false } )
View Source
var ( QueryPageNum = restful.QueryParameter("page", "page number") QueryPageSize = restful.QueryParameter("size", "page size") QuerySearch = restful.QueryParameter("search", "search condition") QueryOrder = restful.QueryParameter("order", "order") )
View Source
var NewPageFromContext = pagination.NewPageDataFromContext
Functions ¶
func BadRequest ¶
func CommonOptions ¶
func IsNotFound ¶
func ListCommonQuery ¶
func ListCommonQuery(rb *restful.RouteBuilder) *restful.RouteBuilder
func NotFoundOrBadRequest ¶
func OrderOption ¶
TODO: handler order priority, "order by id, age" vs "order by age, id"
func PageSizeOption ¶
func ParseError ¶
func ParseError(err error) interface{}
func PreloadOption ¶
func ScopeBelongM2M ¶
func ScopeBelongViaField ¶
func ScopeCondition ¶
func ScopePreload ¶
func ScopeSearch ¶
func SearchOption ¶
func ServiceUnavailable ¶
func Unauthorized ¶
func WhereOptions ¶
Types ¶
type Cond ¶
type Cond struct { Field string Op ConditionOperator Value interface{} }
func Where ¶
func Where(field string, op ConditionOperator, value interface{}) *Cond
func WhereEqual ¶
func WhereNameEqual ¶
func WhereNameEqual(value interface{}) *Cond
type ConditionOperator ¶
type ConditionOperator string
var Eq, Gt, Lt, Neq, Gte, Lte, In, Like ConditionOperator = "=", ">", "<", "<>", ">=", "<=", "in", "like"
type PageData ¶
type PageData struct { Total int64 `json:"total"` List interface{} `json:"list"` CurrentPage int `json:"page"` CurrentSize int `json:"size"` }
func NewPageData ¶
func NewPageData(list interface{}, page, size int, filterfn PageFilterFunc, sortfn PageSortFunc) PageData
func NewPageDataFromContext ¶
func NewPageDataFromContext(req *restful.Request, fulllist interface{}, pick PageFilterFunc, sortfn PageSortFunc) PageData
type PageFilterFunc ¶
type PageSortFunc ¶
type RelationCondition ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.