util

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ERRMSG = "errMsg"
	//參數錯誤
	PARAM  = "parameter"
	FORMAT = "format"
	INT    = "int"
)

-------------------------------// error type

View Source
const (
	REASON  = "reason"
	SUCCESS = "success"
	FAILED  = "failed"
)

成功與否

View Source
const (
	COMMA  = "comma"
	PERIOD = "period"
	SPACE  = " "
)

標點符號

View Source
const (
	CREATE = "create"
	UPDATE = "update"
	MODIFY = "modify"
	GET    = "get"
	DELETE = "delete"
	APPEND = "append"
	REMOVE = "remove"
)

CRUD 方法

View Source
const (
	MODULE = "module"
)

模組

Variables

This section is empty.

Functions

func GetI18nData added in v1.0.2

func GetI18nData(c *gin.Context) gogo_i18n.GoGoi18nInterface

func LoadI18nDataFromDatabase added in v1.0.6

func LoadI18nDataFromDatabase(db *gorm.DB, storeType string, storePath string)

Types

type HttpTester added in v1.0.5

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

func (*HttpTester) DELETE added in v1.0.5

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

DELETE 模擬 Delete Request的動作

func (*HttpTester) GET added in v1.0.5

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

Get 模擬Get Request的動作

func (*HttpTester) PATCH added in v1.0.5

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

PATCH 模擬 Patch Request的動作

func (*HttpTester) POST added in v1.0.5

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

POST 模擬Post Request的動作

func (*HttpTester) POST_FORM added in v1.0.7

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

POST_FORM 模擬Post Request的動作

func (*HttpTester) PUT added in v1.0.5

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

PUT 模擬Post Request的動作

type HttpTesterInterface added in v1.0.5

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

func NewHttpTester added in v1.0.5

func NewHttpTester(router *gin.Engine) HttpTesterInterface

type I18nMsg added in v1.0.7

type I18nMsg struct {
	Module string
	Core   gogo_i18n.GoGoi18nInterface
}

func (*I18nMsg) Append added in v1.0.7

func (i *I18nMsg) Append(isSuccess bool, module string, data map[string]interface{}) string

func (*I18nMsg) Create added in v1.0.7

func (i *I18nMsg) Create(isSuccess bool, data map[string]interface{}) string

func (*I18nMsg) Delete added in v1.0.7

func (i *I18nMsg) Delete(isSuccess bool, data map[string]interface{}) string

func (*I18nMsg) Get added in v1.0.7

func (i *I18nMsg) Get(isSuccess bool, data map[string]interface{}) string

func (*I18nMsg) GetModule added in v1.0.7

func (i *I18nMsg) GetModule(name string) string

func (*I18nMsg) Modify added in v1.0.7

func (i *I18nMsg) Modify(isSuccess bool, data map[string]interface{}) string

func (*I18nMsg) ParamFormatError added in v1.0.7

func (i *I18nMsg) ParamFormatError(data map[string]interface{}) string

func (*I18nMsg) ParamIntError added in v1.0.7

func (i *I18nMsg) ParamIntError(data map[string]interface{}) string

func (*I18nMsg) ParamRequiredError added in v1.0.7

func (i *I18nMsg) ParamRequiredError(data map[string]interface{}) string

func (*I18nMsg) Remove added in v1.0.7

func (i *I18nMsg) Remove(isSuccess bool, module string, data map[string]interface{}) string

func (*I18nMsg) SetCore added in v1.0.7

func (i *I18nMsg) SetCore(data gogo_i18n.GoGoi18nInterface)

func (*I18nMsg) SetModule added in v1.0.7

func (i *I18nMsg) SetModule(module string) *I18nMsg

func (*I18nMsg) Update added in v1.0.7

func (i *I18nMsg) Update(isSuccess bool, data map[string]interface{}) string

type I18nMsgContent added in v1.0.7

type I18nMsgContent struct {
	Data  string `json:"data"`
	Error string `json:"error"`
}

type I18nMsgInterface added in v1.0.7

type I18nMsgInterface interface {
	//基本方法
	SetCore(data gogo_i18n.GoGoi18nInterface)
	SetModule(module string) *I18nMsg
	//error handler
	ParamFormatError(data map[string]interface{}) string
	ParamIntError(data map[string]interface{}) string
	ParamRequiredError(data map[string]interface{}) string
	//取得模組
	GetModule(name string) string
	//http方法
	Get(isSuccess bool, data map[string]interface{}) string
	Create(isSuccess bool, data map[string]interface{}) string
	Update(isSuccess bool, data map[string]interface{}) string
	Modify(isSuccess bool, data map[string]interface{}) string
	Delete(isSuccess bool, data map[string]interface{}) string
	Append(isSuccess bool, module string, data map[string]interface{}) string
	Remove(isSuccess bool, module string, data map[string]interface{}) string
}

func NewI18nMsg added in v1.0.7

func NewI18nMsg(module string) I18nMsgInterface

type RequestHandler

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

func (*RequestHandler) BindBody

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

BindBody : 綁定 body

func (*RequestHandler) ValidValidation

func (r *RequestHandler) ValidValidation(v *validation.Validation) error

ValidValidation : 驗證表單資訊

type RequestHandlerInterface

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

func NewRequestHandler

func NewRequestHandler() RequestHandlerInterface

type Requester added in v1.0.9

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

func (*Requester) DELETE added in v1.0.9

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

func (*Requester) DeleteWithHeader added in v1.0.18

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

func (*Requester) GET added in v1.0.9

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

func (*Requester) GetWithHeader added in v1.0.18

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

func (*Requester) PATCH added in v1.0.9

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

func (*Requester) POST added in v1.0.9

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

func (*Requester) PUT added in v1.0.9

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

func (*Requester) PatchWithHeader added in v1.0.18

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

func (*Requester) PostWithHeader added in v1.0.18

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

func (*Requester) PutWithHeader added in v1.0.18

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

func (*Requester) ReadJSONResponse added in v1.0.10

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

type RequesterInterface added in v1.0.9

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

func NewRequester added in v1.0.9

func NewRequester(client *http.Client) RequesterInterface

Jump to

Keyboard shortcuts

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