Documentation
¶
Overview ¶
Package core 提供列表查询选项的处理框架
主要功能 ¶
- 分页参数管理(Offset/Limit)
- 动态查询选项处理
- 类型安全的参数解析
- 链式调用 API
基本用法 ¶
option := core.NewListOption().SetLimit(50).SetOffset(100)
processor := option.Processor()
processor.Int32("status", func(status int32) error {
// 处理状态过滤
return nil
}).String("keyword", func(keyword string) error {
// 处理关键字搜索
return nil
}).Process()
Slice 处理 ¶
processor.Int32Slice("ids", func(ids []int32) error {
// 处理多个ID:支持 "1,2,3" 或 " 1 , 2 , 3 "
return nil
})
Index ¶
- Constants
- Variables
- type BaseResponse
- func (*BaseResponse) Descriptor() ([]byte, []int)deprecated
- func (x *BaseResponse) GetCode() int32
- func (x *BaseResponse) GetData() *anypb.Any
- func (x *BaseResponse) GetHint() string
- func (x *BaseResponse) GetMessage() string
- func (*BaseResponse) ProtoMessage()
- func (x *BaseResponse) ProtoReflect() protoreflect.Message
- func (x *BaseResponse) Reset()
- func (x *BaseResponse) String() string
- type ConfigItem
- func (*ConfigItem) Descriptor() ([]byte, []int)deprecated
- func (x *ConfigItem) GetKey() string
- func (x *ConfigItem) GetValue() []byte
- func (x *ConfigItem) GetVersion() int64
- func (*ConfigItem) ProtoMessage()
- func (x *ConfigItem) ProtoReflect() protoreflect.Message
- func (x *ConfigItem) Reset()
- func (x *ConfigItem) String() string
- type DiscoveryType
- func (DiscoveryType) Descriptor() protoreflect.EnumDescriptor
- func (x DiscoveryType) Enum() *DiscoveryType
- func (DiscoveryType) EnumDescriptor() ([]byte, []int)deprecated
- func (x DiscoveryType) Number() protoreflect.EnumNumber
- func (x DiscoveryType) String() string
- func (DiscoveryType) Type() protoreflect.EnumType
- type ErrCode
- type Http
- type LazyGen
- func (*LazyGen) Descriptor() ([]byte, []int)deprecated
- func (x *LazyGen) GetAction() string
- func (x *LazyGen) GetAfterHandlers() []string
- func (x *LazyGen) GetBeforeHandlers() []string
- func (x *LazyGen) GetDesc() string
- func (x *LazyGen) GetDocs() string
- func (x *LazyGen) GetGenTo() string
- func (x *LazyGen) GetGroup() string
- func (x *LazyGen) GetModel() string
- func (x *LazyGen) GetName() string
- func (x *LazyGen) GetRoleList() []string
- func (*LazyGen) ProtoMessage()
- func (x *LazyGen) ProtoReflect() protoreflect.Message
- func (x *LazyGen) Reset()
- func (x *LazyGen) String() string
- type ListOption
- func (p *ListOption) AddOption(key int32, value string) *ListOption
- func (p *ListOption) AddOptions(options ...*ListOption_Option) *ListOption
- func (p *ListOption) Clone() *ListOption
- func (*ListOption) Descriptor() ([]byte, []int)deprecated
- func (x *ListOption) GetCursor() string
- func (x *ListOption) GetLimit() uint64
- func (x *ListOption) GetOffset() uint64
- func (x *ListOption) GetOptions() []*ListOption_Option
- func (x *ListOption) GetShowTotal() bool
- func (p *ListOption) Paginate() *Paginate
- func (p *ListOption) Processor() *ListOptionProcessor
- func (*ListOption) ProtoMessage()
- func (x *ListOption) ProtoReflect() protoreflect.Message
- func (x *ListOption) Reset()
- func (p *ListOption) SetLimit(limit uint64) *ListOption
- func (p *ListOption) SetOffset(offset uint64) *ListOption
- func (p *ListOption) SetOptions(options ...*ListOption_Option) *ListOption
- func (p *ListOption) SetShowTotal(showTotal ...bool) *ListOption
- func (x *ListOption) String() string
- type ListOptionProcessor
- func (p *ListOptionProcessor) BetweenTimestamp(key int32, logic func(start, end int64) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Bool(key int32, logic func(value bool) error) *ListOptionProcessor
- func (p *ListOptionProcessor) BoolSlice(key int32, logic func(value []bool) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Float32(key int32, logic func(value float32) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Float32Slice(key int32, logic func(value []float32) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Float64(key int32, logic func(value float64) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Float64Slice(key int32, logic func(value []float64) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Has(key int32, logic func() error) *ListOptionProcessor
- func (p *ListOptionProcessor) Int(key int32, logic func(value int) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Int8(key int32, logic func(value int8) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Int8Slice(key int32, logic func(value []int8) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Int16(key int32, logic func(value int16) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Int16Slice(key int32, logic func(value []int16) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Int32(key int32, logic func(value int32) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Int32Slice(key int32, logic func(value []int32) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Int64(key int32, logic func(value int64) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Int64Slice(key int32, logic func(value []int64) error) *ListOptionProcessor
- func (p *ListOptionProcessor) IntSlice(key int32, logic func(value []int) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Order(key int32, logic func(isDesc bool) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Process() error
- func (p *ListOptionProcessor) String(key int32, logic func(value string) error) *ListOptionProcessor
- func (p *ListOptionProcessor) StringSlice(key int32, logic func(value []string) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Timestamp(key int32, logic func(value int64) error) *ListOptionProcessor
- func (p *ListOptionProcessor) TimestampRange(key int32, logic func(start, end int64) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Uint(key int32, logic func(value uint) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Uint8(key int32, logic func(value uint8) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Uint8Slice(key int32, logic func(value []uint8) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Uint16(key int32, logic func(value uint16) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Uint16Slice(key int32, logic func(value []uint16) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Uint32(key int32, logic func(value uint32) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Uint32Slice(key int32, logic func(value []uint32) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Uint64(key int32, logic func(value uint64) error) *ListOptionProcessor
- func (p *ListOptionProcessor) Uint64Slice(key int32, logic func(value []uint64) error) *ListOptionProcessor
- func (p *ListOptionProcessor) UintSlice(key int32, logic func(value []uint) error) *ListOptionProcessor
- type ListOption_Option
- func (*ListOption_Option) Descriptor() ([]byte, []int)deprecated
- func (x *ListOption_Option) GetKey() int32
- func (x *ListOption_Option) GetValue() string
- func (*ListOption_Option) ProtoMessage()
- func (x *ListOption_Option) ProtoReflect() protoreflect.Message
- func (x *ListOption_Option) Reset()
- func (x *ListOption_Option) String() string
- type Paginate
- func (*Paginate) Descriptor() ([]byte, []int)deprecated
- func (x *Paginate) GetLimit() uint64
- func (x *Paginate) GetNextCursor() string
- func (x *Paginate) GetOffset() uint64
- func (x *Paginate) GetTotal() uint64
- func (*Paginate) ProtoMessage()
- func (x *Paginate) ProtoReflect() protoreflect.Message
- func (x *Paginate) Reset()
- func (x *Paginate) String() string
- type RawReq
- type RawRsp
- type ServiceDiscoveryClient
- func (*ServiceDiscoveryClient) Descriptor() ([]byte, []int)deprecated
- func (x *ServiceDiscoveryClient) GetDiscoveryType() DiscoveryType
- func (x *ServiceDiscoveryClient) GetMethod() string
- func (x *ServiceDiscoveryClient) GetServiceName() string
- func (x *ServiceDiscoveryClient) GetServicePath() string
- func (x *ServiceDiscoveryClient) GetTimeout() *durationpb.Duration
- func (x *ServiceDiscoveryClient) GetUrl() []string
- func (*ServiceDiscoveryClient) ProtoMessage()
- func (x *ServiceDiscoveryClient) ProtoReflect() protoreflect.Message
- func (x *ServiceDiscoveryClient) Reset()
- func (x *ServiceDiscoveryClient) String() string
- type ServiceDiscoveryNode
- func (*ServiceDiscoveryNode) Descriptor() ([]byte, []int)deprecated
- func (x *ServiceDiscoveryNode) GetAlive() bool
- func (x *ServiceDiscoveryNode) GetHost() string
- func (x *ServiceDiscoveryNode) GetPassword() string
- func (x *ServiceDiscoveryNode) GetPort() string
- func (x *ServiceDiscoveryNode) GetType() ServiceType
- func (x *ServiceDiscoveryNode) GetUsername() string
- func (*ServiceDiscoveryNode) ProtoMessage()
- func (x *ServiceDiscoveryNode) ProtoReflect() protoreflect.Message
- func (x *ServiceDiscoveryNode) Reset()
- func (x *ServiceDiscoveryNode) String() string
- type ServiceDiscoveryService
- func (*ServiceDiscoveryService) Descriptor() ([]byte, []int)deprecated
- func (x *ServiceDiscoveryService) GetNodeList() []*ServiceDiscoveryNode
- func (x *ServiceDiscoveryService) GetServiceName() string
- func (p *ServiceDiscoveryService) MergeNode(node *ServiceDiscoveryNode)
- func (*ServiceDiscoveryService) ProtoMessage()
- func (x *ServiceDiscoveryService) ProtoReflect() protoreflect.Message
- func (p *ServiceDiscoveryService) RemoveNode(node *ServiceDiscoveryNode)
- func (x *ServiceDiscoveryService) Reset()
- func (x *ServiceDiscoveryService) String() string
- type ServiceType
- func (ServiceType) Descriptor() protoreflect.EnumDescriptor
- func (x ServiceType) Enum() *ServiceType
- func (ServiceType) EnumDescriptor() ([]byte, []int)deprecated
- func (x ServiceType) Number() protoreflect.EnumNumber
- func (x ServiceType) String() string
- func (ServiceType) Type() protoreflect.EnumType
Constants ¶
const ( DefaultOffset = 0 // 默认偏移量 DefaultLimit = 20 // 默认每页条数 )
Variables ¶
var ( ErrCode_name = map[int32]string{ 0: "Success", 100: "StatusContinue", 101: "StatusSwitchingProtocols", 102: "StatusProcessing", 103: "StatusEarlyHints", 200: "StatusOK", 201: "StatusCreated", 202: "StatusAccepted", 203: "StatusNonAuthoritativeInfo", 204: "StatusNoContent", 205: "StatusResetContent", 206: "StatusPartialContent", 207: "StatusMultiStatus", 208: "StatusAlreadyReported", 226: "StatusIMUsed", 300: "StatusMultipleChoices", 301: "StatusMovedPermanently", 302: "StatusFound", 303: "StatusSeeOther", 304: "StatusNotModified", 305: "StatusUseProxy", 307: "StatusTemporaryRedirect", 308: "StatusPermanentRedirect", 400: "StatusBadRequest", 401: "StatusUnauthorized", 402: "StatusPaymentRequired", 403: "StatusForbidden", 404: "StatusNotFound", 405: "StatusMethodNotAllowed", 406: "StatusNotAcceptable", 407: "StatusProxyAuthRequired", 408: "StatusRequestTimeout", 409: "StatusConflict", 410: "StatusGone", 411: "StatusLengthRequired", 412: "StatusPreconditionFailed", 413: "StatusRequestEntityTooLarge", 414: "StatusRequestURITooLong", 415: "StatusUnsupportedMediaType", 416: "StatusRequestedRangeNotSatisfiable", 417: "StatusExpectationFailed", 418: "StatusTeapot", 421: "StatusMisdirectedRequest", 422: "StatusUnprocessableEntity", 423: "StatusLocked", 424: "StatusFailedDependency", 425: "StatusTooEarly", 426: "StatusUpgradeRequired", 428: "StatusPreconditionRequired", 429: "StatusTooManyRequests", 431: "StatusRequestHeaderFieldsTooLarge", 451: "StatusUnavailableForLegalReasons", 500: "StatusInternalServerError", 501: "StatusNotImplemented", 502: "StatusBadGateway", 503: "StatusServiceUnavailable", 504: "StatusGatewayTimeout", 505: "StatusHTTPVersionNotSupported", 506: "StatusVariantAlsoNegotiates", 507: "StatusInsufficientStorage", 508: "StatusLoopDetected", 510: "StatusNotExtended", 511: "StatusNetworkAuthenticationRequired", 1000: "ServerNotFound", 1001: "ServerNodeNotFound", 1002: "ServerAliveNodeNotFound", 1003: "ConfigNotFound", } ErrCode_value = map[string]int32{ "Success": 0, "StatusContinue": 100, "StatusSwitchingProtocols": 101, "StatusProcessing": 102, "StatusEarlyHints": 103, "StatusOK": 200, "StatusCreated": 201, "StatusAccepted": 202, "StatusNonAuthoritativeInfo": 203, "StatusNoContent": 204, "StatusResetContent": 205, "StatusPartialContent": 206, "StatusMultiStatus": 207, "StatusAlreadyReported": 208, "StatusIMUsed": 226, "StatusMultipleChoices": 300, "StatusMovedPermanently": 301, "StatusFound": 302, "StatusSeeOther": 303, "StatusNotModified": 304, "StatusUseProxy": 305, "StatusTemporaryRedirect": 307, "StatusPermanentRedirect": 308, "StatusBadRequest": 400, "StatusUnauthorized": 401, "StatusPaymentRequired": 402, "StatusForbidden": 403, "StatusNotFound": 404, "StatusMethodNotAllowed": 405, "StatusNotAcceptable": 406, "StatusProxyAuthRequired": 407, "StatusRequestTimeout": 408, "StatusConflict": 409, "StatusGone": 410, "StatusLengthRequired": 411, "StatusPreconditionFailed": 412, "StatusRequestEntityTooLarge": 413, "StatusRequestURITooLong": 414, "StatusUnsupportedMediaType": 415, "StatusRequestedRangeNotSatisfiable": 416, "StatusExpectationFailed": 417, "StatusTeapot": 418, "StatusMisdirectedRequest": 421, "StatusUnprocessableEntity": 422, "StatusLocked": 423, "StatusFailedDependency": 424, "StatusTooEarly": 425, "StatusUpgradeRequired": 426, "StatusPreconditionRequired": 428, "StatusTooManyRequests": 429, "StatusRequestHeaderFieldsTooLarge": 431, "StatusUnavailableForLegalReasons": 451, "StatusInternalServerError": 500, "StatusNotImplemented": 501, "StatusBadGateway": 502, "StatusServiceUnavailable": 503, "StatusGatewayTimeout": 504, "StatusHTTPVersionNotSupported": 505, "StatusVariantAlsoNegotiates": 506, "StatusInsufficientStorage": 507, "StatusLoopDetected": 508, "StatusNotExtended": 510, "StatusNetworkAuthenticationRequired": 511, "ServerNotFound": 1000, "ServerNodeNotFound": 1001, "ServerAliveNodeNotFound": 1002, "ConfigNotFound": 1003, } )
Enum value maps for ErrCode.
var ( DiscoveryType_name = map[int32]string{ 0: "Lazy", 1: "Etcd", 2: "Consul", 3: "Nacos", } DiscoveryType_value = map[string]int32{ "Lazy": 0, "Etcd": 1, "Consul": 2, "Nacos": 3, } )
Enum value maps for DiscoveryType.
var ( ServiceType_name = map[int32]string{ 0: "Service", } ServiceType_value = map[string]int32{ "Service": 0, } )
Enum value maps for ServiceType.
var ( // optional lazygophers.lrpc.core.Http http = 60000; E_Http = &file_core_proto_extTypes[0] // optional lazygophers.lrpc.core.LazyGen lazygen = 60001; E_Lazygen = &file_core_proto_extTypes[1] )
Extension fields to descriptorpb.MethodOptions.
var ( // optional int32 port = 60000; E_Port = &file_core_proto_extTypes[2] // 指定 ip // local/localhostt(相当于 127.0.0.1) // lan 内网 ip // */all (相当于 0.0.0.0)默认为这个 // // optional string host = 60001; E_Host = &file_core_proto_extTypes[3] )
Extension fields to descriptorpb.FileOptions.
var File_core_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type BaseResponse ¶
type BaseResponse struct {
Code int32 `` /* 144-byte string literal not displayed */
Message string `` /* 177-byte string literal not displayed */
Data *anypb.Any `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty" toml:"data,omitempty" gorm:"column:data" yaml:"data,omitempty"`
Hint string `` /* 162-byte string literal not displayed */
// contains filtered or unexported fields
}
func (*BaseResponse) Descriptor
deprecated
func (*BaseResponse) Descriptor() ([]byte, []int)
Deprecated: Use BaseResponse.ProtoReflect.Descriptor instead.
func (*BaseResponse) GetCode ¶
func (x *BaseResponse) GetCode() int32
func (*BaseResponse) GetData ¶
func (x *BaseResponse) GetData() *anypb.Any
func (*BaseResponse) GetHint ¶
func (x *BaseResponse) GetHint() string
func (*BaseResponse) GetMessage ¶
func (x *BaseResponse) GetMessage() string
func (*BaseResponse) ProtoMessage ¶
func (*BaseResponse) ProtoMessage()
func (*BaseResponse) ProtoReflect ¶
func (x *BaseResponse) ProtoReflect() protoreflect.Message
func (*BaseResponse) Reset ¶
func (x *BaseResponse) Reset()
func (*BaseResponse) String ¶
func (x *BaseResponse) String() string
type ConfigItem ¶
type ConfigItem struct {
Key string `` /* 157-byte string literal not displayed */
Value []byte `` /* 155-byte string literal not displayed */
Version int64 `` /* 159-byte string literal not displayed */
// contains filtered or unexported fields
}
分布式配置
func (*ConfigItem) Descriptor
deprecated
func (*ConfigItem) Descriptor() ([]byte, []int)
Deprecated: Use ConfigItem.ProtoReflect.Descriptor instead.
func (*ConfigItem) GetKey ¶
func (x *ConfigItem) GetKey() string
func (*ConfigItem) GetValue ¶
func (x *ConfigItem) GetValue() []byte
func (*ConfigItem) GetVersion ¶
func (x *ConfigItem) GetVersion() int64
func (*ConfigItem) ProtoMessage ¶
func (*ConfigItem) ProtoMessage()
func (*ConfigItem) ProtoReflect ¶
func (x *ConfigItem) ProtoReflect() protoreflect.Message
func (*ConfigItem) Reset ¶
func (x *ConfigItem) Reset()
func (*ConfigItem) String ¶
func (x *ConfigItem) String() string
type DiscoveryType ¶
type DiscoveryType int32
const ( DiscoveryType_Lazy DiscoveryType = 0 DiscoveryType_Etcd DiscoveryType = 1 DiscoveryType_Consul DiscoveryType = 2 DiscoveryType_Nacos DiscoveryType = 3 )
func (DiscoveryType) Descriptor ¶
func (DiscoveryType) Descriptor() protoreflect.EnumDescriptor
func (DiscoveryType) Enum ¶
func (x DiscoveryType) Enum() *DiscoveryType
func (DiscoveryType) EnumDescriptor
deprecated
func (DiscoveryType) EnumDescriptor() ([]byte, []int)
Deprecated: Use DiscoveryType.Descriptor instead.
func (DiscoveryType) Number ¶
func (x DiscoveryType) Number() protoreflect.EnumNumber
func (DiscoveryType) String ¶
func (x DiscoveryType) String() string
func (DiscoveryType) Type ¶
func (DiscoveryType) Type() protoreflect.EnumType
type ErrCode ¶
type ErrCode int32
0 - 100 xerror包占用 100 - 1000 http status code 1000 - 2000 core 占用 2000 - 10000
const ( ErrCode_Success ErrCode = 0 // 100 - 1000 http status code ErrCode_StatusContinue ErrCode = 100 ErrCode_StatusSwitchingProtocols ErrCode = 101 ErrCode_StatusProcessing ErrCode = 102 ErrCode_StatusEarlyHints ErrCode = 103 ErrCode_StatusOK ErrCode = 200 ErrCode_StatusCreated ErrCode = 201 ErrCode_StatusAccepted ErrCode = 202 ErrCode_StatusNonAuthoritativeInfo ErrCode = 203 ErrCode_StatusNoContent ErrCode = 204 ErrCode_StatusResetContent ErrCode = 205 ErrCode_StatusPartialContent ErrCode = 206 ErrCode_StatusMultiStatus ErrCode = 207 ErrCode_StatusAlreadyReported ErrCode = 208 ErrCode_StatusIMUsed ErrCode = 226 ErrCode_StatusMultipleChoices ErrCode = 300 ErrCode_StatusMovedPermanently ErrCode = 301 ErrCode_StatusFound ErrCode = 302 ErrCode_StatusSeeOther ErrCode = 303 ErrCode_StatusNotModified ErrCode = 304 ErrCode_StatusUseProxy ErrCode = 305 ErrCode_StatusTemporaryRedirect ErrCode = 307 ErrCode_StatusPermanentRedirect ErrCode = 308 ErrCode_StatusBadRequest ErrCode = 400 ErrCode_StatusPaymentRequired ErrCode = 402 ErrCode_StatusForbidden ErrCode = 403 ErrCode_StatusNotFound ErrCode = 404 ErrCode_StatusMethodNotAllowed ErrCode = 405 ErrCode_StatusNotAcceptable ErrCode = 406 ErrCode_StatusProxyAuthRequired ErrCode = 407 ErrCode_StatusRequestTimeout ErrCode = 408 ErrCode_StatusConflict ErrCode = 409 ErrCode_StatusGone ErrCode = 410 ErrCode_StatusLengthRequired ErrCode = 411 ErrCode_StatusPreconditionFailed ErrCode = 412 ErrCode_StatusRequestEntityTooLarge ErrCode = 413 ErrCode_StatusRequestURITooLong ErrCode = 414 ErrCode_StatusUnsupportedMediaType ErrCode = 415 ErrCode_StatusRequestedRangeNotSatisfiable ErrCode = 416 ErrCode_StatusExpectationFailed ErrCode = 417 ErrCode_StatusTeapot ErrCode = 418 ErrCode_StatusMisdirectedRequest ErrCode = 421 ErrCode_StatusUnprocessableEntity ErrCode = 422 ErrCode_StatusLocked ErrCode = 423 ErrCode_StatusFailedDependency ErrCode = 424 ErrCode_StatusTooEarly ErrCode = 425 ErrCode_StatusUpgradeRequired ErrCode = 426 ErrCode_StatusPreconditionRequired ErrCode = 428 ErrCode_StatusTooManyRequests ErrCode = 429 ErrCode_StatusRequestHeaderFieldsTooLarge ErrCode = 431 ErrCode_StatusInternalServerError ErrCode = 500 ErrCode_StatusNotImplemented ErrCode = 501 ErrCode_StatusBadGateway ErrCode = 502 ErrCode_StatusGatewayTimeout ErrCode = 504 ErrCode_StatusHTTPVersionNotSupported ErrCode = 505 ErrCode_StatusVariantAlsoNegotiates ErrCode = 506 ErrCode_StatusInsufficientStorage ErrCode = 507 ErrCode_StatusLoopDetected ErrCode = 508 ErrCode_StatusNotExtended ErrCode = 510 ErrCode_StatusNetworkAuthenticationRequired ErrCode = 511 // 1000 - 2000 core 占用 ErrCode_ServerNotFound ErrCode = 1000 ErrCode_ServerNodeNotFound ErrCode = 1001 ErrCode_ServerAliveNodeNotFound ErrCode = 1002 ErrCode_ConfigNotFound ErrCode = 1003 )
func (ErrCode) Descriptor ¶
func (ErrCode) Descriptor() protoreflect.EnumDescriptor
func (ErrCode) EnumDescriptor
deprecated
func (ErrCode) Number ¶
func (x ErrCode) Number() protoreflect.EnumNumber
func (ErrCode) Type ¶
func (ErrCode) Type() protoreflect.EnumType
type Http ¶
type Http struct {
Method *string `` /* 166-byte string literal not displayed */
Path *string `` /* 156-byte string literal not displayed */
// contains filtered or unexported fields
}
代码生成
func (*Http) Descriptor
deprecated
func (*Http) ProtoMessage ¶
func (*Http) ProtoMessage()
func (*Http) ProtoReflect ¶
func (x *Http) ProtoReflect() protoreflect.Message
type LazyGen ¶
type LazyGen struct {
RoleList []string `` // 角色,如 admin/user/public 等
/* 189-byte string literal not displayed */
GenTo string `` // 生成到的文件名,默认使用 impl
/* 183-byte string literal not displayed */
BeforeHandlers []string `` // 前置拦截器
/* 225-byte string literal not displayed */
AfterHandlers []string `` // 后置拦截器
/* 219-byte string literal not displayed */
Group string `` // 分组
/* 167-byte string literal not displayed */
Name string `` // 接口名
/* 162-byte string literal not displayed */
Desc string `` // 接口描述
/* 162-byte string literal not displayed */
Docs string `` // 接口文档,长文本的消息描述
/* 162-byte string literal not displayed */
Action string `` // 操作,用于根据 action 寻找对应的模板
/* 172-byte string literal not displayed */
Model string `` // 模型
/* 168-byte string literal not displayed */
// contains filtered or unexported fields
}
func (*LazyGen) Descriptor
deprecated
func (*LazyGen) GetAfterHandlers ¶
func (*LazyGen) GetBeforeHandlers ¶
func (*LazyGen) GetRoleList ¶
func (*LazyGen) ProtoMessage ¶
func (*LazyGen) ProtoMessage()
func (*LazyGen) ProtoReflect ¶
func (x *LazyGen) ProtoReflect() protoreflect.Message
type ListOption ¶
type ListOption struct {
// @desc: 这一页的起始索引
// @example: 0
Offset uint64 `` /* 198-byte string literal not displayed */
// @desc: 每一页的数量
// @example: 10
Limit uint64 `` /* 188-byte string literal not displayed */
// @desc: 是否返回总数
// @example: true
ShowTotal bool `` /* 246-byte string literal not displayed */
// @desc: 游标,用于分页,如果有优先使用 cursor
Cursor string `` /* 231-byte string literal not displayed */
// @desc: 过滤条件
Options []*ListOption_Option `` /* 185-byte string literal not displayed */
// contains filtered or unexported fields
}
分页
func (*ListOption) AddOption ¶
func (p *ListOption) AddOption(key int32, value string) *ListOption
AddOption 添加单个查询选项的便捷方法 返回自身以支持链式调用
func (*ListOption) AddOptions ¶
func (p *ListOption) AddOptions(options ...*ListOption_Option) *ListOption
AddOptions 添加查询选项(追加到现有选项) 返回自身以支持链式调用
func (*ListOption) Clone ¶
func (p *ListOption) Clone() *ListOption
Clone 创建 ListOption 的深拷贝 如果 p 为 nil,返回使用默认值的新实例
func (*ListOption) Descriptor
deprecated
func (*ListOption) Descriptor() ([]byte, []int)
Deprecated: Use ListOption.ProtoReflect.Descriptor instead.
func (*ListOption) GetCursor ¶
func (x *ListOption) GetCursor() string
func (*ListOption) GetLimit ¶
func (x *ListOption) GetLimit() uint64
func (*ListOption) GetOffset ¶
func (x *ListOption) GetOffset() uint64
func (*ListOption) GetOptions ¶
func (x *ListOption) GetOptions() []*ListOption_Option
func (*ListOption) GetShowTotal ¶
func (x *ListOption) GetShowTotal() bool
func (*ListOption) Paginate ¶
func (p *ListOption) Paginate() *Paginate
Paginate 转换为 Paginate 对象(用于分页结果) 如果 p 为 nil,返回使用默认值的新实例
func (*ListOption) Processor ¶
func (p *ListOption) Processor() *ListOptionProcessor
Processor 创建一个 ListOptionProcessor 来处理查询选项 内部会克隆当前 ListOption 以避免副作用
func (*ListOption) ProtoMessage ¶
func (*ListOption) ProtoMessage()
func (*ListOption) ProtoReflect ¶
func (x *ListOption) ProtoReflect() protoreflect.Message
func (*ListOption) Reset ¶
func (x *ListOption) Reset()
func (*ListOption) SetLimit ¶
func (p *ListOption) SetLimit(limit uint64) *ListOption
SetLimit 设置每页条数限制 返回自身以支持链式调用
func (*ListOption) SetOffset ¶
func (p *ListOption) SetOffset(offset uint64) *ListOption
SetOffset 设置查询偏移量(用于分页) 返回自身以支持链式调用
func (*ListOption) SetOptions ¶
func (p *ListOption) SetOptions(options ...*ListOption_Option) *ListOption
SetOptions 设置查询选项(覆盖现有选项) 返回自身以支持链式调用
func (*ListOption) SetShowTotal ¶
func (p *ListOption) SetShowTotal(showTotal ...bool) *ListOption
SetShowTotal 设置是否显示总数 如果不提供参数,默认为 true 返回自身以支持链式调用
func (*ListOption) String ¶
func (x *ListOption) String() string
type ListOptionProcessor ¶
type ListOptionProcessor struct {
ListOption *ListOption
Handler map[int32]func(string) error
}
ListOptionProcessor 提供类型安全的查询选项处理器 使用链式调用注册处理函数,然后调用 Process() 执行
示例:
processor := option.Processor()
err := processor.
Int32("status", func(status int32) error {
query = query.Where("status = ?", status)
return nil
}).
StringSlice("tags", func(tags []string) error {
query = query.Where("tag IN ?", tags)
return nil
}).
Process()
func NewListOptionProcessor ¶
func NewListOptionProcessor(option *ListOption) *ListOptionProcessor
NewListOptionProcessor 创建新的选项处理器
func (*ListOptionProcessor) BetweenTimestamp ¶
func (p *ListOptionProcessor) BetweenTimestamp(key int32, logic func(start, end int64) error) *ListOptionProcessor
BetweenTimestamp 是 TimestampRange 的别名,语义更清晰
func (*ListOptionProcessor) Bool ¶
func (p *ListOptionProcessor) Bool(key int32, logic func(value bool) error) *ListOptionProcessor
Bool 注册布尔类型的选项处理器 支持多种表示:true/false, 1/0, yes/no, y/n, on/off, enable/disable, enabled/disabled, ok/cancel
func (*ListOptionProcessor) BoolSlice ¶
func (p *ListOptionProcessor) BoolSlice(key int32, logic func(value []bool) error) *ListOptionProcessor
func (*ListOptionProcessor) Float32 ¶
func (p *ListOptionProcessor) Float32(key int32, logic func(value float32) error) *ListOptionProcessor
func (*ListOptionProcessor) Float32Slice ¶
func (p *ListOptionProcessor) Float32Slice(key int32, logic func(value []float32) error) *ListOptionProcessor
func (*ListOptionProcessor) Float64 ¶
func (p *ListOptionProcessor) Float64(key int32, logic func(value float64) error) *ListOptionProcessor
func (*ListOptionProcessor) Float64Slice ¶
func (p *ListOptionProcessor) Float64Slice(key int32, logic func(value []float64) error) *ListOptionProcessor
func (*ListOptionProcessor) Has ¶
func (p *ListOptionProcessor) Has(key int32, logic func() error) *ListOptionProcessor
Has 注册存在性检查处理器 只要选项存在就会调用 logic,不关心选项的值 适用于 flag 类型的选项
func (*ListOptionProcessor) Int ¶
func (p *ListOptionProcessor) Int(key int32, logic func(value int) error) *ListOptionProcessor
Int 注册 int 类型的选项处理器,自动解析字符串为 int
func (*ListOptionProcessor) Int8 ¶
func (p *ListOptionProcessor) Int8(key int32, logic func(value int8) error) *ListOptionProcessor
Int8 注册 int8 类型的选项处理器,自动解析字符串为 int8
func (*ListOptionProcessor) Int8Slice ¶
func (p *ListOptionProcessor) Int8Slice(key int32, logic func(value []int8) error) *ListOptionProcessor
func (*ListOptionProcessor) Int16 ¶
func (p *ListOptionProcessor) Int16(key int32, logic func(value int16) error) *ListOptionProcessor
func (*ListOptionProcessor) Int16Slice ¶
func (p *ListOptionProcessor) Int16Slice(key int32, logic func(value []int16) error) *ListOptionProcessor
func (*ListOptionProcessor) Int32 ¶
func (p *ListOptionProcessor) Int32(key int32, logic func(value int32) error) *ListOptionProcessor
func (*ListOptionProcessor) Int32Slice ¶
func (p *ListOptionProcessor) Int32Slice(key int32, logic func(value []int32) error) *ListOptionProcessor
func (*ListOptionProcessor) Int64 ¶
func (p *ListOptionProcessor) Int64(key int32, logic func(value int64) error) *ListOptionProcessor
func (*ListOptionProcessor) Int64Slice ¶
func (p *ListOptionProcessor) Int64Slice(key int32, logic func(value []int64) error) *ListOptionProcessor
func (*ListOptionProcessor) IntSlice ¶
func (p *ListOptionProcessor) IntSlice(key int32, logic func(value []int) error) *ListOptionProcessor
IntSlice 注册 int 切片处理器,解析逗号分隔的整数 自动清理空白字符,过滤空值 示例:"1, 2, , 3" -> [1, 2, 3]
func (*ListOptionProcessor) Order ¶
func (p *ListOptionProcessor) Order(key int32, logic func(isDesc bool) error) *ListOptionProcessor
Order 注册排序方向处理器 解析排序方向:desc/descend/descending -> true (降序) asc/ascend/ascending/"" -> false (升序,默认) 返回布尔值而非字符串,更易于使用
func (*ListOptionProcessor) Process ¶
func (p *ListOptionProcessor) Process() error
Process 执行所有已注册的选项处理器 1. 自动校正并限制 Offset 和 Limit 的值 2. 按注册顺序执行各选项的处理逻辑 3. 遇到错误立即返回
限制规则:
- Offset < 0 -> 设为默认值 0
- Limit < 0 -> 设为默认值 20
- Limit > 1000 -> 限制为 1000
func (*ListOptionProcessor) String ¶
func (p *ListOptionProcessor) String(key int32, logic func(value string) error) *ListOptionProcessor
String 注册字符串类型的选项处理器 返回自身以支持链式调用
func (*ListOptionProcessor) StringSlice ¶
func (p *ListOptionProcessor) StringSlice(key int32, logic func(value []string) error) *ListOptionProcessor
StringSlice 注册字符串切片处理器,解析逗号分隔的字符串 自动清理空白字符,过滤空字符串 示例:"a, b, , c" -> ["a", "b", "c"]
func (*ListOptionProcessor) Timestamp ¶
func (p *ListOptionProcessor) Timestamp(key int32, logic func(value int64) error) *ListOptionProcessor
Timestamp 注册时间戳类型(int64)的选项处理器
func (*ListOptionProcessor) TimestampRange ¶
func (p *ListOptionProcessor) TimestampRange(key int32, logic func(start, end int64) error) *ListOptionProcessor
TimestampRange 注册时间范围处理器,解析逗号分隔的两个时间戳 格式:「start,end」
func (*ListOptionProcessor) Uint ¶
func (p *ListOptionProcessor) Uint(key int32, logic func(value uint) error) *ListOptionProcessor
func (*ListOptionProcessor) Uint8 ¶
func (p *ListOptionProcessor) Uint8(key int32, logic func(value uint8) error) *ListOptionProcessor
func (*ListOptionProcessor) Uint8Slice ¶
func (p *ListOptionProcessor) Uint8Slice(key int32, logic func(value []uint8) error) *ListOptionProcessor
func (*ListOptionProcessor) Uint16 ¶
func (p *ListOptionProcessor) Uint16(key int32, logic func(value uint16) error) *ListOptionProcessor
func (*ListOptionProcessor) Uint16Slice ¶
func (p *ListOptionProcessor) Uint16Slice(key int32, logic func(value []uint16) error) *ListOptionProcessor
func (*ListOptionProcessor) Uint32 ¶
func (p *ListOptionProcessor) Uint32(key int32, logic func(value uint32) error) *ListOptionProcessor
func (*ListOptionProcessor) Uint32Slice ¶
func (p *ListOptionProcessor) Uint32Slice(key int32, logic func(value []uint32) error) *ListOptionProcessor
func (*ListOptionProcessor) Uint64 ¶
func (p *ListOptionProcessor) Uint64(key int32, logic func(value uint64) error) *ListOptionProcessor
func (*ListOptionProcessor) Uint64Slice ¶
func (p *ListOptionProcessor) Uint64Slice(key int32, logic func(value []uint64) error) *ListOptionProcessor
func (*ListOptionProcessor) UintSlice ¶
func (p *ListOptionProcessor) UintSlice(key int32, logic func(value []uint) error) *ListOptionProcessor
type ListOption_Option ¶
type ListOption_Option struct {
// @desc: 键值对,描述过滤的条件,一般为请求接口的 ListOption 枚举
// @example: 1
Key int32 `` /* 235-byte string literal not displayed */
// @desc: 过滤的条件
// @example: "true"
Value string `` /* 205-byte string literal not displayed */
// contains filtered or unexported fields
}
func (*ListOption_Option) Descriptor
deprecated
func (*ListOption_Option) Descriptor() ([]byte, []int)
Deprecated: Use ListOption_Option.ProtoReflect.Descriptor instead.
func (*ListOption_Option) GetKey ¶
func (x *ListOption_Option) GetKey() int32
func (*ListOption_Option) GetValue ¶
func (x *ListOption_Option) GetValue() string
func (*ListOption_Option) ProtoMessage ¶
func (*ListOption_Option) ProtoMessage()
func (*ListOption_Option) ProtoReflect ¶
func (x *ListOption_Option) ProtoReflect() protoreflect.Message
func (*ListOption_Option) Reset ¶
func (x *ListOption_Option) Reset()
func (*ListOption_Option) String ¶
func (x *ListOption_Option) String() string
type Paginate ¶
type Paginate struct {
// @desc: 这一页的起始索引
// @example: 0
Offset uint64 `` /* 198-byte string literal not displayed */
// @desc: 每一页的数量
// @example: 10
Limit uint64 `` /* 188-byte string literal not displayed */
// @desc: 总数,只有传入 show_total 为 true 时才会返回
// @example: 100
Total uint64 `` /* 224-byte string literal not displayed */
// @desc: 下一页的游标,用于分页,如果有优先使用 cursor
NextCursor string `` /* 284-byte string literal not displayed */
// contains filtered or unexported fields
}
func (*Paginate) Descriptor
deprecated
func (*Paginate) GetNextCursor ¶
func (*Paginate) ProtoMessage ¶
func (*Paginate) ProtoMessage()
func (*Paginate) ProtoReflect ¶
func (x *Paginate) ProtoReflect() protoreflect.Message
type RawReq ¶
type RawReq struct {
Body []byte `` /* 150-byte string literal not displayed */
// contains filtered or unexported fields
}
func (*RawReq) Descriptor
deprecated
func (*RawReq) ProtoMessage ¶
func (*RawReq) ProtoMessage()
func (*RawReq) ProtoReflect ¶
func (x *RawReq) ProtoReflect() protoreflect.Message
type RawRsp ¶
type RawRsp struct {
Body []byte `` /* 150-byte string literal not displayed */
// 不填会按照纯文本处理
ContentType string `` /* 219-byte string literal not displayed */
// contains filtered or unexported fields
}
func (*RawRsp) Descriptor
deprecated
func (*RawRsp) GetContentType ¶
func (*RawRsp) ProtoMessage ¶
func (*RawRsp) ProtoMessage()
func (*RawRsp) ProtoReflect ¶
func (x *RawRsp) ProtoReflect() protoreflect.Message
type ServiceDiscoveryClient ¶
type ServiceDiscoveryClient struct {
DiscoveryType DiscoveryType `` /* 254-byte string literal not displayed */
// 当 type = none 时生效
Url []string `` /* 145-byte string literal not displayed */
ServiceName string `` /* 219-byte string literal not displayed */
ServicePath string `` /* 219-byte string literal not displayed */
Method string `` /* 172-byte string literal not displayed */
Timeout *durationpb.Duration `` /* 139-byte string literal not displayed */
// contains filtered or unexported fields
}
func (*ServiceDiscoveryClient) Descriptor
deprecated
func (*ServiceDiscoveryClient) Descriptor() ([]byte, []int)
Deprecated: Use ServiceDiscoveryClient.ProtoReflect.Descriptor instead.
func (*ServiceDiscoveryClient) GetDiscoveryType ¶
func (x *ServiceDiscoveryClient) GetDiscoveryType() DiscoveryType
func (*ServiceDiscoveryClient) GetMethod ¶
func (x *ServiceDiscoveryClient) GetMethod() string
func (*ServiceDiscoveryClient) GetServiceName ¶
func (x *ServiceDiscoveryClient) GetServiceName() string
func (*ServiceDiscoveryClient) GetServicePath ¶
func (x *ServiceDiscoveryClient) GetServicePath() string
func (*ServiceDiscoveryClient) GetTimeout ¶
func (x *ServiceDiscoveryClient) GetTimeout() *durationpb.Duration
func (*ServiceDiscoveryClient) GetUrl ¶
func (x *ServiceDiscoveryClient) GetUrl() []string
func (*ServiceDiscoveryClient) ProtoMessage ¶
func (*ServiceDiscoveryClient) ProtoMessage()
func (*ServiceDiscoveryClient) ProtoReflect ¶
func (x *ServiceDiscoveryClient) ProtoReflect() protoreflect.Message
func (*ServiceDiscoveryClient) Reset ¶
func (x *ServiceDiscoveryClient) Reset()
func (*ServiceDiscoveryClient) String ¶
func (x *ServiceDiscoveryClient) String() string
type ServiceDiscoveryNode ¶
type ServiceDiscoveryNode struct {
Type ServiceType `` /* 183-byte string literal not displayed */
Host string `` /* 162-byte string literal not displayed */
Port string `` /* 162-byte string literal not displayed */
Username string `` /* 182-byte string literal not displayed */
Password string `` /* 182-byte string literal not displayed */
Alive bool `` /* 165-byte string literal not displayed */
// contains filtered or unexported fields
}
func (*ServiceDiscoveryNode) Descriptor
deprecated
func (*ServiceDiscoveryNode) Descriptor() ([]byte, []int)
Deprecated: Use ServiceDiscoveryNode.ProtoReflect.Descriptor instead.
func (*ServiceDiscoveryNode) GetAlive ¶
func (x *ServiceDiscoveryNode) GetAlive() bool
func (*ServiceDiscoveryNode) GetHost ¶
func (x *ServiceDiscoveryNode) GetHost() string
func (*ServiceDiscoveryNode) GetPassword ¶
func (x *ServiceDiscoveryNode) GetPassword() string
func (*ServiceDiscoveryNode) GetPort ¶
func (x *ServiceDiscoveryNode) GetPort() string
func (*ServiceDiscoveryNode) GetType ¶
func (x *ServiceDiscoveryNode) GetType() ServiceType
func (*ServiceDiscoveryNode) GetUsername ¶
func (x *ServiceDiscoveryNode) GetUsername() string
func (*ServiceDiscoveryNode) ProtoMessage ¶
func (*ServiceDiscoveryNode) ProtoMessage()
func (*ServiceDiscoveryNode) ProtoReflect ¶
func (x *ServiceDiscoveryNode) ProtoReflect() protoreflect.Message
func (*ServiceDiscoveryNode) Reset ¶
func (x *ServiceDiscoveryNode) Reset()
func (*ServiceDiscoveryNode) String ¶
func (x *ServiceDiscoveryNode) String() string
type ServiceDiscoveryService ¶
type ServiceDiscoveryService struct {
ServiceName string `` /* 219-byte string literal not displayed */
NodeList []*ServiceDiscoveryNode `` /* 189-byte string literal not displayed */
// contains filtered or unexported fields
}
func (*ServiceDiscoveryService) Descriptor
deprecated
func (*ServiceDiscoveryService) Descriptor() ([]byte, []int)
Deprecated: Use ServiceDiscoveryService.ProtoReflect.Descriptor instead.
func (*ServiceDiscoveryService) GetNodeList ¶
func (x *ServiceDiscoveryService) GetNodeList() []*ServiceDiscoveryNode
func (*ServiceDiscoveryService) GetServiceName ¶
func (x *ServiceDiscoveryService) GetServiceName() string
func (*ServiceDiscoveryService) MergeNode ¶
func (p *ServiceDiscoveryService) MergeNode(node *ServiceDiscoveryNode)
func (*ServiceDiscoveryService) ProtoMessage ¶
func (*ServiceDiscoveryService) ProtoMessage()
func (*ServiceDiscoveryService) ProtoReflect ¶
func (x *ServiceDiscoveryService) ProtoReflect() protoreflect.Message
func (*ServiceDiscoveryService) RemoveNode ¶
func (p *ServiceDiscoveryService) RemoveNode(node *ServiceDiscoveryNode)
func (*ServiceDiscoveryService) Reset ¶
func (x *ServiceDiscoveryService) Reset()
func (*ServiceDiscoveryService) String ¶
func (x *ServiceDiscoveryService) String() string
type ServiceType ¶
type ServiceType int32
const (
ServiceType_Service ServiceType = 0
)
func (ServiceType) Descriptor ¶
func (ServiceType) Descriptor() protoreflect.EnumDescriptor
func (ServiceType) Enum ¶
func (x ServiceType) Enum() *ServiceType
func (ServiceType) EnumDescriptor
deprecated
func (ServiceType) EnumDescriptor() ([]byte, []int)
Deprecated: Use ServiceType.Descriptor instead.
func (ServiceType) Number ¶
func (x ServiceType) Number() protoreflect.EnumNumber
func (ServiceType) String ¶
func (x ServiceType) String() string
func (ServiceType) Type ¶
func (ServiceType) Type() protoreflect.EnumType