UpdateGraphTemplate 更新模板
(ctx context.Context, eid, templateID int64, name, description string, logo string, entities []*model.EntityDefinition, relations []*model.RelationDefinition)
| 105 | |
| 106 | // UpdateGraphTemplate 更新模板 |
| 107 | func UpdateGraphTemplate(ctx context.Context, eid, templateID int64, name, description string, |
| 108 | logo string, entities []*model.EntityDefinition, relations []*model.RelationDefinition) (*model.GraphTemplate, error) { |
| 109 | |
| 110 | // 更新模板 |
| 111 | template, err := model.UpdateGraphTemplateWithDB(nil, eid, templateID, name, description, logo, entities, relations) |
| 112 | if err != nil { |
| 113 | // 区分业务错误和系统错误 |
| 114 | if err.Error() == "template not found" { |
| 115 | return nil, ErrTemplateNotFound |
| 116 | } |
| 117 | if err.Error() == "template name already exists" { |
| 118 | return nil, ErrTemplateNameExists |
| 119 | } |
| 120 | logger.SysError(fmt.Sprintf("Failed to update graph template: %v", err)) |
| 121 | return nil, err |
| 122 | } |
| 123 | |
| 124 | logger.Info(ctx, fmt.Sprintf("Graph template updated successfully, template_id: %d, name: %s", templateID, name)) |
| 125 | return template, nil |
| 126 | } |
| 127 | |
| 128 | // GetGraphTemplateList 获取模板列表 |
| 129 | func GetGraphTemplateList(ctx context.Context, eid int64, offset, limit int, keyword string) (*GraphTemplateListResponse, error) { |