types

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiVersion

type ApiVersion string

ApiVersion 版本号

func (ApiVersion) Verify

func (av ApiVersion) Verify() bool

type BodyProperty

type BodyProperty string

BodyProperty 响应正文属性

const (
	BodyPropertyRaw  BodyProperty = "raw"
	BodyPropertyText BodyProperty = "text"
	BodyPropertyHtml BodyProperty = "html"
	BodyPropertyFull BodyProperty = "full"
)

func (BodyProperty) Verify

func (bp BodyProperty) Verify() bool

type DayStatRequest added in v1.2.0

type DayStatRequest struct {
	SearchRequest

	StartDay string `form:"startDay" format:"2006-01-02"`
	EndDay   string `form:"endDay" format:"2006-01-02"`
}

DayStatRequest 通用日统计请求。都为空时,默认获取当周数据

func (DayStatRequest) StatAtRange added in v1.2.0

func (in DayStatRequest) StatAtRange() ([]time.Time, error)

func (DayStatRequest) StatAtRangeOrLastWeek added in v1.2.0

func (in DayStatRequest) StatAtRangeOrLastWeek() []time.Time

func (DayStatRequest) StatDayRange added in v1.2.0

func (in DayStatRequest) StatDayRange() ([]uint, error)

func (DayStatRequest) StatDayRangeOrLastWeek added in v1.2.0

func (in DayStatRequest) StatDayRangeOrLastWeek() []uint

type HttpContext

type HttpContext struct {
	// contains filtered or unexported fields
}

func MustParseHttpContext added in v1.2.0

func MustParseHttpContext(ctx context.Context) (*HttpContext, error)

MustParseHttpContext 从 gin 上下文中解析自定义上下文

func NewHttpContext

func NewHttpContext() *HttpContext

NewHttpContext 创建自定义上下文

func ParserHttpContext

func ParserHttpContext(ctx context.Context) (*HttpContext, error)

ParserHttpContext 从 gin 上下文中解析自定义上下文 Deprecated. use MustParseHttpContext

func (*HttpContext) Deadline

func (sc *HttpContext) Deadline() (deadline time.Time, ok bool)

func (*HttpContext) Done

func (sc *HttpContext) Done() <-chan struct{}

func (*HttpContext) Err

func (sc *HttpContext) Err() error

func (*HttpContext) GetUser added in v1.2.0

func (sc *HttpContext) GetUser() *User

func (*HttpContext) HasRole

func (sc *HttpContext) HasRole(roles []IRole) bool

HasRole 判断用户角色

func (*HttpContext) IsRole

func (sc *HttpContext) IsRole(role IRole) bool

IsRole 判断用户角色

func (*HttpContext) Logger

func (sc *HttpContext) Logger() xlog.XLogger

func (*HttpContext) Set

func (sc *HttpContext) Set(key string, value interface{})

Set 设置参数 会根据 value 的类型,自动设置对应属性的值,目前支持: ApiVersion, BodyProperty, types.User, xlog.XLogger

func (*HttpContext) StorageTo

func (sc *HttpContext) StorageTo(ctx *gin.Context) bool

StorageTo 将已变更的数据,存储到 gin 上下文中,继续传输

func (*HttpContext) TraceId

func (sc *HttpContext) TraceId() string

func (*HttpContext) User

func (sc *HttpContext) User() *User

func (*HttpContext) Value

func (sc *HttpContext) Value(key interface{}) interface{}

type IRole

type IRole interface {
	String() string
}

type ResponseModel added in v1.2.0

type ResponseModel struct {
	ID          uint   `json:"id" copy:"ID"`
	CreatedTime string `json:"createdTime" copy:"createdAt"`
	UpdatedTime string `json:"updatedTime" copy:"updatedAt"`
}

ResponseModel 通用响应基础模型

type SearchRequest

type SearchRequest struct {
	// 数据开始位置
	Start int64 `form:"start"`
	// 返回数据条数
	Limit int64 `form:"limit"`
	// 排序规则:sort=otc_type,-created_at,*custom
	// 以符号开头,可选符号:(+或空 正序)(- 倒序)(* 自定义复杂排序标识关键词)
	Sort string `form:"sort"`
}

SearchRequest 通用搜索请求

func (SearchRequest) GetLimit

func (sr SearchRequest) GetLimit() int64

GetLimit 获得分页数据条数

type ToRole

type ToRole func(role string) (IRole, error)

ToRole 转换成角色 IRole

type User

type User struct {
	ID      uint
	Account string
	Name    string
	Roles   []IRole

	IP     string            // 用户登录ID
	Extend map[string]string // 扩展信息
}

User 用户基本信息

func (*User) GetAccount added in v1.1.1

func (u *User) GetAccount() string

func (*User) GetExtend added in v1.1.1

func (u *User) GetExtend() map[string]string

func (*User) GetExtendValue added in v1.2.0

func (u *User) GetExtendValue(field string) string

func (*User) GetID added in v1.1.1

func (u *User) GetID() uint

func (*User) GetIP added in v1.1.1

func (u *User) GetIP() string

func (*User) GetName added in v1.1.1

func (u *User) GetName() string

func (*User) GetRoles added in v1.1.1

func (u *User) GetRoles() []IRole

func (*User) Is added in v1.2.0

func (u *User) Is(role IRole, others ...IRole) bool

Jump to

Keyboard shortcuts

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