feat: 新增工作流执行模块
新增流程执行记录的实体、DTO、DAO、控制器和服务层,支持工作流的执行、回调及结果树状列表查询;同时更新服务名称为 ai-agent。
This commit is contained in:
70
workflow/dao/flow/flow_template_dao.go
Normal file
70
workflow/dao/flow/flow_template_dao.go
Normal file
@@ -0,0 +1,70 @@
|
||||
package flow
|
||||
|
||||
import (
|
||||
"ai-agent/workflow/consts/public"
|
||||
flowDto "ai-agent/workflow/model/dto/flow"
|
||||
"ai-agent/workflow/model/entity"
|
||||
"context"
|
||||
|
||||
"gitea.com/red-future/common/db/gfdb"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
var FlowTemplateDao = &flowTemplateDao{}
|
||||
|
||||
type flowTemplateDao struct{}
|
||||
|
||||
func (d *flowTemplateDao) Insert(ctx context.Context, req *flowDto.CreateFlowTemplateReq) (id int64, err error) {
|
||||
var e = new(entity.FlowTemplate)
|
||||
err = gconv.Struct(req, &e)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
r, err := gfdb.DB(ctx, public.DbNameBlackDeacon).Model(ctx, public.TableNameFlowTemplate).Insert(e)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return r.LastInsertId()
|
||||
}
|
||||
|
||||
func (d *flowTemplateDao) Update(ctx context.Context, req *flowDto.UpdateFlowTemplateReq) (rows int64, err error) {
|
||||
r, err := gfdb.DB(ctx, public.DbNameBlackDeacon).Model(ctx, public.TableNameFlowTemplate).OmitEmpty().
|
||||
Where(entity.FlowTemplateCol.Id, req.Id).
|
||||
Data(req).
|
||||
Update()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return r.RowsAffected()
|
||||
}
|
||||
|
||||
func (d *flowTemplateDao) Delete(ctx context.Context, req *flowDto.DeleteFlowTemplateReq) (rows int64, err error) {
|
||||
r, err := gfdb.DB(ctx, public.DbNameBlackDeacon).Model(ctx, public.TableNameFlowTemplate).Where(entity.FlowTemplateCol.Id, req.Id).Delete()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return r.RowsAffected()
|
||||
}
|
||||
|
||||
func (d *flowTemplateDao) Get(ctx context.Context, req *flowDto.GetFlowTemplateReq, fields ...string) (res *entity.FlowTemplate, err error) {
|
||||
r, err := gfdb.DB(ctx, public.DbNameBlackDeacon).Model(ctx, public.TableNameFlowTemplate).NoTenantId(ctx).Where(entity.FlowTemplateCol.Id, req.Id).Fields(fields).One()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = r.Struct(&res)
|
||||
return
|
||||
}
|
||||
|
||||
func (d *flowTemplateDao) List(ctx context.Context, req *flowDto.ListFlowTemplateReq, fields ...string) (res []*entity.FlowTemplate, total int, err error) {
|
||||
model := gfdb.DB(ctx, public.DbNameBlackDeacon).Model(ctx, public.TableNameFlowTemplate).NoTenantId(ctx).Fields(fields).OmitEmpty()
|
||||
model.OrderDesc(entity.FlowTemplateCol.CreatedAt)
|
||||
if req.Page != nil {
|
||||
model.Page(int(req.Page.PageNum), int(req.Page.PageSize))
|
||||
}
|
||||
r, total, err := model.AllAndCount(false)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = r.Structs(&res)
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user