Documentation
¶
Index ¶
- type AppServer
- type BulkOperateObjectRequest
- type CreateObjectResponse
- type CreateRefObjectRequest
- type DbBulkRetrieve
- type DbCreate
- type DbDelete
- type DbEdit
- type DbOperation
- type DbRetrieve
- type DbUpdate
- type DeleteRefObjectRequest
- type EditRefObjectRequest
- type GetRefObjectRequest
- type HookFunction
- type ObjectKeyType
- type OperateObjectRequest
- type QueryObjectRequest
- type QueryObjectResponse
- type QueryRefObjectRequest
- type QueryRefObjectResponse
- type RefDbBulkRetrieve
- type RefDbCreate
- type RefDbDelete
- type RefDbEdit
- type RefDbOperation
- type RefDbRetrieve
- type RefDbUpdate
- type RepoBulkCreate
- type RepoBulkGet
- type RepoCRUD
- type RepoCRUDFull
- type RepoCRUDWithBulk
- type RepoCreate
- type RepoDelete
- type RepoEdit
- type RepoRetrieve
- type RepoUpdate
- type RepoUpsert
- type ServiceBulkCreate
- type ServiceBulkGet
- type ServiceCreate
- type ServiceDelete
- type ServiceEdit
- type ServiceGet
- type ServiceOperation
- type ServiceQuery
- type ServiceRetrieve
- type ServiceUpdate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppServer ¶
type AppServer interface {
Start() error // 开始
Stop(forced ...bool) error // 默认为优雅关闭, 如果forced为true, 则强制关闭
HookPreStart(fns ...HookFunction) AppServer // 添加启动前的钩子函数
HookPreStop(fns ...HookFunction) AppServer // 添加停止前的钩子函数
}
type BulkOperateObjectRequest ¶
type BulkOperateObjectRequest[TObjectKey ObjectKeyType] struct { Keys []TObjectKey `json:"keys"` }
type CreateObjectResponse ¶
type CreateObjectResponse[TObjectId ObjectKeyType] struct { Id TObjectId `json:"id"` }
type CreateRefObjectRequest ¶
type CreateRefObjectRequest[TObjectKey ObjectKeyType, TBizObject any] struct { Key TObjectKey `json:"key"` Item TBizObject `json:"item"` }
type DbBulkRetrieve ¶
type DbBulkRetrieve[TObjectKey ObjectKeyType, ModelObject any] interface { BulkGet(ids []TObjectKey) (map[TObjectKey]ModelObject, error) // 批量获取对象 }
DbBulkRetrieve 批量读取
type DbCreate ¶
type DbCreate[BizObject any, ModelObject any] interface { Create(bizObj BizObject) (ModelObject, error) // 创建对象 }
DbCreate 创建操作:C
type DbDelete ¶
type DbDelete[TObjectKey ObjectKeyType] interface { Delete(key TObjectKey) error // 删除对象 }
DbDelete 删除
type DbOperation ¶
type DbOperation[TObjectKey ObjectKeyType, TBizObject any, TModelObject any, TCondition any] interface { DbCreate[TBizObject, TModelObject] DbRetrieve[TObjectKey, TModelObject, TCondition] DbUpdate[TModelObject] DbDelete[TObjectKey] }
type DbRetrieve ¶
type DbRetrieve[TObjectKey ObjectKeyType, TModelObject any, TCondition any] interface { Get(key TObjectKey) (TModelObject, error) // 获取对象 Count(filters map[string]string) (int64, error) // 统计对象 List(filters map[string]string, list ...*protobuf.ListParam) ([]TModelObject, error) // 列出对象, list不传的时候获取所有对象 GetQueryConditions(filters map[string]string) []TCondition // 获取查询条件 }
DbRetrieve 读操作
type DeleteRefObjectRequest ¶
type DeleteRefObjectRequest[TObjectKey ObjectKeyType] struct { Key TObjectKey `json:"key"` ItemKey TObjectKey `json:"item_key"` }
type EditRefObjectRequest ¶
type EditRefObjectRequest[TObjectKey ObjectKeyType, TBizObject any] struct { Key TObjectKey `json:"key"` Item TBizObject `json:"item"` }
type GetRefObjectRequest ¶
type GetRefObjectRequest[TObjectKey ObjectKeyType] struct { Key TObjectKey `json:"key"` ItemKey TObjectKey `json:"item_key"` }
type HookFunction ¶
type HookFunction func() error
type OperateObjectRequest ¶
type OperateObjectRequest[TObjectKey ObjectKeyType] struct { Key TObjectKey `json:"key"` }
type QueryObjectRequest ¶
type QueryObjectResponse ¶
type QueryRefObjectRequest ¶
type QueryRefObjectRequest[TObjectKey ObjectKeyType] struct { Key TObjectKey `json:"key"` Filters map[string]string `json:"filters,omitempty"` List *protobuf.ListParam `json:"list,omitempty"` }
type QueryRefObjectResponse ¶
type RefDbBulkRetrieve ¶
type RefDbBulkRetrieve[TObjectKey ObjectKeyType, TRefModelObject any] interface { BulkGet(key TObjectKey, refKeys []TObjectKey) (map[TObjectKey]TRefModelObject, error) // 批量获取对象 }
RefDbBulkRetrieve 批量读取关联对象
type RefDbCreate ¶
type RefDbCreate[TObjectKey ObjectKeyType, TRefBizObject any, TRefModelObject any] interface { Create(key TObjectKey, refBizObj TRefBizObject) (TRefModelObject, error) // 创建关联对象DAO }
RefDbCreate 创建关联对象操作:C
type RefDbDelete ¶
type RefDbDelete[TObjectKey ObjectKeyType] interface { Delete(key, refKey TObjectKey) error // 删除关联对象DAO }
RefDbDelete 删除关联对象
type RefDbEdit ¶
type RefDbEdit[TObjectKey ObjectKeyType, TRefBizObject any] interface { Edit(key TObjectKey, refBizObj TRefBizObject) error // 编辑数据库关联对象DAO }
type RefDbOperation ¶
type RefDbOperation[TObjectKey ObjectKeyType, TRefBizObject any, TRefModelObject any, TCondition any] interface { RefDbCreate[TObjectKey, TRefBizObject, TRefModelObject] RefDbRetrieve[TObjectKey, TRefModelObject, TCondition] RefDbUpdate[TRefModelObject] RefDbDelete[TObjectKey] }
type RefDbRetrieve ¶
type RefDbRetrieve[TObjectKey ObjectKeyType, TRefModelObject any, Condition any] interface { Get(key, refKey TObjectKey) (TRefModelObject, error) // 获取关联对象DAO Count(key TObjectKey, refObjFilters map[string]string) (int64, error) // 统计关联对象DAO List(key TObjectKey, refObjFilters map[string]string, list ...*protobuf.ListParam) ([]TRefModelObject, error) // 列出关联对象DAO GetQueryConditions(key TObjectKey, refObjFilters map[string]string) []Condition // 获取关联对象DAO }
RefDbRetrieve 读取关联对象操作:R
type RefDbUpdate ¶
type RefDbUpdate[TRefObjectModel any] interface { Update(refObjModel TRefObjectModel) error // 更新数据库关联对象 }
RefDbUpdate 更新关联对象:U
type RepoBulkCreate ¶ added in v0.1.1
type RepoBulkCreate[TModelObject any] interface { BulkCreate(ctx context.Context, items []TModelObject) ([]TModelObject, error) }
RepoBulkCreate 批量创建
type RepoBulkGet ¶ added in v0.1.1
type RepoBulkGet[TObjectKey ObjectKeyType, TModelObject any] interface { BulkGet(ctx context.Context, ids []TObjectKey) (map[TObjectKey]TModelObject, error) }
RepoBulkGet 批量读取(返回 map) 调用者需要 slice 时,使用 pie.Values(map) 或 slices.Collect(maps.Values(map))
type RepoCRUD ¶ added in v0.1.1
type RepoCRUD[TObjectKey ObjectKeyType, TBizObject any, TModelObject any] interface { RepoCreate[TBizObject, TModelObject] RepoRetrieve[TObjectKey, TModelObject] RepoEdit[TBizObject, TModelObject] RepoDelete[TObjectKey] }
RepoCRUD 标准 CRUD 操作接口 TObjectKey: 主键类型(int64, int32, int, string) TBizObject: 业务对象类型(pb.XXX) TModelObject: 数据模型类型(db.XXX)
type RepoCRUDFull ¶ added in v0.1.1
type RepoCRUDFull[TObjectKey ObjectKeyType, TBizObject any, TModelObject any] interface { RepoCreate[TBizObject, TModelObject] RepoRetrieve[TObjectKey, TModelObject] RepoBulkGet[TObjectKey, TModelObject] RepoEdit[TBizObject, TModelObject] RepoDelete[TObjectKey] }
RepoCRUDFull 完整 CRUD(包含所有常用操作)
type RepoCRUDWithBulk ¶ added in v0.1.1
type RepoCRUDWithBulk[TObjectKey ObjectKeyType, TBizObject any, TModelObject any] interface { RepoCRUD[TObjectKey, TBizObject, TModelObject] RepoBulkGet[TObjectKey, TModelObject] }
RepoCRUDWithBulk 标准 CRUD + 批量读取
type RepoCreate ¶ added in v0.1.1
type RepoCreate[TBizObject any, TModelObject any] interface { Create(ctx context.Context, bizObj TBizObject) (TModelObject, error) }
RepoCreate 创建操作:C
type RepoDelete ¶ added in v0.1.1
type RepoDelete[TObjectKey ObjectKeyType] interface { Delete(ctx context.Context, key TObjectKey) error }
RepoDelete 删除:D
type RepoEdit ¶ added in v0.1.1
type RepoEdit[TBizObject any, TModelObject any] interface { Edit(ctx context.Context, bizObj TBizObject) (TModelObject, error) }
RepoEdit 编辑操作(基于业务对象,返回模型对象)
type RepoRetrieve ¶ added in v0.1.1
type RepoRetrieve[TObjectKey ObjectKeyType, TModelObject any] interface { Get(ctx context.Context, key TObjectKey) (TModelObject, error) Count(ctx context.Context, filters map[string]string) (int64, error) List(ctx context.Context, filters map[string]string, list ...*protobuf.ListParam) ([]TModelObject, error) }
RepoRetrieve 读操作:R
type RepoUpdate ¶ added in v0.1.1
type RepoUpdate[TModelObject any] interface { Update(ctx context.Context, modelObj TModelObject) error }
RepoUpdate 更新:U
type RepoUpsert ¶ added in v0.1.1
type RepoUpsert[TBizObject any, TModelObject any] interface { Upsert(ctx context.Context, bizObj TBizObject) (TModelObject, error) }
RepoUpsert Upsert 操作(创建或更新)
type ServiceBulkCreate ¶ added in v0.1.1
type ServiceBulkCreate[TModelObject any] interface { BulkCreate(ctx context.Context, items []TModelObject) ([]TModelObject, error) }
ServiceBulkCreate 批量创建
type ServiceBulkGet ¶ added in v0.1.1
type ServiceBulkGet[TObjectKey ObjectKeyType, TModelObject any] interface { BulkGet(ctx context.Context, ids []TObjectKey) (map[TObjectKey]TModelObject, error) }
ServiceBulkGet 批量读取(返回 map) 调用者需要 slice 时,使用 pie.Values(map) 或 slices.Collect(maps.Values(map))
type ServiceCreate ¶
type ServiceDelete ¶
type ServiceDelete[TObjectKey ObjectKeyType] interface { Delete(ctx context.Context, key TObjectKey) error // 删除业务对象 }
type ServiceEdit ¶ added in v0.1.1
type ServiceGet ¶ added in v0.0.11
type ServiceGet[TObjectKey ObjectKeyType, TBizObject any] interface { Get(ctx context.Context, key TObjectKey) (TBizObject, error) // 获取业务对象 }
type ServiceOperation ¶
type ServiceOperation[TObjectKey ObjectKeyType, TBizObject any] interface { ServiceCreate[TBizObject] ServiceRetrieve[TObjectKey, TBizObject] ServiceEdit[TBizObject] ServiceDelete[TObjectKey] }
type ServiceQuery ¶ added in v0.0.11
type ServiceRetrieve ¶
type ServiceRetrieve[TObjectKey ObjectKeyType, TBizObject any] interface { ServiceGet[TObjectKey, TBizObject] ServiceQuery[TBizObject] }