MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / UpdateDoc

Method UpdateDoc

module/api-doc/api_doc.go:30–56  ·  view source on GitHub ↗
(ctx context.Context, serviceId string, input *api_doc_dto.UpdateDoc)

Source from the content-addressed store, hash-verified

28}
29
30func (i *imlAPIDocModule) UpdateDoc(ctx context.Context, serviceId string, input *api_doc_dto.UpdateDoc) (*api_doc_dto.ApiDocDetail, error) {
31 info, err := i.serviceService.Get(ctx, serviceId)
32 if err != nil {
33 return nil, err
34 }
35 if input.Id == "" {
36 input.Id = uuid.New().String()
37 }
38 // 每个API加上前缀
39 err = i.transaction.Transaction(ctx, func(ctx context.Context) error {
40 count, err := i.apiDocService.UpdateDoc(ctx, serviceId, &api_doc.UpdateDoc{
41 ID: input.Id,
42 Content: input.Content,
43 Prefix: info.Prefix,
44 })
45 if err != nil {
46 return fmt.Errorf("update api doc error:%v", err)
47 }
48 return i.serviceOverviewService.Update(ctx, serviceId, &service_overview.Update{
49 ApiCount: &count,
50 })
51 })
52 if err != nil {
53 return nil, err
54 }
55 return i.GetDoc(ctx, serviceId)
56}
57
58func (i *imlAPIDocModule) GetDoc(ctx context.Context, serviceId string) (*api_doc_dto.ApiDocDetail, error) {
59 _, err := i.serviceService.Get(ctx, serviceId)

Callers

nothing calls this directly

Calls 5

GetDocMethod · 0.95
GetMethod · 0.65
UpdateDocMethod · 0.65
UpdateMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected