Documentation ¶
Overview ¶
service/base_service.go
Index ¶
- Variables
- func CamelToSnake(s string) string
- type DslBaseService
- func (bs *DslBaseService[T]) BulkCreate(models []T) (int, error)
- func (bs *DslBaseService[T]) BulkDelete(ids []string) (int, error)
- func (bs *DslBaseService[T]) Create(model T) (*T, error)
- func (bs *DslBaseService[T]) Delete(id string) error
- func (bs *DslBaseService[T]) GetById(id string) (*T, error)
- func (bs *DslBaseService[T]) PageByDTO(queryDto interface{}, queryPage *QueryPage) ([]T, int, error)
- func (bs *DslBaseService[T]) Update(id string, model T) (*T, error)
- type ESResponse
- type HitElement
- type Hits
- type IDSLDao
- type IDslBaseEntity
- type QueryPage
- type TotalHits
- type ZincClient
- func (zc *ZincClient) BulkCreate(indexName string, docs []map[string]interface{}) error
- func (zc *ZincClient) BulkDelete(indexName string, ids []string) error
- func (zc *ZincClient) Create(indexName string, doc interface{}) error
- func (zc *ZincClient) CreateWithId(indexName string, doc interface{}, id int64) error
- func (zc *ZincClient) Delete(indexName, id string) error
- func (zc *ZincClient) PageByDTO(indexName string, dto any, queryPage QueryPage) (*ESResponse, int, error)
- func (zc *ZincClient) Search(indexName string, query interface{}) ([]byte, error)
- func (zc *ZincClient) Update(indexName, id string, update interface{}) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ZincClientObj = NewZincClient("http://192.168.1.200:4080", "admin", "admin")
Functions ¶
Types ¶
type DslBaseService ¶
type DslBaseService[T IDslBaseEntity] struct { DB *ZincClient // GORM 数据库连接实例 Model T // 模型引用 }
DslBaseService 定义了一个通用的基础服务,提供了一些通用的字段和方法。
func NewDslBaseService ¶
func NewDslBaseService[T IDslBaseEntity](db *ZincClient, model T) *DslBaseService[T]
NewDslBaseService 创建一个新的 DslBaseService 实例。
func (*DslBaseService[T]) BulkCreate ¶
func (bs *DslBaseService[T]) BulkCreate(models []T) (int, error)
BulkCreate 实现批量创建
func (*DslBaseService[T]) BulkDelete ¶
func (bs *DslBaseService[T]) BulkDelete(ids []string) (int, error)
Create 实现基础服务接口中的创建方法
func (*DslBaseService[T]) Create ¶
func (bs *DslBaseService[T]) Create(model T) (*T, error)
Create 实现基础服务接口中的创建方法
func (*DslBaseService[T]) Delete ¶
func (bs *DslBaseService[T]) Delete(id string) error
Delete 实现基础服务接口中的删除方法
func (*DslBaseService[T]) GetById ¶
func (bs *DslBaseService[T]) GetById(id string) (*T, error)
Read 实现基础服务接口中的读取方法
func (*DslBaseService[T]) PageByDTO ¶
func (bs *DslBaseService[T]) PageByDTO(queryDto interface{}, queryPage *QueryPage) ([]T, int, error)
func (*DslBaseService[T]) Update ¶
func (bs *DslBaseService[T]) Update(id string, model T) (*T, error)
Update 实现基础服务接口中的更新方法
type ESResponse ¶
type ESResponse struct {
Hits Hits `json:"hits"`
}
type HitElement ¶
type Hits ¶
type Hits struct { Total TotalHits `json:"total"` MaxScore float64 `json:"max_score"` Hits []HitElement `json:"hits"` }
type IDSLDao ¶
type IDSLDao interface { BulkCreate(indexName string, docs []map[string]interface{}) error BulkDelete(indexName string, ids []string) error Create(indexName string, doc interface{}) error Search(indexName string, query interface{}) ([]byte, error) Update(indexName, id string, update interface{}) error Delete(indexName, id string) error // PageByDTO(indexName string, dto map[string]string, pageNum, pageSize int) (*ESResponse, int, error) PageByDTO(queryDto interface{}, queryPage *QueryPage) (*ESResponse, int, error) }
type IDslBaseEntity ¶
type ZincClient ¶
ZincClient 代表与ZincSearch交互的客户端
func NewZincClient ¶
func NewZincClient(host, username, password string) *ZincClient
NewZincClient 创建一个新的ZincSearch客户端实例
func (*ZincClient) BulkCreate ¶
func (zc *ZincClient) BulkCreate(indexName string, docs []map[string]interface{}) error
修改后的 BulkCreateDocuments 方法直接接受 []map[string]interface{}
func (*ZincClient) BulkDelete ¶
func (zc *ZincClient) BulkDelete(indexName string, ids []string) error
BulkDeleteDocuments 批量删除指定索引中的文档
func (*ZincClient) Create ¶
func (zc *ZincClient) Create(indexName string, doc interface{}) error
CreateDocument 向指定索引添加文档
func (*ZincClient) CreateWithId ¶
func (zc *ZincClient) CreateWithId(indexName string, doc interface{}, id int64) error
CreateDocument 向指定索引添加文档
func (*ZincClient) Delete ¶
func (zc *ZincClient) Delete(indexName, id string) error
DeleteDocument 删除指定索引中的文档
func (*ZincClient) PageByDTO ¶
func (zc *ZincClient) PageByDTO(indexName string, dto any, queryPage QueryPage) (*ESResponse, int, error)
func (*ZincClient) Search ¶
func (zc *ZincClient) Search(indexName string, query interface{}) ([]byte, error)
SearchDocuments 在指定索引中搜索文档
func (*ZincClient) Update ¶
func (zc *ZincClient) Update(indexName, id string, update interface{}) error
UpdateDocument 更新指定索引中的文档
Click to show internal directories.
Click to hide internal directories.