model

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ResponseOK        = BaseResponse(200, "ok")         // 通用成功
	ResponseErr       = BaseResponse(500, "err")        // 通用错误
	ResponseNeedLogin = BaseResponse(401, "need login") // 没有权限
)
View Source
var DateLayoutShort string = "20060102"
View Source
var TimeLayout string = "2006-01-02 15:04:05"
View Source
var TimeLayoutShort string = "2006-01-02"

Functions

This section is empty.

Types

type DateTime added in v1.3.1

type DateTime time.Time

func (DateTime) MarshalJSON added in v1.3.1

func (t DateTime) MarshalJSON() ([]byte, error)

func (*DateTime) Scan added in v1.3.1

func (t *DateTime) Scan(v interface{}) error

func (DateTime) String added in v1.3.1

func (t DateTime) String() string

func (DateTime) Time added in v1.3.2

func (t DateTime) Time() time.Time

func (*DateTime) UnmarshalJSON added in v1.3.1

func (t *DateTime) UnmarshalJSON(data []byte) (err error)

func (DateTime) Value added in v1.3.1

func (t DateTime) Value() (driver.Value, error)

type PageResponseModel added in v1.4.1

type PageResponseModel[T any] struct {
	Page     int   `json:"page"`
	PageSize int   `json:"pageSize"`
	List     []T   `json:"list"`
	Total    int64 `json:"total"`
}

type ResponseModel

type ResponseModel[T any] struct {
	Code       int    `json:"code"`
	Msg        string `json:"msg"`
	Data       T      `json:"data"`
	ServerTime int64  `json:"serverTime"`
}

func BaseResponse

func BaseResponse(code int, msg string) *ResponseModel[interface{}]

func (*ResponseModel[T]) WithData

func (res *ResponseModel[T]) WithData(data T) ResponseModel[T]

追加响应数据

func (*ResponseModel[T]) WithMsg

func (res *ResponseModel[T]) WithMsg(message string) ResponseModel[T]

Jump to

Keyboard shortcuts

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