feat: implement wiki and wiki content management system including database schemas, DTOs, and API endpoints
All checks were successful
Build and Release / release (push) Successful in 1m33s
All checks were successful
Build and Release / release (push) Successful in 1m33s
This commit is contained in:
@@ -512,12 +512,29 @@ func (s *submissionService) UpdateSubmissionStatus(ctx context.Context, reviewer
|
||||
ID: wikiUUID,
|
||||
Title: convert.StringToText(wiki.Title),
|
||||
Slug: convert.PtrToText(wiki.Slug),
|
||||
Content: convert.StringToText(wiki.Doc),
|
||||
ProjectID: projectUUID,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fiber.NewError(fiber.StatusInternalServerError, "Failed to update wiki: "+err.Error())
|
||||
}
|
||||
|
||||
count, err := s.wikiRepo.GetContentCountByWikiID(ctx, wikiUUID)
|
||||
if err != nil {
|
||||
return nil, fiber.NewError(fiber.StatusInternalServerError, "Failed to get wiki content count: "+err.Error())
|
||||
}
|
||||
versionTitle := fmt.Sprintf("Version %d", count+1)
|
||||
|
||||
_, err = wikiRepo.CreateContent(ctx, sqlc.CreateWikiContentParams{
|
||||
WikiID: wikiUUID,
|
||||
Title: versionTitle,
|
||||
Content: convert.StringToText(wiki.Doc),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fiber.NewError(fiber.StatusInternalServerError, "Failed to create wiki content: "+err.Error())
|
||||
}
|
||||
|
||||
_ = s.c.Del(ctx, fmt.Sprintf("wiki:id:%s", wikiUUID.String()), fmt.Sprintf("wiki:slug:%s", *wiki.Slug))
|
||||
|
||||
newWikis = append(newWikis, snapshotData.Wikis[i])
|
||||
|
||||
} else if wiki.Source == "inline" {
|
||||
@@ -525,12 +542,23 @@ func (s *submissionService) UpdateSubmissionStatus(ctx context.Context, reviewer
|
||||
ID: wikiUUID,
|
||||
Title: convert.StringToText(wiki.Title),
|
||||
Slug: convert.PtrToText(wiki.Slug),
|
||||
Content: convert.StringToText(wiki.Doc),
|
||||
ProjectID: projectUUID,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fiber.NewError(fiber.StatusInternalServerError, "Failed to create wiki: "+err.Error())
|
||||
}
|
||||
|
||||
_, err = wikiRepo.CreateContent(ctx, sqlc.CreateWikiContentParams{
|
||||
WikiID: wikiUUID,
|
||||
Title: "Version 1",
|
||||
Content: convert.StringToText(wiki.Doc),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fiber.NewError(fiber.StatusInternalServerError, "Failed to create wiki content: "+err.Error())
|
||||
}
|
||||
|
||||
_ = s.c.Del(ctx, fmt.Sprintf("wiki:id:%s", wikiUUID.String()), fmt.Sprintf("wiki:slug:%s", *wiki.Slug))
|
||||
|
||||
newWikis = append(newWikis, snapshotData.Wikis[i])
|
||||
|
||||
} else if wiki.Source == "ref" {
|
||||
|
||||
@@ -19,6 +19,7 @@ type WikiService interface {
|
||||
GetWikiBySlug(ctx context.Context, slug string) (*response.WikiResponse, *fiber.Error)
|
||||
IsExistWikiSlug(ctx context.Context, slug string) (bool, *fiber.Error)
|
||||
SearchWikis(ctx context.Context, req *request.SearchWikiDto) ([]*response.WikiResponse, *fiber.Error)
|
||||
GetWikiContentByID(ctx context.Context, id string) (*response.WikiContentResponse, *fiber.Error)
|
||||
}
|
||||
|
||||
type wikiService struct {
|
||||
@@ -107,3 +108,22 @@ func (s *wikiService) SearchWikis(ctx context.Context, req *request.SearchWikiDt
|
||||
|
||||
return models.WikisEntityToResponse(wikis), nil
|
||||
}
|
||||
|
||||
func (s *wikiService) GetWikiContentByID(ctx context.Context, id string) (*response.WikiContentResponse, *fiber.Error) {
|
||||
contentId, err := convert.StringToUUID(id)
|
||||
if err != nil {
|
||||
return nil, fiber.NewError(fiber.StatusBadRequest, "Invalid content ID format")
|
||||
}
|
||||
content, err := s.wikiRepo.GetContentByID(ctx, contentId)
|
||||
if err != nil {
|
||||
return nil, fiber.NewError(fiber.StatusNotFound, "Wiki content not found")
|
||||
}
|
||||
|
||||
return &response.WikiContentResponse{
|
||||
ID: content.ID,
|
||||
WikiID: content.WikiID,
|
||||
Title: content.Title,
|
||||
Content: content.Content,
|
||||
CreatedAt: content.CreatedAt,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user