res

package
v0.0.0-...-47b8d5d Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseResponse

type BaseResponse struct {
	// Uid 唯一ID
	Uid string `json:"uid"`
	// HTTP状态码
	Status int `json:"-"`
}

BaseResponse 基础响应

func (*BaseResponse) GetHttpStatus

func (_self *BaseResponse) GetHttpStatus() int

func (*BaseResponse) GetStatus

func (_self *BaseResponse) GetStatus() int

func (*BaseResponse) GetUid

func (_self *BaseResponse) GetUid() string

func (*BaseResponse) SetStatus

func (_self *BaseResponse) SetStatus(status int)

func (*BaseResponse) SetUid

func (_self *BaseResponse) SetUid(uid string)

type Brief

type Brief struct {
	// Success 是否成功
	Success bool `json:"success"`
	// 状态码
	Code int `json:"code"`
	// Msg 异常信息
	Msg string `json:"msg"`
	// Timestamp 时间戳
	Timestamp string `json:"timestamp"`
	// GmtCreate 时间字符串
	GmtCreate string `json:"gmtCreate"`
}

Brief 异常简要信息类

func (*Brief) GetCode

func (_self *Brief) GetCode() int

func (*Brief) GetMsg

func (_self *Brief) GetMsg() string

func (*Brief) SetCode

func (_self *Brief) SetCode(code int)

func (*Brief) SetMsg

func (_self *Brief) SetMsg(msg string)

func (*Brief) Verify

func (_self *Brief) Verify()

Verify 检验是否成功

type DRKey

type DRKey interface {
	~string | ~int | ~uint | ~int8 | ~uint8 | ~int16 | ~uint16 | ~int32 | ~uint32 | ~int64 | ~uint64
}

DRKey Data Result Key类型

type Data

type Data[T any] interface {

	// GetData 获取数据
	GetData() T

	// SetData 设置数据
	//
	// @param data 数据
	SetData(data T)
}

Data 数据模型接口

type Error

type Error interface {

	// GetCode 获取状态码
	GetCode() int

	// SetCode 设置状态码
	//
	// @param code 状态码
	SetCode(code int)

	// GetMsg 获取异常信息
	GetMsg() string

	// SetMsg 设置异常信息
	//
	// @param msg 异常信息
	SetMsg(msg string)
}

Error Error接口

type MapResult

type MapResult[K DRKey, V any] interface {

	// Get 根据key获取值
	//
	// @param key 键
	Get(key K) V

	// Put 添加值
	//
	// @param key 键
	//
	// @param value 值
	Put(key K, value V)

	// PutIfAbsent 添加值
	//
	// @param key 键
	//
	// @param value 值
	PutIfAbsent(key K, value V)

	// PutAll 添加多个值
	//
	// @param data map值
	PutAll(data map[K]V)

	// PutAllIfAbsent 添加多个值
	//
	// @param data map值
	PutAllIfAbsent(data map[K]V)

	// Remove 根据指定键移除值
	//
	// @param key 键
	Remove(key K)

	// Clear 清空数据
	Clear()

	// ContainsKey 检查是否包含指定的键
	//
	// @param key 键
	ContainsKey(key K) bool

	// ContainsValue 检查是否包含指定的值
	//
	// @param value 值
	ContainsValue(value V) bool

	// GetSize 获取元素个数
	GetSize() int

	// IsEmpty 检查是否存在数据
	IsEmpty() bool
}

MapResult 数据结果集

type MultipleResult

type MultipleResult[K DRKey, V any] struct {
	// BaseResponse 基础响应对象
	*BaseResponse
	// Brief 简要信息对象
	*Brief
	// Map数据
	Data map[K]V `json:"data"`
}

MultipleResult 多值结果集

func NewMultipleFailure

func NewMultipleFailure[K DRKey, V any](status int, code int, msg string) *MultipleResult[K, V]

NewMultipleFailure 创建实例

@param status HTTP状态码

@param code 状态码

@param msg 错误消息

func NewMultipleFailureWithEmpty

func NewMultipleFailureWithEmpty[K DRKey, V any]() *MultipleResult[K, V]

NewMultipleFailureWithEmpty 创建实例

func NewMultipleFailureWithMsg

func NewMultipleFailureWithMsg[K DRKey, V any](code int, msg string) *MultipleResult[K, V]

NewMultipleFailureWithMsg 创建实例

@param code 状态码

@param msg 错误信息

func NewMultipleWithEmpty

func NewMultipleWithEmpty[K DRKey, V any]() *MultipleResult[K, V]

NewMultipleWithEmpty 创建实例

func NewMultipleWithMany

func NewMultipleWithMany[K DRKey, V any](data map[K]V) *MultipleResult[K, V]

NewMultipleWithMany 创建实例

@param data 多个值

func NewMultipleWithOne

func NewMultipleWithOne[K DRKey, V any](key K, value V) *MultipleResult[K, V]

NewMultipleWithOne 创建实例

@param key 键

@param value 值

func NewMultipleWithSize

func NewMultipleWithSize[K DRKey, V any](size int) *MultipleResult[K, V]

NewMultipleWithSize 创建实例

@param size 容量大小

func (*MultipleResult[K, V]) Clear

func (_self *MultipleResult[K, V]) Clear()

func (*MultipleResult[K, V]) ContainsKey

func (_self *MultipleResult[K, V]) ContainsKey(key K) bool

func (*MultipleResult[K, V]) ContainsValue

func (_self *MultipleResult[K, V]) ContainsValue(value V) bool

func (*MultipleResult[K, V]) Get

func (_self *MultipleResult[K, V]) Get(key K) V

func (*MultipleResult[K, V]) GetData

func (_self *MultipleResult[K, V]) GetData() map[K]V

func (*MultipleResult[K, V]) GetSize

func (_self *MultipleResult[K, V]) GetSize() int

func (*MultipleResult[K, V]) IsEmpty

func (_self *MultipleResult[K, V]) IsEmpty() bool

func (*MultipleResult[K, V]) Put

func (_self *MultipleResult[K, V]) Put(key K, value V)

func (*MultipleResult[K, V]) PutAll

func (_self *MultipleResult[K, V]) PutAll(data map[K]V)

func (*MultipleResult[K, V]) PutAllIfAbsent

func (_self *MultipleResult[K, V]) PutAllIfAbsent(data map[K]V)

func (*MultipleResult[K, V]) PutIfAbsent

func (_self *MultipleResult[K, V]) PutIfAbsent(key K, value V)

func (*MultipleResult[K, V]) Remove

func (_self *MultipleResult[K, V]) Remove(key K)

func (*MultipleResult[K, V]) SetData

func (_self *MultipleResult[K, V]) SetData(data map[K]V)

type PlainResult

type PlainResult[T any] struct {
	// BaseResponse 基础响应对象
	*BaseResponse
	// Brief 简要信息对象
	*Brief
	// Data 数据
	Data T `json:"data"`
}

PlainResult 单值结果集

func NewPlainFailure

func NewPlainFailure[T any](status int, code int, msg string) *PlainResult[T]

NewPlainFailure 创建实例

@param status HTTP状态值

@param code 状态码

@param msg 错误信息

func NewPlainFailureWithEmpty

func NewPlainFailureWithEmpty[T any]() *PlainResult[T]

NewPlainFailureWithEmpty 创建实例

func NewPlainFailureWithMsg

func NewPlainFailureWithMsg[T any](code int, msg string) *PlainResult[T]

NewPlainFailureWithMsg 创建实例

@param code 状态码

@param msg 错误信息

func NewPlainWithData

func NewPlainWithData[T any](data T) *PlainResult[T]

NewPlainWithData 创建实例

@param data 数据

func NewPlainWithEmpty

func NewPlainWithEmpty[T any]() *PlainResult[T]

NewPlainWithEmpty 创建实例

func (*PlainResult[T]) GetData

func (_self *PlainResult[T]) GetData() T

func (*PlainResult[T]) SetData

func (_self *PlainResult[T]) SetData(data T)

type Response

type Response interface {

	// GetUid 获取请求唯一ID
	GetUid() string

	// SetUid 设置唯一ID
	//
	// 唯一ID
	SetUid(uid string)

	// GetStatus 获取HTTP状态码
	GetStatus() int

	// SetStatus 设置HTTP状态码
	//
	// @param status HTTP状态码
	SetStatus(status int)

	// GetHttpStatus 获取Http状态码
	GetHttpStatus() int
}

Response 响应接口

type Result

type Result interface {
	Error
	Response
}

Result 结果集接口

Jump to

Keyboard shortcuts

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