0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-06-11 16:17:47 +02:00
gitea/modules/structs/project.go
silverwind 438f367ab3
Simplify
- Drop lazy LoadRepo/LoadOwner in convert.ToProject; rely on caller
  preloading. ListProjects sets Repo from ctx.Repo.Repository on each
  project; CreateProject does the same on the new project. Avoids
  N+1 queries for repo-scoped list endpoints.
- Strip redundant API struct field comments that just restate the
  field name; keep the ones that document enum values.
- Pre-allocate GetColumnsByIDs result slice with len(columnsIDs).
- Fix CountProjectColumns doc comment (was "CountColumns").

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
2026-05-03 14:32:38 +05:30

95 lines
3.0 KiB
Go

// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package structs
import (
"time"
)
// Project represents a project
// swagger:model
type Project struct {
ID int64 `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
OwnerID int64 `json:"owner_id,omitempty"`
RepoID int64 `json:"repo_id,omitempty"`
CreatorID int64 `json:"creator_id"`
IsClosed bool `json:"is_closed"`
// Template type: 0=none, 1=basic_kanban, 2=bug_triage
TemplateType int `json:"template_type"`
// Card type: 0=text_only, 1=images_and_text
CardType int `json:"card_type"`
// Project type: 1=individual, 2=repository, 3=organization
Type int `json:"type"`
NumOpenIssues int64 `json:"num_open_issues,omitempty"`
NumClosedIssues int64 `json:"num_closed_issues,omitempty"`
NumIssues int64 `json:"num_issues,omitempty"`
// swagger:strfmt date-time
Created time.Time `json:"created"`
// swagger:strfmt date-time
Updated time.Time `json:"updated"`
// swagger:strfmt date-time
ClosedDate *time.Time `json:"closed_date,omitempty"`
URL string `json:"url,omitempty"`
}
// CreateProjectOption represents options for creating a project
// swagger:model
type CreateProjectOption struct {
// required: true
Title string `json:"title" binding:"Required"`
Description string `json:"description"`
// Template type: 0=none, 1=basic_kanban, 2=bug_triage
TemplateType int `json:"template_type"`
// Card type: 0=text_only, 1=images_and_text
CardType int `json:"card_type"`
}
// EditProjectOption represents options for editing a project
// swagger:model
type EditProjectOption struct {
Title *string `json:"title,omitempty"`
Description *string `json:"description,omitempty"`
// Card type: 0=text_only, 1=images_and_text
CardType *int `json:"card_type,omitempty"`
// State of the project (open or closed)
State *string `json:"state,omitempty"`
}
// ProjectColumn represents a project column (board)
// swagger:model
type ProjectColumn struct {
ID int64 `json:"id"`
Title string `json:"title"`
Default bool `json:"default"`
Sorting int `json:"sorting"`
Color string `json:"color,omitempty"`
ProjectID int64 `json:"project_id"`
CreatorID int64 `json:"creator_id"`
NumIssues int64 `json:"num_issues,omitempty"`
// swagger:strfmt date-time
Created time.Time `json:"created"`
// swagger:strfmt date-time
Updated time.Time `json:"updated"`
}
// CreateProjectColumnOption represents options for creating a project column
// swagger:model
type CreateProjectColumnOption struct {
// required: true
Title string `json:"title" binding:"Required"`
// Column color (hex format, e.g. #FF0000)
Color string `json:"color,omitempty"`
}
// EditProjectColumnOption represents options for editing a project column
// swagger:model
type EditProjectColumnOption struct {
Title *string `json:"title,omitempty"`
// Column color (hex format)
Color *string `json:"color,omitempty"`
Sorting *int `json:"sorting,omitempty"`
}