Add AgentBoard project board card API
Some checks failed
cron-lock / action (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled
cron-translations / crowdin-push (push) Has been cancelled

This commit is contained in:
Mikhail Kilin
2026-05-28 17:39:06 +03:00
parent 2ebe4f0514
commit ee3b2ac09d
3 changed files with 77 additions and 0 deletions

View File

@@ -1563,6 +1563,7 @@ func Routes() *web.Route {
m.Combo("/boards"). m.Combo("/boards").
Get(projects.ListProjectBoards). Get(projects.ListProjectBoards).
Post(bind(api.NewProjectBoardPayload{}), projects.CreateProjectBoard) Post(bind(api.NewProjectBoardPayload{}), projects.CreateProjectBoard)
m.Get("/boards/{boardId}/cards", projects.ListProjectBoardCards)
}) })
m.Group("/boards", func() { m.Group("/boards", func() {

View File

@@ -6,6 +6,7 @@ package projects
import ( import (
"net/http" "net/http"
issues_model "code.gitea.io/gitea/models/issues"
project_model "code.gitea.io/gitea/models/project" project_model "code.gitea.io/gitea/models/project"
"code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/setting"
@@ -69,6 +70,80 @@ func ListProjectBoards(ctx *context.APIContext) {
} }
// ProjectBoardCard represents an issue card on a project board.
type ProjectBoardCard struct {
ID int64 `json:"id"`
Issue *api.Issue `json:"issue,omitempty"`
}
func ListProjectBoardCards(ctx *context.APIContext) {
// swagger:operation GET /projects/{projectId}/boards/{boardId}/cards board boardGetProjectBoardCards
// ---
// summary: Get project board cards
// produces:
// - application/json
// parameters:
// - name: projectId
// in: path
// description: id of the project
// type: string
// required: true
// - name: boardId
// in: path
// description: id of the board
// type: string
// required: true
// responses:
// "200":
// "description": "Project board cards"
// "403":
// "$ref": "#/responses/forbidden"
// "404":
// "$ref": "#/responses/notFound"
projectID := ctx.ParamsInt64(":projectId")
project, err := project_model.GetProjectByID(ctx, projectID)
if err != nil {
ctx.Error(http.StatusNotFound, "ListProjectBoardCards", err)
return
}
boardID := ctx.ParamsInt64(":boardId")
var board *project_model.Board
if boardID == 0 {
board = &project_model.Board{
ID: 0,
ProjectID: project.ID,
Default: true,
Title: "Uncategorized",
}
} else {
board, err = project_model.GetBoard(ctx, boardID)
if err != nil {
ctx.Error(http.StatusNotFound, "GetProjectBoard", err)
return
}
if board.ProjectID != project.ID {
ctx.NotFound("BoardNotInProject", nil)
return
}
}
issues, err := issues_model.LoadIssuesFromBoard(ctx, board)
if err != nil {
ctx.InternalServerError(err)
return
}
cards := make([]*ProjectBoardCard, 0, len(issues))
for _, issue := range issues {
cards = append(cards, &ProjectBoardCard{
ID: issue.ID,
Issue: convert.ToAPIIssue(ctx, issue),
})
}
ctx.JSON(http.StatusOK, cards)
}
func CreateProjectBoard(ctx *context.APIContext) { func CreateProjectBoard(ctx *context.APIContext) {
// swagger:operation POST /projects/{projectId}/boards board boardCreateProjectBoard // swagger:operation POST /projects/{projectId}/boards board boardCreateProjectBoard
// --- // ---

View File

@@ -36,6 +36,7 @@ func ToApiProjectBoardList(
func ToAPIProject(ctx context.Context, project *project_model.Project) *api.Project { func ToAPIProject(ctx context.Context, project *project_model.Project) *api.Project {
apiProject := &api.Project{ apiProject := &api.Project{
ID: project.ID,
Title: project.Title, Title: project.Title,
Description: project.Description, Description: project.Description,
BoardType: uint8(project.BoardType), BoardType: uint8(project.BoardType),