util

package
v3.0.27 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterDateTimeRange added in v3.0.21

func FilterDateTimeRange(condition *QueryDateTimeCondition) func(in *gorm.DB) *gorm.DB

func GetLimit added in v3.0.1

func GetLimit(data map[string]interface{}) (map[string]interface{}, int, int)

func Pagination

func Pagination(data map[string]interface{}) func(in *gorm.DB) *gorm.DB

func TotalSize

func TotalSize(in *gorm.DB) (total int64)

Types

type DateTimeCondition added in v3.0.21

type DateTimeCondition struct {
	Operator string `json:"operator"`
	Number   string `json:"number"`
}

func NewCondition added in v3.0.21

func NewCondition(str string) *DateTimeCondition

type HttpTester

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

func (*HttpTester) DELETE

func (h *HttpTester) DELETE(uri string, param interface{}) (int, *response.Response)

DELETE 模擬 Delete Request的動作

func (*HttpTester) GET

func (h *HttpTester) GET(uri string) (int, *response.Response)

Get 模擬Get Request的動作

func (*HttpTester) PATCH

func (h *HttpTester) PATCH(uri string, param interface{}) (int, *response.Response)

PATCH 模擬 Patch Request的動作

func (*HttpTester) POST

func (h *HttpTester) POST(uri string, param interface{}) (int, *response.Response)

POST 模擬Post Request的動作

func (*HttpTester) POST_FORM

func (h *HttpTester) POST_FORM(uri string, param interface{}) (int, *response.Response)

POST_FORM 模擬Post Request的動作

func (*HttpTester) PUT

func (h *HttpTester) PUT(uri string, param interface{}) (int, *response.Response)

PUT 模擬Post Request的動作

type HttpTesterInterface

type HttpTesterInterface interface {
	GET(uri string) (int, *response.Response)
	POST(uri string, param interface{}) (int, *response.Response)
	POST_FORM(uri string, param interface{}) (int, *response.Response)
	PUT(uri string, param interface{}) (int, *response.Response)
	PATCH(uri string, param interface{}) (int, *response.Response)
	DELETE(uri string, param interface{}) (int, *response.Response)
}

func NewHttpTester

func NewHttpTester(router *gin.Engine) HttpTesterInterface

type Operator added in v3.0.21

type Operator string
const (
	Less        Operator = "lt"
	LessThan    Operator = "lta"
	Equal       Operator = "eq"
	Greater     Operator = "gt"
	GreaterThan Operator = "gta"
)

func (Operator) Get added in v3.0.23

func (o Operator) Get() string

type PaginationData

type PaginationData struct {
	Total int         `json:"total"`
	Data  interface{} `json:"data"`
}

func NewPaginationData

func NewPaginationData(total int, data interface{}) *PaginationData

type QueryDateTimeCondition added in v3.0.21

type QueryDateTimeCondition struct {
	Column string             `json:"column"`
	Unit   string             `json:"unit"`
	Year   *DateTimeCondition `json:"year"`
	Month  *DateTimeCondition `json:"month"`
	Date   *DateTimeCondition `json:"date"`
}

type RequestHandler

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

func (*RequestHandler) BindBody

func (r *RequestHandler) BindBody(c *gin.Context, body interface{}) (int, *response.Response)

BindBody : 綁定 body

func (*RequestHandler) ValidValidation

func (r *RequestHandler) ValidValidation(c *gin.Context, v *validation.Validation) (int, *response.Response)

ValidValidation : 驗證表單資訊

type RequestHandlerInterface

type RequestHandlerInterface interface {
	//BindBody : 綁定 body
	BindBody(c *gin.Context, body interface{}) (int, *response.Response)
	//ValidValidation : 驗證表單資訊
	ValidValidation(c *gin.Context, v *validation.Validation) (int, *response.Response)
}

func NewRequestHandler

func NewRequestHandler() RequestHandlerInterface

type Requester

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

func (*Requester) DELETE

func (r *Requester) DELETE(uri string, param interface{}) (*response.Response, error)

func (*Requester) DeleteWithHeader

func (r *Requester) DeleteWithHeader(uri string, header map[string]string, param interface{}) (*response.Response, error)

func (*Requester) GET

func (r *Requester) GET(uri string) (*response.Response, error)

func (*Requester) GetWithHeader

func (r *Requester) GetWithHeader(uri string, header map[string]string) (*response.Response, error)

func (*Requester) PATCH

func (r *Requester) PATCH(uri string, param interface{}) (*response.Response, error)

func (*Requester) POST

func (r *Requester) POST(uri string, param interface{}) (*response.Response, error)

func (*Requester) PUT

func (r *Requester) PUT(uri string, param interface{}) (*response.Response, error)

func (*Requester) PatchWithHeader

func (r *Requester) PatchWithHeader(uri string, header map[string]string, param interface{}) (*response.Response, error)

func (*Requester) PostWithHeader

func (r *Requester) PostWithHeader(uri string, header map[string]string, param interface{}) (*response.Response, error)

func (*Requester) PutWithHeader

func (r *Requester) PutWithHeader(uri string, header map[string]string, param interface{}) (*response.Response, error)

func (*Requester) ReadJSONResponse

func (r *Requester) ReadJSONResponse(in *http.Response) (*response.Response, error)

type RequesterInterface

type RequesterInterface interface {
	GET(uri string) (*response.Response, error)
	POST(uri string, param interface{}) (*response.Response, error)
	PUT(uri string, param interface{}) (*response.Response, error)
	PATCH(uri string, param interface{}) (*response.Response, error)
	DELETE(uri string, param interface{}) (*response.Response, error)
	GetWithHeader(uri string, header map[string]string) (*response.Response, error)
	PostWithHeader(uri string, header map[string]string, param interface{}) (*response.Response, error)
	PutWithHeader(uri string, header map[string]string, param interface{}) (*response.Response, error)
	PatchWithHeader(uri string, header map[string]string, param interface{}) (*response.Response, error)
	DeleteWithHeader(uri string, header map[string]string, param interface{}) (*response.Response, error)
}

func NewRequester

func NewRequester(client *http.Client) RequesterInterface

Jump to

Keyboard shortcuts

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