types

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: Apache-2.0 Imports: 2 Imported by: 20

Documentation

Index

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 CreateRequest added in v0.1.6

type CreateRequest[TCreateModel any] struct {
	Item TCreateModel `json:"item"`
}

type DbBulkRetrieve

type DbBulkRetrieve[TObjectKey KeyType, 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 KeyType] interface {
	Delete(key TObjectKey) error // 删除对象
}

DbDelete 删除

type DbEdit

type DbEdit[TBizObject any] interface {
	Edit(bizObj TBizObject) error // 编辑对象
}

type DbOperation

type DbOperation[TObjectKey KeyType, TBizObject any, TModelObject any, TCondition any] interface {
	DbCreate[TBizObject, TModelObject]
	DbRetrieve[TObjectKey, TModelObject, TCondition]
	DbUpdate[TModelObject]
	DbDelete[TObjectKey]
}

type DbRetrieve

type DbRetrieve[TObjectKey KeyType, 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 DbUpdate

type DbUpdate[TModelObject any] interface {
	Update(modelObj TModelObject) error // 更新某个字段
}

DbUpdate 更新:U

type DeleteRequest added in v0.1.6

type DeleteRequest[TKey KeyType] struct {
	Key TKey `json:"key"`
}

type GetRequest added in v0.1.6

type GetRequest[TKey KeyType] struct {
	Key TKey `json:"key"`
}

type HookFunction

type HookFunction func() error

type KeyType added in v0.1.6

type KeyType interface {
	~int64 | ~int32 | ~int | ~string
}

type QueryRequest added in v0.1.6

type QueryRequest[TFilter any] struct {
	Filters TFilter             `json:"filters,omitempty"`
	List    *protobuf.ListParam `json:"list,omitempty"`
}

type QueryResponse added in v0.1.6

type QueryResponse[TResult any] struct {
	Total int64     `json:"total"`
	Items []TResult `json:"items"`
}

type RefDbBulkRetrieve

type RefDbBulkRetrieve[TObjectKey KeyType, TRefModelObject any] interface {
	BulkGet(key TObjectKey, refKeys []TObjectKey) (map[TObjectKey]TRefModelObject, error) // 批量获取对象
}

RefDbBulkRetrieve 批量读取关联对象

type RefDbCreate

type RefDbCreate[TObjectKey KeyType, TRefBizObject any, TRefModelObject any] interface {
	Create(key TObjectKey, refBizObj TRefBizObject) (TRefModelObject, error) // 创建关联对象DAO
}

RefDbCreate 创建关联对象操作:C

type RefDbDelete

type RefDbDelete[TObjectKey KeyType] interface {
	Delete(key, refKey TObjectKey) error // 删除关联对象DAO
}

RefDbDelete 删除关联对象

type RefDbEdit

type RefDbEdit[TObjectKey KeyType, TRefBizObject any] interface {
	Edit(key TObjectKey, refBizObj TRefBizObject) error // 编辑数据库关联对象DAO
}

type RefDbOperation

type RefDbOperation[TObjectKey KeyType, TRefBizObject any, TRefModelObject any, TCondition any] interface {
	RefDbCreate[TObjectKey, TRefBizObject, TRefModelObject]
	RefDbRetrieve[TObjectKey, TRefModelObject, TCondition]
	RefDbUpdate[TRefModelObject]
	RefDbDelete[TObjectKey]
}

type RefDbRetrieve

type RefDbRetrieve[TObjectKey KeyType, 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 RepoBulkGet added in v0.1.1

type RepoBulkGet[TKey KeyType, TModel any] interface {
	BulkGet(ctx context.Context, keys ...TKey) (map[TKey]TModel, error)
}

RepoBulkGet 批量读取(返回 map) 调用者需要 slice 时,使用 pie.Values(map) 或 slices.Collect(maps.Values(map))

type RepoCount added in v0.1.6

type RepoCount[TFilter any] interface {
	Count(ctx context.Context, filter TFilter) (int64, error)
}

type RepoCreate added in v0.1.1

type RepoCreate[TCreate any, TKey KeyType] interface {
	Create(ctx context.Context, model TCreate) (TKey, error)
}

RepoCreate 创建操作:C

type RepoDelete added in v0.1.1

type RepoDelete[TKey KeyType] interface {
	Delete(ctx context.Context, keys ...TKey) (int64, error)
}

RepoDelete 删除:D

type RepoGet added in v0.1.6

type RepoGet[TKey KeyType, TModel any] interface {
	Get(ctx context.Context, key TKey) (TModel, error)
}

type RepoList added in v0.1.6

type RepoList[TFilter any, TModel any] interface {
	List(ctx context.Context, filter TFilter, list ...*protobuf.ListParam) ([]TModel, error)
}

type RepoOperation added in v0.1.6

type RepoOperation[TKey KeyType, TCreate, TUpdate, TFilter, TModel any] interface {
	RepoCreate[TCreate, TKey]
	RepoGet[TKey, TModel]
	RepoCount[TFilter]
	RepoList[TFilter, TModel]
	RepoUpdate[TUpdate]
	RepoDelete[TKey]
}

type RepoQuery added in v0.1.6

type RepoQuery[TFilter any, TModel any] interface {
	RepoCount[TFilter]
	RepoList[TFilter, TModel]
}

type RepoUpdate added in v0.1.1

type RepoUpdate[TUpdate any] interface {
	Update(ctx context.Context, model TUpdate) error
}

RepoUpdate 更新:U

type ScopedCreateRequest added in v0.1.17

type ScopedCreateRequest[TScopedKey KeyType, TCreate any] struct {
	ScopedKey TScopedKey `json:"scoped_key"`
	Item      TCreate    `json:"item"`
}

type ScopedDeleteRequest added in v0.1.17

type ScopedDeleteRequest[TScopedKey, TKey KeyType] struct {
	ScopedKey TScopedKey `json:"scoped_key"`
	Key       TKey       `json:"key"`
}

type ScopedGetRequest added in v0.1.17

type ScopedGetRequest[TScopedKey, TKey KeyType] struct {
	ScopedKey TScopedKey `json:"scoped_key"`
	Key       TKey       `json:"key"`
}

type ScopedQueryRequest added in v0.1.17

type ScopedQueryRequest[TScopedKey KeyType, TFilter any] struct {
	ScopedKey TScopedKey          `json:"scoped_key"`
	Filters   TFilter             `json:"filters,omitempty"`
	List      *protobuf.ListParam `json:"list,omitempty"`
}

type ScopedRepoCount added in v0.1.6

type ScopedRepoCount[TScopeKey KeyType, TFilter any] interface {
	Count(ctx context.Context, scopeKey TScopeKey, filters TFilter) (int64, error)
}

type ScopedRepoCreate added in v0.1.6

type ScopedRepoCreate[TScopeKey, TKey KeyType, TCreate any] interface {
	Create(ctx context.Context, scopeKey TScopeKey, item TCreate) (TKey, error)
}

type ScopedRepoDelete added in v0.1.6

type ScopedRepoDelete[TScopeKey, TKey KeyType] interface {
	Delete(ctx context.Context, scopeKey TScopeKey, keys ...TKey) (int64, error)
}

type ScopedRepoList added in v0.1.6

type ScopedRepoList[TScopeKey KeyType, TFilter, TModel any] interface {
	List(ctx context.Context, scopeKey TScopeKey, filters TFilter, list ...*protobuf.ListParam) ([]TModel, error)
}

type ScopedRepoOperation added in v0.1.6

type ScopedRepoOperation[TScopeKey, TKey KeyType, TCreate, TUpdate, TFilter, TModel any] interface {
	RepoGet[TKey, TModel]
	ScopedRepoCreate[TScopeKey, TKey, TCreate]
	ScopedRepoUpdate[TScopeKey, TUpdate]
	ScopedRepoDelete[TScopeKey, TKey]
	ScopedRepoCount[TScopeKey, TFilter]
	ScopedRepoList[TScopeKey, TFilter, TModel]
}

type ScopedRepoUpdate added in v0.1.6

type ScopedRepoUpdate[TScopeKey KeyType, TUpdate any] interface {
	Update(ctx context.Context, scopeKey TScopeKey, item TUpdate) error
}

type ScopedServiceCreate added in v0.1.18

type ScopedServiceCreate[TScopedKey, TKey KeyType, TCreate any] interface {
	Create(ctx context.Context, scopedKey TScopedKey, model TCreate) (TKey, error) // 创建业务对象
}

type ScopedServiceDelete added in v0.1.18

type ScopedServiceDelete[TScopedKey, TKey KeyType] interface {
	Delete(ctx context.Context, scopedKey TScopedKey, itemKey TKey) error
}

type ScopedServiceGet added in v0.1.18

type ScopedServiceGet[TScopedKey, TKey KeyType, TResult any] interface {
	Get(ctx context.Context, scopedKey TScopedKey, itemKey TKey) (TResult, error) // 获取业务对象
}

type ScopedServiceOperation added in v0.1.18

type ScopedServiceOperation[TScopedKey, TKey KeyType, TCreate, TUpdate, TFilter, TResult any] interface {
	ScopedServiceCreate[TScopedKey, TKey, TCreate]
	ScopedServiceGet[TScopedKey, TKey, TResult]
	ScopedServiceQuery[TScopedKey, TFilter, TResult]
	ScopedServiceUpdate[TScopedKey, TUpdate]
	ScopedServiceDelete[TScopedKey, TKey]
}

type ScopedServiceQuery added in v0.1.18

type ScopedServiceQuery[TScopedKey KeyType, TFilter, TResult any] interface {
	Query(ctx context.Context, scopedKey TScopedKey, filters TFilter, list ...*protobuf.ListParam) (int64, []TResult, error) // 查询业务对象
}

type ScopedServiceUpdate added in v0.1.18

type ScopedServiceUpdate[TScopedKey KeyType, TUpdate any] interface {
	Update(ctx context.Context, scopedKey TScopedKey, model TUpdate) error // 更新业务对象
}

type ScopedUpdateRequest added in v0.1.17

type ScopedUpdateRequest[TScopedKey KeyType, TUpdate any] struct {
	ScopedKey TScopedKey `json:"scoped_key"`
	Item      TUpdate    `json:"item"`
}

type ServiceBulkGet added in v0.1.1

type ServiceBulkGet[TKey KeyType, TResult any] interface {
	BulkGet(ctx context.Context, keys ...TKey) (map[TKey]TResult, error)
}

ServiceBulkGet 批量读取(返回 map) 调用者需要 slice 时,使用 pie.Values(map) 或 slices.Collect(maps.Values(map))

type ServiceCreate

type ServiceCreate[TCreate any, TKey KeyType] interface {
	Create(ctx context.Context, model TCreate) (TKey, error) // 创建业务对象
}

type ServiceDelete

type ServiceDelete[TKey KeyType] interface {
	Delete(ctx context.Context, key TKey) error
}

type ServiceGet added in v0.0.11

type ServiceGet[TKey KeyType, TResult any] interface {
	Get(ctx context.Context, key TKey) (TResult, error) // 获取业务对象
}

type ServiceOperation

type ServiceOperation[TKey KeyType, TCreate, TUpdate, TFilter, TResult any] interface {
	ServiceCreate[TCreate, TKey]
	ServiceGet[TKey, TResult]
	ServiceQuery[TFilter, TResult]
	ServiceUpdate[TUpdate]
	ServiceDelete[TKey]
}

type ServiceQuery added in v0.0.11

type ServiceQuery[TFilter, TResult any] interface {
	Query(ctx context.Context, filters TFilter, list ...*protobuf.ListParam) (int64, []TResult, error) // 查询业务对象
}

type ServiceUpdate

type ServiceUpdate[TUpdate any] interface {
	Update(ctx context.Context, model TUpdate) error // 更新业务对象
}

type UpdateRequest added in v0.1.8

type UpdateRequest[TUpdateModel any] struct {
	Item TUpdateModel `json:"item"`
}

Jump to

Keyboard shortcuts

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