mirror of
https://github.com/go-gitea/gitea
synced 2025-12-07 13:28:25 +00:00
api(refactor): create a common handler for org and repo projects
edit project api response format to include more fields
This commit is contained in:
+13
-13
@@ -12,25 +12,25 @@ import (
|
||||
|
||||
// ToProject converts a models.Project to api.Project
|
||||
func ToProject(ctx context.Context, project *project_model.Project) *api.Project {
|
||||
if project == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &api.Project{
|
||||
ID: project.ID,
|
||||
Title: project.Title,
|
||||
Description: project.Description,
|
||||
TemplateType: uint8(project.TemplateType),
|
||||
CardType: uint8(project.CardType),
|
||||
ID: project.ID,
|
||||
Title: project.Title,
|
||||
Description: project.Description,
|
||||
TemplateType: uint8(project.TemplateType),
|
||||
CardType: uint8(project.CardType),
|
||||
OwnerID: project.OwnerID,
|
||||
RepoID: project.RepoID,
|
||||
CreatorID: project.CreatorID,
|
||||
IsClosed: project.IsClosed,
|
||||
Type: uint8(project.Type),
|
||||
CreatedUnix: int64(project.CreatedUnix),
|
||||
UpdatedUnix: int64(project.UpdatedUnix),
|
||||
ClosedDateUnix: int64(project.ClosedDateUnix),
|
||||
}
|
||||
}
|
||||
|
||||
// ToProjects converts a slice of models.Project to a slice of api.Project
|
||||
func ToProjects(ctx context.Context, projects []*project_model.Project) []*api.Project {
|
||||
if projects == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
result := make([]*api.Project, len(projects))
|
||||
for i, project := range projects {
|
||||
result[i] = ToProject(ctx, project)
|
||||
|
||||
Reference in New Issue
Block a user