Help us shape the future of Go! Take the 2026 Go Developer Survey

models

package
v2.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PostLog

type PostLog struct {
	//ID            bson.ObjectId     `bson:"_id"`
	Time          string            `json:"time" bson:"time"`
	RequestId     string            `json:"requestId" bson:"requestId"`
	ResponseTime  string            `json:"responseTime" bson:"responseTime"`
	TTL           int               `json:"ttl" bson:"ttl"`
	AppName       string            `json:"appName" bson:"appName"`
	Apiname       string            `json:"apiName" bson:"apiName"`
	Method        string            `json:"method" bson:"method"`
	ContentType   string            `json:"contentType" bson:"contentType"`
	Uri           string            `json:"uri" bson:"uri"`
	ClientIP      string            `json:"clientIP" bson:"clientIP"`
	RequestHeader map[string]string `json:"requestHeader" bson:"requestHeader"`
	RequestParam  any               `json:"requestParam" bson:"requestParam"`
	RequestBody   any               `json:"requestBody" bson:"requestBody"`
	ResponseStr   string            `json:"responseStr" bson:"responseStr"`
	ResponseMap   any               `json:"responseMap" bson:"responseMap"`
}

type Result

type Result[T any] struct {
	Status int         `json:"status" bson:"status"`
	Msg    string      `json:"msg" bson:"msg"`
	Data   T           `json:"data,omitempty" bson:"data,omitempty"`
	Page   *ResultPage `json:"page,omitempty" bson:"page,omitempty"`
}

* 通用返回结果类

func Error

func Error(s int, m string) Result[any]

func ErrorT

func ErrorT[T any](s int, m string) Result[T]

func Success

func Success[T any](data T) Result[T]

func SuccessPage

func SuccessPage[T any](data T, page *ResultPage) Result[T]

func SuccessWithMsg

func SuccessWithMsg[T any](msg string, data T) Result[T]

func SuccessWithPage

func SuccessWithPage[T any](data T, count, index, size, total int) Result[T]

func ToAny

func ToAny[T any](result Result[any]) Result[T]

从any转指定泛型,必须明确Data的类型一致,否则断言可能panic

func (Result[T]) ToAny

func (r Result[T]) ToAny() Result[any]

从泛型转any

type ResultPage

type ResultPage struct {
	Count int `json:"count"` //总页数
	Index int `json:"index"` //页号
	Size  int `json:"size"`  //分页大小
	Total int `json:"total"` //总记录数
}

type Timestamp

type Timestamp time.Time

func NewTimestamp

func NewTimestamp(t time.Time) Timestamp

func (Timestamp) MarshalJSON

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

MarshalJSON implements json.Marshaler.

func (*Timestamp) Scan

func (t *Timestamp) Scan(v any) error

func (Timestamp) Time

func (t Timestamp) Time() time.Time

func (*Timestamp) UnmarshalJSON

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

func (Timestamp) Value

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

Directories

Path Synopsis
sys
vo

Jump to

Keyboard shortcuts

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