1 Star 0 Fork 0

water/goweb

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cmd_dto.go 1.77 KB
一键复制 编辑 原始数据 按行查看 历史
leijmdas 提交于 2024-11-10 19:04 . add
package cmddto
import (
"gitee.com/leijmdas/gobase/goconfig/common/base/basedto"
"gitee.com/leijmdas/gobase/goconfig/common/base/jsonutils"
"gitee.com/leijmdas/goweb/goes/esdto"
"github.com/olivere/elastic/v7"
)
type ScriptDto struct {
basedto.BaseEntity
UpdateClause string
Params map[string]interface{}
}
func NewScriptDto() *ScriptDto {
return &ScriptDto{}
}
type CmdDto struct {
basedto.BaseEntity
esdto.ReqDto
Script *ScriptDto `json:"script"`
Refresh string `json:"refresh"`
Data interface{} `json:"data"`
Doc map[string]interface{} `json:"params"`
BulkDocs []*BulkDoc
BulkStrus []*BulkStru
}
func NewCmdDto() *CmdDto {
var cmd = &CmdDto{
Script: NewScriptDto(),
Refresh: "true",
Doc: make(map[string]interface{}),
BulkDocs: make([]*BulkDoc, 0),
}
cmd.InitProxy(cmd)
return cmd
}
func (self *CmdDto) RefreshStr() string {
return self.Refresh
}
func (self *CmdDto) ScriptAs(updateClause string, params map[string]interface{}) string {
self.Script.UpdateClause = updateClause
self.Script.Params = params
return self.Refresh
}
func (self *CmdDto) NewScript() *elastic.Script {
return elastic.NewScriptInline(self.Script.UpdateClause).Params(self.Script.Params)
}
func (self *CmdDto) AddDoc(id string, doc map[string]any) {
var bd = NewBulkDoc()
bd.Id = id
bd.Doc = doc
self.AddBulkDoc(bd)
}
func (self *CmdDto) AddStru(id string, doc any) {
var bulkStru = NewBulkStru()
bulkStru.Id = id
bulkStru.Doc = doc
self.AddDoc(id, jsonutils.Stru2Map(doc))
self.AddBulkStru(bulkStru)
}
func (self *CmdDto) AddBulkStru(bulkDoc *BulkStru) {
self.BulkStrus = append(self.BulkStrus, bulkDoc)
}
func (self *CmdDto) AddBulkDoc(bulkDoc *BulkDoc) {
self.BulkDocs = append(self.BulkDocs, bulkDoc)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/leijmdas/goweb.git
git@gitee.com:leijmdas/goweb.git
leijmdas
goweb
goweb
v1.0.2-dev-10

搜索帮助