This commit is contained in:
2026-06-22 08:55:57 +08:00
parent dbb87823e8
commit 6ade6e8fa9
325 changed files with 41131 additions and 855 deletions
+70
View File
@@ -0,0 +1,70 @@
// dto.go defines the HTTP request/response shapes for the change-request module.
package changerequest
import (
"time"
"github.com/google/uuid"
)
// ===== request DTO =====
type createReq struct {
SourceBranch string `json:"source_branch"`
TargetBranch string `json:"target_branch"`
Title string `json:"title"`
Description string `json:"description"`
RequirementID *uuid.UUID `json:"requirement_id"`
IssueID *uuid.UUID `json:"issue_id"`
}
type reviewReq struct {
Verdict string `json:"verdict"`
Note string `json:"note"`
}
type mergeReq struct {
Method string `json:"method"`
}
// ===== response DTO =====
type changeRequestResp struct {
ID uuid.UUID `json:"id"`
ProjectID uuid.UUID `json:"project_id"`
WorkspaceID uuid.UUID `json:"workspace_id"`
RequirementID *uuid.UUID `json:"requirement_id"`
IssueID *uuid.UUID `json:"issue_id"`
Number int `json:"number"`
Title string `json:"title"`
Description string `json:"description"`
SourceBranch string `json:"source_branch"`
TargetBranch string `json:"target_branch"`
State string `json:"state"`
ReviewVerdict string `json:"review_verdict"`
CIState string `json:"ci_state"`
Provider string `json:"provider"`
ExternalID *int64 `json:"external_id"`
ExternalURL string `json:"external_url"`
MergeCommitSHA string `json:"merge_commit_sha"`
ReviewedBy *uuid.UUID `json:"reviewed_by"`
ReviewedAt *time.Time `json:"reviewed_at"`
CreatedBy uuid.UUID `json:"created_by"`
MergedAt *time.Time `json:"merged_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func toResp(cr *ChangeRequest) changeRequestResp {
return changeRequestResp{
ID: cr.ID, ProjectID: cr.ProjectID, WorkspaceID: cr.WorkspaceID,
RequirementID: cr.RequirementID, IssueID: cr.IssueID, Number: cr.Number,
Title: cr.Title, Description: cr.Description,
SourceBranch: cr.SourceBranch, TargetBranch: cr.TargetBranch,
State: string(cr.State), ReviewVerdict: string(cr.ReviewVerdict),
CIState: string(cr.CIState), Provider: cr.Provider,
ExternalID: cr.ExternalID, ExternalURL: cr.ExternalURL, MergeCommitSHA: cr.MergeCommitSHA,
ReviewedBy: cr.ReviewedBy, ReviewedAt: cr.ReviewedAt, CreatedBy: cr.CreatedBy,
MergedAt: cr.MergedAt, CreatedAt: cr.CreatedAt, UpdatedAt: cr.UpdatedAt,
}
}