feat: 新增工作流执行模块
新增流程执行记录的实体、DTO、DAO、控制器和服务层,支持工作流的执行、回调及结果树状列表查询;同时更新服务名称为 ai-agent。
This commit is contained in:
55
workflow/service/flow/flow_template_service.go
Normal file
55
workflow/service/flow/flow_template_service.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package flow
|
||||
|
||||
import (
|
||||
flowDao "ai-agent/workflow/dao/flow"
|
||||
flowDto "ai-agent/workflow/model/dto/flow"
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
var FlowTemplateService = &flowTemplateService{}
|
||||
|
||||
type flowTemplateService struct{}
|
||||
|
||||
func (s *flowTemplateService) Create(ctx context.Context, req *flowDto.CreateFlowTemplateReq) (res *flowDto.CreateFlowTemplateRes, err error) {
|
||||
req.NodeInputParams = ExtractFlowNodeFrom(req.FlowContent)
|
||||
id, err := flowDao.FlowTemplateDao.Insert(ctx, req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return &flowDto.CreateFlowTemplateRes{Id: id}, nil
|
||||
}
|
||||
|
||||
func (s *flowTemplateService) Update(ctx context.Context, req *flowDto.UpdateFlowTemplateReq) (err error) {
|
||||
req.NodeInputParams = ExtractFlowNodeFrom(req.FlowContent)
|
||||
_, err = flowDao.FlowTemplateDao.Update(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
func (s *flowTemplateService) Delete(ctx context.Context, req *flowDto.DeleteFlowTemplateReq) (err error) {
|
||||
_, err = flowDao.FlowTemplateDao.Delete(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
func (s *flowTemplateService) Get(ctx context.Context, req *flowDto.GetFlowTemplateReq) (res *flowDto.FlowTemplateVO, err error) {
|
||||
flowInfo, err := flowDao.FlowTemplateDao.Get(ctx, req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
res = new(flowDto.FlowTemplateVO)
|
||||
err = gconv.Struct(flowInfo, res)
|
||||
return
|
||||
}
|
||||
|
||||
func (s *flowTemplateService) List(ctx context.Context, req *flowDto.ListFlowTemplateReq) (res *flowDto.ListFlowTemplateRes, err error) {
|
||||
list, total, err := flowDao.FlowTemplateDao.List(ctx, req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
res = &flowDto.ListFlowTemplateRes{
|
||||
Total: total,
|
||||
}
|
||||
err = gconv.Struct(list, &res.List)
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user