std

package module
v0.0.0-...-d9300bc Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 1 Imported by: 1

README

std

standard API error, output and input parameters

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OrderBySep = " "
View Source
var OrderBysSep = ","

Functions

This section is empty.

Types

type Error

type Error struct {
	Message     string
	Key         string
	Args        []interface{}
	Err         error
	FieldErrors []FieldError
	ErrorCode   string
	HttpStatus  int
}

func Err

func Err(msg string) *Error

func NewError

func NewError(msg, key string, args ...interface{}) *Error

func WrapError

func WrapError(err error, key string, args ...interface{}) *Error

func (*Error) AddField

func (s *Error) AddField(field, message string) *Error

func (*Error) AddFieldError

func (s *Error) AddFieldError(field, message, key string, params ...interface{}) *Error

func (*Error) Error

func (s *Error) Error() string

func (*Error) I18n

func (s *Error) I18n(key string, args ...interface{}) *Error

func (*Error) SetError

func (s *Error) SetError(err error) *Error

func (*Error) SetErrorCode

func (s *Error) SetErrorCode(code string) *Error

func (*Error) SetHttpStatus

func (s *Error) SetHttpStatus(status int) *Error

func (*Error) ToResult

func (s *Error) ToResult(translator func(key string, params ...interface{}) string) Result

type FieldError

type FieldError struct {
	Field   string
	Message string
	Key     string
	Params  []interface{}
}

type OrderBy

type OrderBy struct {
	Field string
	Asc   bool
}

func ParseOrderBy

func ParseOrderBy(str string) OrderBy

func (OrderBy) String

func (s OrderBy) String() string

type OrderBys

type OrderBys []OrderBy

func ParseOrderBys

func ParseOrderBys(orderByStr string) OrderBys

func (OrderBys) AddPrefix

func (s OrderBys) AddPrefix(prefixes map[string]string) OrderBys

func (OrderBys) Pick

func (s OrderBys) Pick(fields ...string) OrderBys

func (OrderBys) String

func (s OrderBys) String() string

type PageData

type PageData struct {
	Items      interface{} `json:"items"`
	TotalCount int         `json:"totalCount"`
	PageSize   int         `json:"pageSize"`
	PageIndex  int         `json:"pageIndex"`
	TotalPages int         `json:"totalPages"`
}

func NewPageData

func NewPageData(items interface{}, totalCount, pageSize, pageIndex int) PageData

type Result

type Result struct {
	State       int               `json:"state"`
	Data        interface{}       `json:"data,omitempty"`
	Error       string            `json:"error,omitempty"`
	FieldErrors map[string]string `json:"fieldErrors,omitempty"`
	ErrorCode   string            `json:"errorCode,omitempty"`
}

standard result to restful API

Jump to

Keyboard shortcuts

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