fix: 修复更新流程用户时的返回值和逻辑

- 调整 Update 接口返回创建结果 ID
- 修复管理员更新流程模板和普通用户更新流程的归属逻辑
This commit is contained in:
2026-08-24 17:18:53 +08:00
parent f0f8724bd9
commit 8936a4c921
2 changed files with 27 additions and 25 deletions
@@ -18,9 +18,8 @@ func (c *flowUser) Create(ctx context.Context, req *flowDto.CreateFlowUserReq) (
return
}
func (c *flowUser) Update(ctx context.Context, req *flowDto.UpdateFlowUserReq) (res *beans.ResponseEmpty, err error) {
err = flowService.FlowUserService.Update(ctx, req)
return
func (c *flowUser) Update(ctx context.Context, req *flowDto.UpdateFlowUserReq) (res *flowDto.CreateFlowUserRes, err error) {
return flowService.FlowUserService.Update(ctx, req)
}
func (c *flowUser) Delete(ctx context.Context, req *flowDto.DeleteFlowUserReq) (res *beans.ResponseEmpty, err error) {
+25 -22
View File
@@ -39,31 +39,13 @@ func (s *flowUserService) Create(ctx context.Context, req *flowDto.CreateFlowUse
return &flowDto.CreateFlowUserRes{Id: id}, err
}
func (s *flowUserService) Update(ctx context.Context, req *flowDto.UpdateFlowUserReq) (err error) {
func (s *flowUserService) Update(ctx context.Context, req *flowDto.UpdateFlowUserReq) (res *flowDto.CreateFlowUserRes, err error) {
id := req.Id
admin, err := service.UtilService.IsAdmin(ctx)
if err != nil {
return
}
req.NodeInputParams = ExtractFlowNodeFrom(req.FlowContent)
get, err := flowDao.FlowTemplateDao.Get(ctx, &flowDto.GetFlowTemplateReq{
Id: req.Id,
})
if err != nil {
return err
}
if !g.IsEmpty(get) && !admin {
_, err = flowDao.FlowUserDao.Insert(ctx, &flowDto.CreateFlowUserReq{
FlowName: req.FlowName,
Description: req.Description,
FlowContent: req.FlowContent,
NodeInputParams: req.NodeInputParams,
SourceFlowTemplateId: get.Id,
})
if err != nil {
return
}
}
if admin {
_, err = flowDao.FlowTemplateDao.Update(ctx, &flowDto.UpdateFlowTemplateReq{
Id: req.Id,
@@ -74,9 +56,30 @@ func (s *flowUserService) Update(ctx context.Context, req *flowDto.UpdateFlowUse
Status: flow.FlowTemplateStatusEnable.Code(),
})
} else {
_, err = flowDao.FlowUserDao.Update(ctx, req)
var get *entity.FlowTemplate
get, err = flowDao.FlowTemplateDao.Get(ctx, &flowDto.GetFlowTemplateReq{
Id: req.Id,
})
if err != nil {
return nil, err
}
if !g.IsEmpty(get) {
id, err = flowDao.FlowUserDao.Insert(ctx, &flowDto.CreateFlowUserReq{
FlowName: req.FlowName,
Description: req.Description,
FlowContent: req.FlowContent,
NodeInputParams: req.NodeInputParams,
SourceFlowTemplateId: get.Id,
})
if err != nil {
return
}
} else {
_, err = flowDao.FlowUserDao.Update(ctx, req)
}
}
return
return &flowDto.CreateFlowUserRes{Id: id}, err
}
func (s *flowUserService) Delete(ctx context.Context, req *flowDto.DeleteFlowUserReq) (err error) {