feat: implement wiki and submission management services with corresponding database schema and API endpoints
Build and Release / release (push) Successful in 2m3s

This commit is contained in:
2026-05-27 18:00:30 +07:00
parent 79cf5caa0b
commit e35f67e26b
16 changed files with 462 additions and 265 deletions
+15
View File
@@ -14,6 +14,7 @@ import (
"history-api/pkg/cache"
"history-api/pkg/constants"
"history-api/pkg/convert"
"regexp"
"slices"
"strconv"
@@ -25,6 +26,8 @@ import (
"golang.org/x/sync/errgroup"
)
var blockquoteRegex = regexp.MustCompile(`(?is)<blockquote\b[^>]*>.*?</blockquote>`)
type SubmissionService interface {
CreateSubmission(ctx context.Context, userID string, dto *request.CreateSubmissionDto) (*response.SubmissionResponse, *fiber.Error)
UpdateSubmissionStatus(ctx context.Context, reviewerID string, submissionID string, dto *request.UpdateSubmissionStatusDto) (*response.SubmissionResponse, *fiber.Error)
@@ -888,10 +891,16 @@ func (s *submissionService) applySnapshot(ctx context.Context, tx pgx.Tx, projec
}
versionTitle := fmt.Sprintf("Version %d", count+1)
var preview pgtype.Text
if match := blockquoteRegex.FindString(wiki.Doc); match != "" {
preview = convert.StringToText(match)
}
_, err = wikiRepo.CreateContent(ctx, sqlc.CreateWikiContentParams{
WikiID: wikiUUID,
Title: versionTitle,
Content: convert.StringToText(wiki.Doc),
Preview: preview,
})
if err != nil {
return fiber.NewError(fiber.StatusInternalServerError, "Failed to create wiki content: "+err.Error())
@@ -912,10 +921,16 @@ func (s *submissionService) applySnapshot(ctx context.Context, tx pgx.Tx, projec
return fiber.NewError(fiber.StatusInternalServerError, "Failed to create wiki: "+err.Error())
}
var preview pgtype.Text
if match := blockquoteRegex.FindString(wiki.Doc); match != "" {
preview = convert.StringToText(match)
}
_, err = wikiRepo.CreateContent(ctx, sqlc.CreateWikiContentParams{
WikiID: wikiUUID,
Title: "Version 1",
Content: convert.StringToText(wiki.Doc),
Preview: preview,
})
if err != nil {
return fiber.NewError(fiber.StatusInternalServerError, "Failed to create wiki content: "+err.Error())