Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Respect user query parameter in GET /issue

天舟035ff5035332
diff --git a/backend/api/issue.go b/backend/api/issue.go
index 765a6d4c8e..7f519c1ad3 100644
--- a/backend/api/issue.go
+++ b/backend/api/issue.go
@@ -114,6 +114,11 @@ type IssueFind struct {
// Related fields
ProjectId *int
+
+ // Domain specific fields
+ // Find issue where principalId is either creator or assignee
+ // TODO: Add subscriber support
+ PrincipalId *int
}
type IssuePatch struct {
diff --git a/backend/server/issue.go b/backend/server/issue.go
index c114f18bb3..06593691b8 100644
--- a/backend/server/issue.go
+++ b/backend/server/issue.go
@@ -78,6 +78,14 @@ func (s *Server) registerIssueRoutes(g *echo.Group) {
}
issueFind.ProjectId = &projectId
}
+ userIdStr := c.QueryParams().Get("user")
+ if userIdStr != "" {
+ userId, err := strconv.Atoi(userIdStr)
+ if err != nil {
+ return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("user query parameter is not a number: %s", userIdStr)).SetInternal(err)
+ }
+ issueFind.PrincipalId = &userId
+ }
list, err := s.IssueService.FindIssueList(context.Background(), issueFind)
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to fetch issue list").SetInternal(err)
diff --git a/backend/store/issue.go b/backend/store/issue.go
index 92a7fe9900..d083fb51bd 100644
--- a/backend/store/issue.go
+++ b/backend/store/issue.go
@@ -214,6 +214,11 @@ func (s *IssueService) findIssueList(ctx context.Context, tx *Tx, find *api.Issu
if v := find.ProjectId; v != nil {
where, args = append(where, "project_id = ?"), append(args, *v)
}
+ if v := find.PrincipalId; v != nil {
+ where = append(where, "(creator_id = ? OR assignee_id = ?)")
+ args = append(args, *v)
+ args = append(args, *v)
+ }
rows, err := tx.QueryContext(ctx, `
SELECT