UPDATE: change submit
All checks were successful
Build and Release / release (push) Successful in 1m35s
All checks were successful
Build and Release / release (push) Successful in 1m35s
This commit is contained in:
@@ -6,6 +6,8 @@ INSERT INTO submissions (
|
||||
)
|
||||
RETURNING
|
||||
id, project_id, commit_id, user_id, created_at, status, reviewed_by, reviewed_at, review_note, content, is_deleted,
|
||||
(SELECT title FROM projects WHERE id = submissions.project_id) AS project_title,
|
||||
(SELECT description FROM projects WHERE id = submissions.project_id) AS project_description,
|
||||
(
|
||||
SELECT json_build_object(
|
||||
'id', u.id,
|
||||
@@ -34,6 +36,7 @@ RETURNING
|
||||
-- name: GetSubmissionById :one
|
||||
SELECT
|
||||
s.id, s.project_id, s.commit_id, s.user_id, s.created_at, s.status, s.reviewed_by, s.reviewed_at, s.review_note, s.content, s.is_deleted,
|
||||
p.title AS project_title, p.description AS project_description,
|
||||
json_build_object(
|
||||
'id', u.id,
|
||||
'email', u.email,
|
||||
@@ -51,6 +54,7 @@ SELECT
|
||||
)::json
|
||||
ELSE NULL::json END AS reviewer
|
||||
FROM submissions s
|
||||
JOIN projects p ON s.project_id = p.id
|
||||
JOIN users u ON s.user_id = u.id
|
||||
LEFT JOIN user_profiles up ON u.id = up.user_id
|
||||
LEFT JOIN users ru ON s.reviewed_by = ru.id
|
||||
@@ -64,14 +68,16 @@ SET
|
||||
reviewed_by = COALESCE(sqlc.narg('reviewed_by'), reviewed_by),
|
||||
review_note = COALESCE(sqlc.narg('review_note'), review_note),
|
||||
content = COALESCE(sqlc.narg('content'), content)
|
||||
FROM users u
|
||||
FROM projects p, users u
|
||||
LEFT JOIN user_profiles up ON u.id = up.user_id
|
||||
LEFT JOIN users ru ON submissions.reviewed_by = ru.id
|
||||
LEFT JOIN user_profiles rup ON ru.id = rup.user_id
|
||||
WHERE submissions.id = sqlc.arg('id')
|
||||
AND submissions.project_id = p.id
|
||||
AND submissions.user_id = u.id
|
||||
RETURNING
|
||||
submissions.id, submissions.project_id, submissions.commit_id, submissions.user_id, submissions.created_at, submissions.status, submissions.reviewed_by, submissions.reviewed_at, submissions.review_note, submissions.content, submissions.is_deleted,
|
||||
p.title AS project_title, p.description AS project_description,
|
||||
json_build_object(
|
||||
'id', u.id,
|
||||
'email', u.email,
|
||||
@@ -97,6 +103,7 @@ WHERE id = $1;
|
||||
-- name: SearchSubmissions :many
|
||||
SELECT
|
||||
s.id, s.project_id, s.commit_id, s.user_id, s.created_at, s.status, s.reviewed_by, s.reviewed_at, s.review_note, s.content, s.is_deleted,
|
||||
p.title AS project_title, p.description AS project_description,
|
||||
json_build_object(
|
||||
'id', u.id,
|
||||
'email', u.email,
|
||||
@@ -114,6 +121,7 @@ SELECT
|
||||
)::json
|
||||
ELSE NULL::json END AS reviewer
|
||||
FROM submissions s
|
||||
JOIN projects p ON s.project_id = p.id
|
||||
JOIN users u ON s.user_id = u.id
|
||||
LEFT JOIN user_profiles up ON u.id = up.user_id
|
||||
LEFT JOIN users ru ON s.reviewed_by = ru.id
|
||||
@@ -168,6 +176,7 @@ WHERE s.is_deleted = false
|
||||
-- name: GetSubmissionsByIDs :many
|
||||
SELECT
|
||||
s.id, s.project_id, s.commit_id, s.user_id, s.created_at, s.status, s.reviewed_by, s.reviewed_at, s.review_note, s.content, s.is_deleted,
|
||||
p.title AS project_title, p.description AS project_description,
|
||||
json_build_object(
|
||||
'id', u.id,
|
||||
'email', u.email,
|
||||
@@ -185,8 +194,10 @@ SELECT
|
||||
)::json
|
||||
ELSE NULL::json END AS reviewer
|
||||
FROM submissions s
|
||||
JOIN projects p ON s.project_id = p.id
|
||||
JOIN users u ON s.user_id = u.id
|
||||
LEFT JOIN user_profiles up ON u.id = up.user_id
|
||||
LEFT JOIN users ru ON s.reviewed_by = ru.id
|
||||
LEFT JOIN user_profiles rup ON ru.id = rup.user_id
|
||||
WHERE s.id = ANY($1::uuid[]) AND s.is_deleted = false;
|
||||
|
||||
|
||||
@@ -3,16 +3,18 @@ package response
|
||||
import "time"
|
||||
|
||||
type SubmissionResponse struct {
|
||||
ID string `json:"id"`
|
||||
ProjectID string `json:"project_id"`
|
||||
CommitID string `json:"commit_id"`
|
||||
UserID string `json:"user_id"`
|
||||
CreatedAt *time.Time `json:"created_at"`
|
||||
Status string `json:"status"`
|
||||
ReviewedBy *string `json:"reviewed_by,omitempty"`
|
||||
ReviewedAt *time.Time `json:"reviewed_at,omitempty"`
|
||||
ReviewNote *string `json:"review_note,omitempty"`
|
||||
Content *string `json:"content,omitempty"`
|
||||
User *UserSimpleResponse `json:"user"`
|
||||
Reviewer *UserSimpleResponse `json:"reviewer,omitempty"`
|
||||
ID string `json:"id"`
|
||||
ProjectID string `json:"project_id"`
|
||||
CommitID string `json:"commit_id"`
|
||||
UserID string `json:"user_id"`
|
||||
CreatedAt *time.Time `json:"created_at"`
|
||||
Status string `json:"status"`
|
||||
ReviewedBy *string `json:"reviewed_by,omitempty"`
|
||||
ReviewedAt *time.Time `json:"reviewed_at,omitempty"`
|
||||
ReviewNote *string `json:"review_note,omitempty"`
|
||||
Content *string `json:"content,omitempty"`
|
||||
ProjectTitle string `json:"project_title"`
|
||||
ProjectDescription *string `json:"project_description,omitempty"`
|
||||
User *UserSimpleResponse `json:"user"`
|
||||
Reviewer *UserSimpleResponse `json:"reviewer,omitempty"`
|
||||
}
|
||||
|
||||
@@ -65,6 +65,8 @@ INSERT INTO submissions (
|
||||
)
|
||||
RETURNING
|
||||
id, project_id, commit_id, user_id, created_at, status, reviewed_by, reviewed_at, review_note, content, is_deleted,
|
||||
(SELECT title FROM projects WHERE id = submissions.project_id) AS project_title,
|
||||
(SELECT description FROM projects WHERE id = submissions.project_id) AS project_description,
|
||||
(
|
||||
SELECT json_build_object(
|
||||
'id', u.id,
|
||||
@@ -100,19 +102,21 @@ type CreateSubmissionParams struct {
|
||||
}
|
||||
|
||||
type CreateSubmissionRow struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
CommitID pgtype.UUID `json:"commit_id"`
|
||||
UserID pgtype.UUID `json:"user_id"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
Status int16 `json:"status"`
|
||||
ReviewedBy pgtype.UUID `json:"reviewed_by"`
|
||||
ReviewedAt pgtype.Timestamptz `json:"reviewed_at"`
|
||||
ReviewNote pgtype.Text `json:"review_note"`
|
||||
Content pgtype.Text `json:"content"`
|
||||
IsDeleted bool `json:"is_deleted"`
|
||||
User []byte `json:"user"`
|
||||
Reviewer []byte `json:"reviewer"`
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
CommitID pgtype.UUID `json:"commit_id"`
|
||||
UserID pgtype.UUID `json:"user_id"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
Status int16 `json:"status"`
|
||||
ReviewedBy pgtype.UUID `json:"reviewed_by"`
|
||||
ReviewedAt pgtype.Timestamptz `json:"reviewed_at"`
|
||||
ReviewNote pgtype.Text `json:"review_note"`
|
||||
Content pgtype.Text `json:"content"`
|
||||
IsDeleted bool `json:"is_deleted"`
|
||||
ProjectTitle string `json:"project_title"`
|
||||
ProjectDescription pgtype.Text `json:"project_description"`
|
||||
User []byte `json:"user"`
|
||||
Reviewer []byte `json:"reviewer"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateSubmission(ctx context.Context, arg CreateSubmissionParams) (CreateSubmissionRow, error) {
|
||||
@@ -136,6 +140,8 @@ func (q *Queries) CreateSubmission(ctx context.Context, arg CreateSubmissionPara
|
||||
&i.ReviewNote,
|
||||
&i.Content,
|
||||
&i.IsDeleted,
|
||||
&i.ProjectTitle,
|
||||
&i.ProjectDescription,
|
||||
&i.User,
|
||||
&i.Reviewer,
|
||||
)
|
||||
@@ -156,6 +162,7 @@ func (q *Queries) DeleteSubmission(ctx context.Context, id pgtype.UUID) error {
|
||||
const getSubmissionById = `-- name: GetSubmissionById :one
|
||||
SELECT
|
||||
s.id, s.project_id, s.commit_id, s.user_id, s.created_at, s.status, s.reviewed_by, s.reviewed_at, s.review_note, s.content, s.is_deleted,
|
||||
p.title AS project_title, p.description AS project_description,
|
||||
json_build_object(
|
||||
'id', u.id,
|
||||
'email', u.email,
|
||||
@@ -173,6 +180,7 @@ SELECT
|
||||
)::json
|
||||
ELSE NULL::json END AS reviewer
|
||||
FROM submissions s
|
||||
JOIN projects p ON s.project_id = p.id
|
||||
JOIN users u ON s.user_id = u.id
|
||||
LEFT JOIN user_profiles up ON u.id = up.user_id
|
||||
LEFT JOIN users ru ON s.reviewed_by = ru.id
|
||||
@@ -181,19 +189,21 @@ WHERE s.id = $1 AND s.is_deleted = false
|
||||
`
|
||||
|
||||
type GetSubmissionByIdRow struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
CommitID pgtype.UUID `json:"commit_id"`
|
||||
UserID pgtype.UUID `json:"user_id"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
Status int16 `json:"status"`
|
||||
ReviewedBy pgtype.UUID `json:"reviewed_by"`
|
||||
ReviewedAt pgtype.Timestamptz `json:"reviewed_at"`
|
||||
ReviewNote pgtype.Text `json:"review_note"`
|
||||
Content pgtype.Text `json:"content"`
|
||||
IsDeleted bool `json:"is_deleted"`
|
||||
User []byte `json:"user"`
|
||||
Reviewer []byte `json:"reviewer"`
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
CommitID pgtype.UUID `json:"commit_id"`
|
||||
UserID pgtype.UUID `json:"user_id"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
Status int16 `json:"status"`
|
||||
ReviewedBy pgtype.UUID `json:"reviewed_by"`
|
||||
ReviewedAt pgtype.Timestamptz `json:"reviewed_at"`
|
||||
ReviewNote pgtype.Text `json:"review_note"`
|
||||
Content pgtype.Text `json:"content"`
|
||||
IsDeleted bool `json:"is_deleted"`
|
||||
ProjectTitle string `json:"project_title"`
|
||||
ProjectDescription pgtype.Text `json:"project_description"`
|
||||
User []byte `json:"user"`
|
||||
Reviewer []byte `json:"reviewer"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetSubmissionById(ctx context.Context, id pgtype.UUID) (GetSubmissionByIdRow, error) {
|
||||
@@ -211,6 +221,8 @@ func (q *Queries) GetSubmissionById(ctx context.Context, id pgtype.UUID) (GetSub
|
||||
&i.ReviewNote,
|
||||
&i.Content,
|
||||
&i.IsDeleted,
|
||||
&i.ProjectTitle,
|
||||
&i.ProjectDescription,
|
||||
&i.User,
|
||||
&i.Reviewer,
|
||||
)
|
||||
@@ -220,6 +232,7 @@ func (q *Queries) GetSubmissionById(ctx context.Context, id pgtype.UUID) (GetSub
|
||||
const getSubmissionsByIDs = `-- name: GetSubmissionsByIDs :many
|
||||
SELECT
|
||||
s.id, s.project_id, s.commit_id, s.user_id, s.created_at, s.status, s.reviewed_by, s.reviewed_at, s.review_note, s.content, s.is_deleted,
|
||||
p.title AS project_title, p.description AS project_description,
|
||||
json_build_object(
|
||||
'id', u.id,
|
||||
'email', u.email,
|
||||
@@ -237,6 +250,7 @@ SELECT
|
||||
)::json
|
||||
ELSE NULL::json END AS reviewer
|
||||
FROM submissions s
|
||||
JOIN projects p ON s.project_id = p.id
|
||||
JOIN users u ON s.user_id = u.id
|
||||
LEFT JOIN user_profiles up ON u.id = up.user_id
|
||||
LEFT JOIN users ru ON s.reviewed_by = ru.id
|
||||
@@ -245,19 +259,21 @@ WHERE s.id = ANY($1::uuid[]) AND s.is_deleted = false
|
||||
`
|
||||
|
||||
type GetSubmissionsByIDsRow struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
CommitID pgtype.UUID `json:"commit_id"`
|
||||
UserID pgtype.UUID `json:"user_id"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
Status int16 `json:"status"`
|
||||
ReviewedBy pgtype.UUID `json:"reviewed_by"`
|
||||
ReviewedAt pgtype.Timestamptz `json:"reviewed_at"`
|
||||
ReviewNote pgtype.Text `json:"review_note"`
|
||||
Content pgtype.Text `json:"content"`
|
||||
IsDeleted bool `json:"is_deleted"`
|
||||
User []byte `json:"user"`
|
||||
Reviewer []byte `json:"reviewer"`
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
CommitID pgtype.UUID `json:"commit_id"`
|
||||
UserID pgtype.UUID `json:"user_id"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
Status int16 `json:"status"`
|
||||
ReviewedBy pgtype.UUID `json:"reviewed_by"`
|
||||
ReviewedAt pgtype.Timestamptz `json:"reviewed_at"`
|
||||
ReviewNote pgtype.Text `json:"review_note"`
|
||||
Content pgtype.Text `json:"content"`
|
||||
IsDeleted bool `json:"is_deleted"`
|
||||
ProjectTitle string `json:"project_title"`
|
||||
ProjectDescription pgtype.Text `json:"project_description"`
|
||||
User []byte `json:"user"`
|
||||
Reviewer []byte `json:"reviewer"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetSubmissionsByIDs(ctx context.Context, dollar_1 []pgtype.UUID) ([]GetSubmissionsByIDsRow, error) {
|
||||
@@ -281,6 +297,8 @@ func (q *Queries) GetSubmissionsByIDs(ctx context.Context, dollar_1 []pgtype.UUI
|
||||
&i.ReviewNote,
|
||||
&i.Content,
|
||||
&i.IsDeleted,
|
||||
&i.ProjectTitle,
|
||||
&i.ProjectDescription,
|
||||
&i.User,
|
||||
&i.Reviewer,
|
||||
); err != nil {
|
||||
@@ -297,6 +315,7 @@ func (q *Queries) GetSubmissionsByIDs(ctx context.Context, dollar_1 []pgtype.UUI
|
||||
const searchSubmissions = `-- name: SearchSubmissions :many
|
||||
SELECT
|
||||
s.id, s.project_id, s.commit_id, s.user_id, s.created_at, s.status, s.reviewed_by, s.reviewed_at, s.review_note, s.content, s.is_deleted,
|
||||
p.title AS project_title, p.description AS project_description,
|
||||
json_build_object(
|
||||
'id', u.id,
|
||||
'email', u.email,
|
||||
@@ -314,6 +333,7 @@ SELECT
|
||||
)::json
|
||||
ELSE NULL::json END AS reviewer
|
||||
FROM submissions s
|
||||
JOIN projects p ON s.project_id = p.id
|
||||
JOIN users u ON s.user_id = u.id
|
||||
LEFT JOIN user_profiles up ON u.id = up.user_id
|
||||
LEFT JOIN users ru ON s.reviewed_by = ru.id
|
||||
@@ -361,19 +381,21 @@ type SearchSubmissionsParams struct {
|
||||
}
|
||||
|
||||
type SearchSubmissionsRow struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
CommitID pgtype.UUID `json:"commit_id"`
|
||||
UserID pgtype.UUID `json:"user_id"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
Status int16 `json:"status"`
|
||||
ReviewedBy pgtype.UUID `json:"reviewed_by"`
|
||||
ReviewedAt pgtype.Timestamptz `json:"reviewed_at"`
|
||||
ReviewNote pgtype.Text `json:"review_note"`
|
||||
Content pgtype.Text `json:"content"`
|
||||
IsDeleted bool `json:"is_deleted"`
|
||||
User []byte `json:"user"`
|
||||
Reviewer []byte `json:"reviewer"`
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
CommitID pgtype.UUID `json:"commit_id"`
|
||||
UserID pgtype.UUID `json:"user_id"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
Status int16 `json:"status"`
|
||||
ReviewedBy pgtype.UUID `json:"reviewed_by"`
|
||||
ReviewedAt pgtype.Timestamptz `json:"reviewed_at"`
|
||||
ReviewNote pgtype.Text `json:"review_note"`
|
||||
Content pgtype.Text `json:"content"`
|
||||
IsDeleted bool `json:"is_deleted"`
|
||||
ProjectTitle string `json:"project_title"`
|
||||
ProjectDescription pgtype.Text `json:"project_description"`
|
||||
User []byte `json:"user"`
|
||||
Reviewer []byte `json:"reviewer"`
|
||||
}
|
||||
|
||||
func (q *Queries) SearchSubmissions(ctx context.Context, arg SearchSubmissionsParams) ([]SearchSubmissionsRow, error) {
|
||||
@@ -409,6 +431,8 @@ func (q *Queries) SearchSubmissions(ctx context.Context, arg SearchSubmissionsPa
|
||||
&i.ReviewNote,
|
||||
&i.Content,
|
||||
&i.IsDeleted,
|
||||
&i.ProjectTitle,
|
||||
&i.ProjectDescription,
|
||||
&i.User,
|
||||
&i.Reviewer,
|
||||
); err != nil {
|
||||
@@ -429,14 +453,16 @@ SET
|
||||
reviewed_by = COALESCE($2, reviewed_by),
|
||||
review_note = COALESCE($3, review_note),
|
||||
content = COALESCE($4, content)
|
||||
FROM users u
|
||||
FROM projects p, users u
|
||||
LEFT JOIN user_profiles up ON u.id = up.user_id
|
||||
LEFT JOIN users ru ON submissions.reviewed_by = ru.id
|
||||
LEFT JOIN user_profiles rup ON ru.id = rup.user_id
|
||||
WHERE submissions.id = $5
|
||||
AND submissions.project_id = p.id
|
||||
AND submissions.user_id = u.id
|
||||
RETURNING
|
||||
submissions.id, submissions.project_id, submissions.commit_id, submissions.user_id, submissions.created_at, submissions.status, submissions.reviewed_by, submissions.reviewed_at, submissions.review_note, submissions.content, submissions.is_deleted,
|
||||
p.title AS project_title, p.description AS project_description,
|
||||
json_build_object(
|
||||
'id', u.id,
|
||||
'email', u.email,
|
||||
@@ -464,19 +490,21 @@ type UpdateSubmissionParams struct {
|
||||
}
|
||||
|
||||
type UpdateSubmissionRow struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
CommitID pgtype.UUID `json:"commit_id"`
|
||||
UserID pgtype.UUID `json:"user_id"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
Status int16 `json:"status"`
|
||||
ReviewedBy pgtype.UUID `json:"reviewed_by"`
|
||||
ReviewedAt pgtype.Timestamptz `json:"reviewed_at"`
|
||||
ReviewNote pgtype.Text `json:"review_note"`
|
||||
Content pgtype.Text `json:"content"`
|
||||
IsDeleted bool `json:"is_deleted"`
|
||||
User []byte `json:"user"`
|
||||
Reviewer []byte `json:"reviewer"`
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
CommitID pgtype.UUID `json:"commit_id"`
|
||||
UserID pgtype.UUID `json:"user_id"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
Status int16 `json:"status"`
|
||||
ReviewedBy pgtype.UUID `json:"reviewed_by"`
|
||||
ReviewedAt pgtype.Timestamptz `json:"reviewed_at"`
|
||||
ReviewNote pgtype.Text `json:"review_note"`
|
||||
Content pgtype.Text `json:"content"`
|
||||
IsDeleted bool `json:"is_deleted"`
|
||||
ProjectTitle string `json:"project_title"`
|
||||
ProjectDescription pgtype.Text `json:"project_description"`
|
||||
User []byte `json:"user"`
|
||||
Reviewer []byte `json:"reviewer"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateSubmission(ctx context.Context, arg UpdateSubmissionParams) (UpdateSubmissionRow, error) {
|
||||
@@ -500,6 +528,8 @@ func (q *Queries) UpdateSubmission(ctx context.Context, arg UpdateSubmissionPara
|
||||
&i.ReviewNote,
|
||||
&i.Content,
|
||||
&i.IsDeleted,
|
||||
&i.ProjectTitle,
|
||||
&i.ProjectDescription,
|
||||
&i.User,
|
||||
&i.Reviewer,
|
||||
)
|
||||
|
||||
@@ -8,19 +8,21 @@ import (
|
||||
)
|
||||
|
||||
type SubmissionEntity struct {
|
||||
ID string `json:"id"`
|
||||
ProjectID string `json:"project_id"`
|
||||
CommitID string `json:"commit_id"`
|
||||
UserID string `json:"user_id"`
|
||||
CreatedAt *time.Time `json:"created_at"`
|
||||
Status constants.StatusType `json:"status"`
|
||||
ReviewedBy *string `json:"reviewed_by"`
|
||||
ReviewedAt *time.Time `json:"reviewed_at"`
|
||||
ReviewNote *string `json:"review_note"`
|
||||
Content *string `json:"content"`
|
||||
IsDeleted bool `json:"is_deleted"`
|
||||
User *UserSimpleEntity `json:"user"`
|
||||
Reviewer *UserSimpleEntity `json:"reviewer"`
|
||||
ID string `json:"id"`
|
||||
ProjectID string `json:"project_id"`
|
||||
CommitID string `json:"commit_id"`
|
||||
UserID string `json:"user_id"`
|
||||
CreatedAt *time.Time `json:"created_at"`
|
||||
Status constants.StatusType `json:"status"`
|
||||
ReviewedBy *string `json:"reviewed_by"`
|
||||
ReviewedAt *time.Time `json:"reviewed_at"`
|
||||
ReviewNote *string `json:"review_note"`
|
||||
Content *string `json:"content"`
|
||||
IsDeleted bool `json:"is_deleted"`
|
||||
ProjectTitle string `json:"project_title"`
|
||||
ProjectDescription *string `json:"project_description"`
|
||||
User *UserSimpleEntity `json:"user"`
|
||||
Reviewer *UserSimpleEntity `json:"reviewer"`
|
||||
}
|
||||
|
||||
func (s *SubmissionEntity) ParseUser(data []byte) error {
|
||||
@@ -45,18 +47,20 @@ func (s *SubmissionEntity) ToResponse() *response.SubmissionResponse {
|
||||
}
|
||||
|
||||
return &response.SubmissionResponse{
|
||||
ID: s.ID,
|
||||
ProjectID: s.ProjectID,
|
||||
CommitID: s.CommitID,
|
||||
UserID: s.UserID,
|
||||
CreatedAt: s.CreatedAt,
|
||||
Status: s.Status.String(),
|
||||
ReviewedBy: s.ReviewedBy,
|
||||
ReviewedAt: s.ReviewedAt,
|
||||
ReviewNote: s.ReviewNote,
|
||||
Content: s.Content,
|
||||
User: s.User.ToResponse(),
|
||||
Reviewer: s.Reviewer.ToResponse(),
|
||||
ID: s.ID,
|
||||
ProjectID: s.ProjectID,
|
||||
CommitID: s.CommitID,
|
||||
UserID: s.UserID,
|
||||
CreatedAt: s.CreatedAt,
|
||||
Status: s.Status.String(),
|
||||
ReviewedBy: s.ReviewedBy,
|
||||
ReviewedAt: s.ReviewedAt,
|
||||
ReviewNote: s.ReviewNote,
|
||||
Content: s.Content,
|
||||
ProjectTitle: s.ProjectTitle,
|
||||
ProjectDescription: s.ProjectDescription,
|
||||
User: s.User.ToResponse(),
|
||||
Reviewer: s.Reviewer.ToResponse(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,17 +58,19 @@ func (r *submissionRepository) GetByID(ctx context.Context, id pgtype.UUID) (*mo
|
||||
return nil, err
|
||||
}
|
||||
entity := &models.SubmissionEntity{
|
||||
ID: convert.UUIDToString(row.ID),
|
||||
ProjectID: convert.UUIDToString(row.ProjectID),
|
||||
CommitID: convert.UUIDToString(row.CommitID),
|
||||
UserID: convert.UUIDToString(row.UserID),
|
||||
CreatedAt: convert.TimeToPtr(row.CreatedAt),
|
||||
Status: constants.ParseStatusType(row.Status),
|
||||
ReviewedBy: convert.UUIDToStringPtr(row.ReviewedBy),
|
||||
ReviewedAt: convert.TimeToPtr(row.ReviewedAt),
|
||||
ReviewNote: convert.TextToPtr(row.ReviewNote),
|
||||
Content: convert.TextToPtr(row.Content),
|
||||
IsDeleted: row.IsDeleted,
|
||||
ID: convert.UUIDToString(row.ID),
|
||||
ProjectID: convert.UUIDToString(row.ProjectID),
|
||||
CommitID: convert.UUIDToString(row.CommitID),
|
||||
UserID: convert.UUIDToString(row.UserID),
|
||||
CreatedAt: convert.TimeToPtr(row.CreatedAt),
|
||||
Status: constants.ParseStatusType(row.Status),
|
||||
ReviewedBy: convert.UUIDToStringPtr(row.ReviewedBy),
|
||||
ReviewedAt: convert.TimeToPtr(row.ReviewedAt),
|
||||
ReviewNote: convert.TextToPtr(row.ReviewNote),
|
||||
Content: convert.TextToPtr(row.Content),
|
||||
IsDeleted: row.IsDeleted,
|
||||
ProjectTitle: row.ProjectTitle,
|
||||
ProjectDescription: convert.TextToPtr(row.ProjectDescription),
|
||||
}
|
||||
_ = entity.ParseUser(row.User)
|
||||
_ = entity.ParseReviewer(row.Reviewer)
|
||||
@@ -113,17 +115,19 @@ func (r *submissionRepository) getByIDsWithFallback(ctx context.Context, ids []s
|
||||
if err == nil {
|
||||
for _, row := range dbRows {
|
||||
entity := &models.SubmissionEntity{
|
||||
ID: convert.UUIDToString(row.ID),
|
||||
ProjectID: convert.UUIDToString(row.ProjectID),
|
||||
CommitID: convert.UUIDToString(row.CommitID),
|
||||
UserID: convert.UUIDToString(row.UserID),
|
||||
CreatedAt: convert.TimeToPtr(row.CreatedAt),
|
||||
Status: constants.ParseStatusType(row.Status),
|
||||
ReviewedBy: convert.UUIDToStringPtr(row.ReviewedBy),
|
||||
ReviewedAt: convert.TimeToPtr(row.ReviewedAt),
|
||||
ReviewNote: convert.TextToPtr(row.ReviewNote),
|
||||
Content: convert.TextToPtr(row.Content),
|
||||
IsDeleted: row.IsDeleted,
|
||||
ID: convert.UUIDToString(row.ID),
|
||||
ProjectID: convert.UUIDToString(row.ProjectID),
|
||||
CommitID: convert.UUIDToString(row.CommitID),
|
||||
UserID: convert.UUIDToString(row.UserID),
|
||||
CreatedAt: convert.TimeToPtr(row.CreatedAt),
|
||||
Status: constants.ParseStatusType(row.Status),
|
||||
ReviewedBy: convert.UUIDToStringPtr(row.ReviewedBy),
|
||||
ReviewedAt: convert.TimeToPtr(row.ReviewedAt),
|
||||
ReviewNote: convert.TextToPtr(row.ReviewNote),
|
||||
Content: convert.TextToPtr(row.Content),
|
||||
IsDeleted: row.IsDeleted,
|
||||
ProjectTitle: row.ProjectTitle,
|
||||
ProjectDescription: convert.TextToPtr(row.ProjectDescription),
|
||||
}
|
||||
_ = entity.ParseUser(row.User)
|
||||
_ = entity.ParseReviewer(row.Reviewer)
|
||||
@@ -183,17 +187,19 @@ func (r *submissionRepository) Search(ctx context.Context, params sqlc.SearchSub
|
||||
|
||||
for _, row := range rows {
|
||||
entity := &models.SubmissionEntity{
|
||||
ID: convert.UUIDToString(row.ID),
|
||||
ProjectID: convert.UUIDToString(row.ProjectID),
|
||||
CommitID: convert.UUIDToString(row.CommitID),
|
||||
UserID: convert.UUIDToString(row.UserID),
|
||||
CreatedAt: convert.TimeToPtr(row.CreatedAt),
|
||||
Status: constants.ParseStatusType(row.Status),
|
||||
ReviewedBy: convert.UUIDToStringPtr(row.ReviewedBy),
|
||||
ReviewedAt: convert.TimeToPtr(row.ReviewedAt),
|
||||
ReviewNote: convert.TextToPtr(row.ReviewNote),
|
||||
Content: convert.TextToPtr(row.Content),
|
||||
IsDeleted: row.IsDeleted,
|
||||
ID: convert.UUIDToString(row.ID),
|
||||
ProjectID: convert.UUIDToString(row.ProjectID),
|
||||
CommitID: convert.UUIDToString(row.CommitID),
|
||||
UserID: convert.UUIDToString(row.UserID),
|
||||
CreatedAt: convert.TimeToPtr(row.CreatedAt),
|
||||
Status: constants.ParseStatusType(row.Status),
|
||||
ReviewedBy: convert.UUIDToStringPtr(row.ReviewedBy),
|
||||
ReviewedAt: convert.TimeToPtr(row.ReviewedAt),
|
||||
ReviewNote: convert.TextToPtr(row.ReviewNote),
|
||||
Content: convert.TextToPtr(row.Content),
|
||||
IsDeleted: row.IsDeleted,
|
||||
ProjectTitle: row.ProjectTitle,
|
||||
ProjectDescription: convert.TextToPtr(row.ProjectDescription),
|
||||
}
|
||||
_ = entity.ParseUser(row.User)
|
||||
_ = entity.ParseReviewer(row.Reviewer)
|
||||
@@ -236,17 +242,19 @@ func (r *submissionRepository) Create(ctx context.Context, params sqlc.CreateSub
|
||||
return nil, err
|
||||
}
|
||||
submission := models.SubmissionEntity{
|
||||
ID: convert.UUIDToString(row.ID),
|
||||
ProjectID: convert.UUIDToString(row.ProjectID),
|
||||
CommitID: convert.UUIDToString(row.CommitID),
|
||||
UserID: convert.UUIDToString(row.UserID),
|
||||
CreatedAt: convert.TimeToPtr(row.CreatedAt),
|
||||
Status: constants.ParseStatusType(row.Status),
|
||||
ReviewedBy: convert.UUIDToStringPtr(row.ReviewedBy),
|
||||
ReviewedAt: convert.TimeToPtr(row.ReviewedAt),
|
||||
ReviewNote: convert.TextToPtr(row.ReviewNote),
|
||||
Content: convert.TextToPtr(row.Content),
|
||||
IsDeleted: row.IsDeleted,
|
||||
ID: convert.UUIDToString(row.ID),
|
||||
ProjectID: convert.UUIDToString(row.ProjectID),
|
||||
CommitID: convert.UUIDToString(row.CommitID),
|
||||
UserID: convert.UUIDToString(row.UserID),
|
||||
CreatedAt: convert.TimeToPtr(row.CreatedAt),
|
||||
Status: constants.ParseStatusType(row.Status),
|
||||
ReviewedBy: convert.UUIDToStringPtr(row.ReviewedBy),
|
||||
ReviewedAt: convert.TimeToPtr(row.ReviewedAt),
|
||||
ReviewNote: convert.TextToPtr(row.ReviewNote),
|
||||
Content: convert.TextToPtr(row.Content),
|
||||
IsDeleted: row.IsDeleted,
|
||||
ProjectTitle: row.ProjectTitle,
|
||||
ProjectDescription: convert.TextToPtr(row.ProjectDescription),
|
||||
}
|
||||
|
||||
if err := submission.ParseUser(row.User); err != nil {
|
||||
@@ -273,17 +281,19 @@ func (r *submissionRepository) Update(ctx context.Context, params sqlc.UpdateSub
|
||||
}
|
||||
|
||||
submission := models.SubmissionEntity{
|
||||
ID: convert.UUIDToString(row.ID),
|
||||
ProjectID: convert.UUIDToString(row.ProjectID),
|
||||
CommitID: convert.UUIDToString(row.CommitID),
|
||||
UserID: convert.UUIDToString(row.UserID),
|
||||
CreatedAt: convert.TimeToPtr(row.CreatedAt),
|
||||
Status: constants.ParseStatusType(row.Status),
|
||||
ReviewedBy: convert.UUIDToStringPtr(row.ReviewedBy),
|
||||
ReviewedAt: convert.TimeToPtr(row.ReviewedAt),
|
||||
ReviewNote: convert.TextToPtr(row.ReviewNote),
|
||||
Content: convert.TextToPtr(row.Content),
|
||||
IsDeleted: row.IsDeleted,
|
||||
ID: convert.UUIDToString(row.ID),
|
||||
ProjectID: convert.UUIDToString(row.ProjectID),
|
||||
CommitID: convert.UUIDToString(row.CommitID),
|
||||
UserID: convert.UUIDToString(row.UserID),
|
||||
CreatedAt: convert.TimeToPtr(row.CreatedAt),
|
||||
Status: constants.ParseStatusType(row.Status),
|
||||
ReviewedBy: convert.UUIDToStringPtr(row.ReviewedBy),
|
||||
ReviewedAt: convert.TimeToPtr(row.ReviewedAt),
|
||||
ReviewNote: convert.TextToPtr(row.ReviewNote),
|
||||
Content: convert.TextToPtr(row.Content),
|
||||
IsDeleted: row.IsDeleted,
|
||||
ProjectTitle: row.ProjectTitle,
|
||||
ProjectDescription: convert.TextToPtr(row.ProjectDescription),
|
||||
}
|
||||
|
||||
if err := submission.ParseUser(row.User); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user