Documentation
¶
Index ¶
- Variables
- func InitErrorCodeMsg(e ErrorCode, msg string)
- func Pagination(page int, perPage int) func(db *gorm.DB) *gorm.DB
- type AbstractAdapter
- type AbstractDataObject
- type AbstractPageQuery
- type AbstractRepository
- func (d *AbstractRepository[D]) Create(do *D) int64
- func (d *AbstractRepository[D]) DB(do D) *gorm.DB
- func (d *AbstractRepository[D]) Delete(ids []int) int64
- func (d *AbstractRepository[D]) Error() error
- func (d *AbstractRepository[D]) Find(id int) *D
- func (d *AbstractRepository[D]) First(where [][]string, columns []string) *D
- func (d *AbstractRepository[D]) Get(where [][]string, columns []string, limit int) *[]D
- func (d *AbstractRepository[D]) Last(where [][]string, columns []string) *D
- func (d *AbstractRepository[D]) Paginate(pageQry *AbstractPageQuery) *PageVO[D]
- func (d *AbstractRepository[D]) Update(id int, do *D) int64
- type AbstractViewObject
- type App
- type BoolVO
- type CmdRepo
- type CmdRepository
- type DataObject
- type DateTime
- func (t *DateTime) MarshalJSON() ([]byte, error)
- func (t *DateTime) Scan(_ context.Context, _ *schema.Field, _ reflect.Value, fieldValue interface{}) error
- func (t *DateTime) UnmarshalJSON(data []byte) error
- func (t *DateTime) Value(_ context.Context, _ *schema.Field, dst reflect.Value, fieldValue interface{}) (interface{}, error)
- type EmptyVO
- type Entity
- type Error
- type ErrorCode
- type Http
- type IdVO
- type PageVO
- type QryRepo
- type QryRepository
- type Repository
- type Response
- type Server
- type StopError
- type VO
- type ViewObject
- type ViewObjectTemplate
- type Zero
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // IsAlwaysHttpCodeOk 是否httpCode总为200 IsAlwaysHttpCodeOk bool // ErrNone 成功 ErrNone ErrorCode = 200 // ErrTimeout 请求超时 ErrTimeout ErrorCode = 400408 // ErrTokenInvalid token失效 ErrTokenInvalid ErrorCode = 401000 // ErrAuthLoginFailed 用户或密码错误 ErrAuthLoginFailed ErrorCode = 401100 // ErrAuthTokenInvalid 非法token ErrAuthTokenInvalid ErrorCode = 401200 // ErrAuthSessionExpired token过期 ErrAuthSessionExpired ErrorCode = 401300 ErrAuthUnauthorized ErrorCode = 401400 // ErrAuthFailed 认证失败 ErrAuthFailed ErrorCode = 401500 // ErrAccessDenied 没有权限 ErrAccessDenied ErrorCode = 403100 // ErrAccessRefuse 拒绝客户端请求 ErrAccessRefuse ErrorCode = 403200 // ErrNoRepetitionOperation 禁止重复操作 ErrNoRepetitionOperation ErrorCode = 403400 // ErrBadRequest 客户端错误 ErrBadRequest ErrorCode = 400100 // ErrUriNotFound 资源未找到 ErrUriNotFound ErrorCode = 404100 // ErrInvalidParams 非法的参数 ErrInvalidParams ErrorCode = 422100 // ErrServerError 服务器异常 ErrServerError ErrorCode = 500100 )
Functions ¶
func InitErrorCodeMsg ¶ added in v0.1.26
Types ¶
type AbstractAdapter ¶
type AbstractAdapter struct { }
func (AbstractAdapter) Response ¶
func (a AbstractAdapter) Response(ctx *app.RequestContext, vo interface{})
type AbstractDataObject ¶
type AbstractDataObject struct { DataObject `gorm:"-:all" json:"-"` ID uint `gorm:"primarykey" json:"id"` CreatedAt DateTime `json:"createdAt"` UpdatedAt DateTime `json:"updatedAt"` DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt"` }
func (AbstractDataObject) PrimaryKey ¶
func (do AbstractDataObject) PrimaryKey() string
func (AbstractDataObject) PrimaryValue ¶
func (do AbstractDataObject) PrimaryValue() uint
type AbstractPageQuery ¶
type AbstractRepository ¶
type AbstractRepository[D DataObject] struct { Conf *config.Conf Err error }
func (*AbstractRepository[D]) Create ¶
func (d *AbstractRepository[D]) Create(do *D) int64
func (*AbstractRepository[D]) DB ¶
func (d *AbstractRepository[D]) DB(do D) *gorm.DB
func (*AbstractRepository[D]) Delete ¶
func (d *AbstractRepository[D]) Delete(ids []int) int64
func (*AbstractRepository[D]) Error ¶
func (d *AbstractRepository[D]) Error() error
func (*AbstractRepository[D]) Find ¶
func (d *AbstractRepository[D]) Find(id int) *D
func (*AbstractRepository[D]) First ¶
func (d *AbstractRepository[D]) First(where [][]string, columns []string) *D
func (*AbstractRepository[D]) Get ¶
func (d *AbstractRepository[D]) Get(where [][]string, columns []string, limit int) *[]D
func (*AbstractRepository[D]) Last ¶
func (d *AbstractRepository[D]) Last(where [][]string, columns []string) *D
func (*AbstractRepository[D]) Paginate ¶
func (d *AbstractRepository[D]) Paginate(pageQry *AbstractPageQuery) *PageVO[D]
Paginate 分页
func (*AbstractRepository[D]) Update ¶
func (d *AbstractRepository[D]) Update(id int, do *D) int64
type AbstractViewObject ¶
type AbstractViewObject struct {
ViewObject `json:"-"`
}
type BoolVO ¶
type BoolVO struct { AbstractViewObject Result bool `json:"result"` }
type CmdRepo ¶
type CmdRepo[D DataObject, E Entity] struct { AbstractRepository[D] }
type CmdRepository ¶
type DataObject ¶
type DateTime ¶
func (*DateTime) MarshalJSON ¶
func (*DateTime) UnmarshalJSON ¶
type EmptyVO ¶
type EmptyVO struct {
AbstractViewObject
}
type Error ¶
type Error interface { Code() ErrorCode HttpCode() int Msg() string WithMsg(string) Error SetTemplate(name string, value string) Error Error() string }
Error 普通错误
type Http ¶
func NewDefaultHttp ¶ added in v0.1.18
type IdVO ¶
type IdVO struct { AbstractViewObject ID int `json:"id"` }
type QryRepo ¶
type QryRepo[D DataObject] struct { AbstractRepository[D] }
func (QryRepo[D]) ListByPage ¶
func (q QryRepo[D]) ListByPage(pageQry *AbstractPageQuery) *PageVO[D]
type QryRepository ¶
type QryRepository[D DataObject] interface { Repository[D] ListByPage(id []int) }
type Repository ¶
type Repository[D DataObject] interface { Error() error DB(do D) *gorm.DB Find(id int) *D First(where [][]string, columns []string) *D Last(where [][]string, columns []string) *D Get(where [][]string, columns []string, limit int) *[]D Paginate(where [][]string, columns []string, orderByRaw string, page int, pageSize int) *PageVO[D] Create(do *D) int64 Update(id int, do *D) int64 Delete(ids []int) int64 // contains filtered or unexported methods }
type Response ¶
type Response interface { // Success 成功响应 Success(data interface{}) // Failure 错误响应-默认错误信息 Failure(code ErrorCode) // FailureMsg 错误响应-自定义错误信息 FailureMsg(code ErrorCode, msg string) // FailureError 错误响应-根据Error FailureError(err error) }
Response 统一响应格式
func NewResponse ¶
func NewResponse(ctx *app.RequestContext) Response
type VO ¶
func NewConvertorVO ¶ added in v0.1.35
func NewLowerCamelVO ¶ added in v0.1.35
func NewSnakeVO ¶ added in v0.1.35
type ViewObject ¶
type ViewObject interface { }
type ViewObjectTemplate ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.