Documentation ¶
Index ¶
- type ApiResponse
- func Error[TData any](statusMessage string, statusCode int) ApiResponse[TData]
- func Error403[TData any](statusMessage string) ApiResponse[TData]
- func NewApiResponseByByte[TData any](body []byte) ApiResponse[TData]
- func NewApiResponseByReader[TData any](reader io.Reader) ApiResponse[TData]
- func Success[TData any](statusMessage string, data TData) ApiResponse[TData]
- type ApiResponseInt
- type ApiResponseLong
- type ApiResponseString
- type ConsumerFunc
- type EventArgs
- type IEvent
- type IHealthCheck
- type ILock
- type ILog
- type IMapperInit
- type ITransaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApiResponse ¶
type ApiResponse[TData any] struct { // 操作是否成功 Status bool // 返回状态代码 StatusCode int // 返回消息内容 StatusMessage string // 接口返回时间 ServerAt dateTime.DateTime // 耗时 ElapsedMilliseconds int64 // 链路追踪ID TraceId int64 // 不同接口返回的值 Data TData }
ApiResponse 标准的API Response结构
func Error ¶
func Error[TData any](statusMessage string, statusCode int) ApiResponse[TData]
Error 接口调用失时返回的Json
func Error403 ¶
func Error403[TData any](statusMessage string) ApiResponse[TData]
Error403 接口调用失时返回的Json
func NewApiResponseByByte ¶ added in v0.6.0
func NewApiResponseByByte[TData any](body []byte) ApiResponse[TData]
NewApiResponseByByte 创建实例
func NewApiResponseByReader ¶ added in v0.6.0
func NewApiResponseByReader[TData any](reader io.Reader) ApiResponse[TData]
NewApiResponseByReader 创建实例
func Success ¶
func Success[TData any](statusMessage string, data TData) ApiResponse[TData]
Success 接口调用成功后返回的Json
func (*ApiResponse[TData]) SetData ¶
func (receiver *ApiResponse[TData]) SetData(data TData)
SetData 设置Data字段的值
func (*ApiResponse[TData]) ToBytes ¶
func (receiver *ApiResponse[TData]) ToBytes() []byte
ToBytes 转成Json字节
func (*ApiResponse[TData]) ToJson ¶
func (receiver *ApiResponse[TData]) ToJson() string
ToJson 转成Json
type ApiResponseInt ¶
type ApiResponseInt ApiResponse[int]
ApiResponseInt 标准的API Response结构(默认int值)
func ApiResponseIntError ¶
func ApiResponseIntError(statusMessage string, statusCode int) ApiResponseInt
ApiResponseIntError 接口调用失时返回的Json
func ApiResponseIntError403 ¶
func ApiResponseIntError403(statusMessage string) ApiResponseInt
ApiResponseIntError403 接口调用失时返回的Json
func ApiResponseIntSuccess ¶
func ApiResponseIntSuccess(statusMessage string, data int) ApiResponseInt
ApiResponseIntSuccess 接口调用成功后返回的Json
type ApiResponseLong ¶
type ApiResponseLong ApiResponse[int64]
ApiResponseLong 标准的API Response结构(默认int值)
func ApiResponseLongError ¶
func ApiResponseLongError(statusMessage string, statusCode int) ApiResponseLong
ApiResponseLongError 接口调用失时返回的Json
func ApiResponseLongError403 ¶
func ApiResponseLongError403(statusMessage string) ApiResponseLong
ApiResponseLongError403 接口调用失时返回的Json
func ApiResponseLongSuccess ¶
func ApiResponseLongSuccess(statusMessage string, data int64) ApiResponseLong
ApiResponseLongSuccess 接口调用成功后返回的Json
type ApiResponseString ¶
type ApiResponseString ApiResponse[string]
ApiResponseString 标准的API Response结构(默认string值)
func ApiResponseStringError ¶
func ApiResponseStringError(statusMessage string, statusCode int) ApiResponseString
ApiResponseStringError 接口调用失时返回的Json
func ApiResponseStringError403 ¶
func ApiResponseStringError403(statusMessage string) ApiResponseString
ApiResponseStringError403 接口调用失时返回的Json
func ApiResponseStringSuccess ¶
func ApiResponseStringSuccess(statusMessage string, data string) ApiResponseString
ApiResponseStringSuccess 接口调用成功后返回的Json
type ConsumerFunc ¶ added in v0.7.0
ConsumerFunc 订阅者的函数
type EventArgs ¶ added in v0.7.0
type EventArgs struct { // 唯一标识 Id string // 事件的发布时间 CreateAt int64 // 消息内容 Message any // 执行失败次数 ErrorCount int // 事件名称 EventName string }
EventArgs 事件属性
type IHealthCheck ¶ added in v0.7.0
IHealthCheck 健康检查
type ILock ¶ added in v0.7.0
type ILock interface { // TryLock 尝试加锁 TryLock() bool // GetLock 获取锁,直到获取成功 GetLock() // ReleaseLock 释放锁 ReleaseLock() // TryLockRun 尝试加锁,执行完后,自动释放锁 TryLockRun(fn func()) bool // GetLockRun 获取锁,直到获取成功,执行完后,自动释放锁 GetLockRun(fn func()) }
ILock 锁
type ILog ¶ added in v0.8.0
type ILog interface { Trace(contents ...any) // Trace Trace日志 Tracef(format string, a ...any) // Tracef Trace日志 Debug(contents ...any) // Debug Debug日志 Debugf(format string, a ...any) // Debugf Debug日志 Info(contents ...any) // Info Info日志 Infof(format string, a ...any) // Infof Info日志 Warning(content ...any) // Warning Warning日志 Warningf(format string, a ...any) // Warningf Warning日志 Error(contents ...any) error // Error Error日志 Errorf(format string, a ...any) error // Errorf Error日志 Critical(contents ...any) // Critical Critical日志 Criticalf(format string, a ...any) // Criticalf Critical日志 Log(logLevel eumLogLevel.Enum, content string, component string, newLine bool) // 通用的日志记录 }
ILog 日志记录器的外壳,由ILoggerFactory创建
type IMapperInit ¶ added in v0.9.0
type IMapperInit interface {
// MapperInit 在Mapper转换的时候初始化
MapperInit()
}
type ITransaction ¶ added in v0.8.0
type ITransaction interface { // Begin 开始 // isolationLevels:事务等级 Begin(isolationLevels ...sql.IsolationLevel) // Commit 提交 Commit() // Rollback 回滚 Rollback() // Transaction 使用事务 Transaction(executeFn func()) }
ITransaction 事务