mirror of
https://github.com/go-gitea/gitea.git
synced 2025-08-10 12:14:19 +00:00
improvements
This commit is contained in:
parent
1faa7e82e3
commit
899efca7c4
@ -8,9 +8,9 @@ import (
|
|||||||
|
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
project_model "code.gitea.io/gitea/models/project"
|
project_model "code.gitea.io/gitea/models/project"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
"code.gitea.io/gitea/modules/web"
|
"code.gitea.io/gitea/modules/web"
|
||||||
|
"code.gitea.io/gitea/routers/api/v1/utils"
|
||||||
"code.gitea.io/gitea/services/context"
|
"code.gitea.io/gitea/services/context"
|
||||||
"code.gitea.io/gitea/services/convert"
|
"code.gitea.io/gitea/services/convert"
|
||||||
)
|
)
|
||||||
@ -283,18 +283,20 @@ func ListUserProjects(ctx *context.APIContext) {
|
|||||||
// "$ref": "#/responses/forbidden"
|
// "$ref": "#/responses/forbidden"
|
||||||
// "404":
|
// "404":
|
||||||
// "$ref": "#/responses/notFound"
|
// "$ref": "#/responses/notFound"
|
||||||
|
|
||||||
|
listOptions := utils.GetListOptions(ctx)
|
||||||
projects, count, err := db.FindAndCount[project_model.Project](ctx, project_model.SearchOptions{
|
projects, count, err := db.FindAndCount[project_model.Project](ctx, project_model.SearchOptions{
|
||||||
Type: project_model.TypeIndividual,
|
Type: project_model.TypeIndividual,
|
||||||
IsClosed: ctx.FormOptionalBool("closed"),
|
IsClosed: ctx.FormOptionalBool("closed"),
|
||||||
OwnerID: ctx.Doer.ID,
|
OwnerID: ctx.Doer.ID,
|
||||||
ListOptions: db.ListOptions{Page: ctx.FormInt("page")},
|
ListOptions: listOptions,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.APIErrorInternal(err)
|
ctx.APIErrorInternal(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.SetLinkHeader(int(count), setting.UI.IssuePagingNum)
|
ctx.SetLinkHeader(int(count), listOptions.PageSize)
|
||||||
ctx.SetTotalCountHeader(count)
|
ctx.SetTotalCountHeader(count)
|
||||||
|
|
||||||
apiProjects, err := convert.ToAPIProjectList(ctx, projects)
|
apiProjects, err := convert.ToAPIProjectList(ctx, projects)
|
||||||
@ -337,9 +339,11 @@ func ListOrgProjects(ctx *context.APIContext) {
|
|||||||
// "$ref": "#/responses/forbidden"
|
// "$ref": "#/responses/forbidden"
|
||||||
// "404":
|
// "404":
|
||||||
// "$ref": "#/responses/notFound"
|
// "$ref": "#/responses/notFound"
|
||||||
|
|
||||||
|
listOptions := utils.GetListOptions(ctx)
|
||||||
projects, count, err := db.FindAndCount[project_model.Project](ctx, project_model.SearchOptions{
|
projects, count, err := db.FindAndCount[project_model.Project](ctx, project_model.SearchOptions{
|
||||||
OwnerID: ctx.Org.Organization.AsUser().ID,
|
OwnerID: ctx.Org.Organization.AsUser().ID,
|
||||||
ListOptions: db.ListOptions{Page: ctx.FormInt("page")},
|
ListOptions: listOptions,
|
||||||
IsClosed: ctx.FormOptionalBool("closed"),
|
IsClosed: ctx.FormOptionalBool("closed"),
|
||||||
Type: project_model.TypeOrganization,
|
Type: project_model.TypeOrganization,
|
||||||
})
|
})
|
||||||
@ -348,7 +352,7 @@ func ListOrgProjects(ctx *context.APIContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.SetLinkHeader(int(count), setting.UI.IssuePagingNum)
|
ctx.SetLinkHeader(int(count), listOptions.PageSize)
|
||||||
ctx.SetTotalCountHeader(count)
|
ctx.SetTotalCountHeader(count)
|
||||||
|
|
||||||
apiProjects, err := convert.ToAPIProjectList(ctx, projects)
|
apiProjects, err := convert.ToAPIProjectList(ctx, projects)
|
||||||
@ -397,19 +401,19 @@ func ListRepoProjects(ctx *context.APIContext) {
|
|||||||
// "404":
|
// "404":
|
||||||
// "$ref": "#/responses/notFound"
|
// "$ref": "#/responses/notFound"
|
||||||
|
|
||||||
page := ctx.FormInt("page")
|
listOptions := utils.GetListOptions(ctx)
|
||||||
projects, count, err := db.FindAndCount[project_model.Project](ctx, project_model.SearchOptions{
|
projects, count, err := db.FindAndCount[project_model.Project](ctx, project_model.SearchOptions{
|
||||||
RepoID: ctx.Repo.Repository.ID,
|
RepoID: ctx.Repo.Repository.ID,
|
||||||
IsClosed: ctx.FormOptionalBool("closed"),
|
IsClosed: ctx.FormOptionalBool("closed"),
|
||||||
Type: project_model.TypeRepository,
|
Type: project_model.TypeRepository,
|
||||||
ListOptions: db.ListOptions{Page: page},
|
ListOptions: listOptions,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.APIErrorInternal(err)
|
ctx.APIErrorInternal(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.SetLinkHeader(int(count), page)
|
ctx.SetLinkHeader(int(count), listOptions.PageSize)
|
||||||
ctx.SetTotalCountHeader(count)
|
ctx.SetTotalCountHeader(count)
|
||||||
|
|
||||||
apiProjects, err := convert.ToAPIProjectList(ctx, projects)
|
apiProjects, err := convert.ToAPIProjectList(ctx, projects)
|
||||||
|
29
templates/swagger/v1_json.tmpl
generated
29
templates/swagger/v1_json.tmpl
generated
@ -3385,7 +3385,7 @@
|
|||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/NewProjectPayload"
|
"$ref": "#/definitions/NewProjectOption"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -4308,7 +4308,7 @@
|
|||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/UpdateProjectPayload"
|
"$ref": "#/definitions/UpdateProjectOption"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -13687,7 +13687,7 @@
|
|||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/NewProjectPayload"
|
"$ref": "#/definitions/NewProjectOption"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -20014,7 +20014,7 @@
|
|||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/NewProjectPayload"
|
"$ref": "#/definitions/NewProjectOption"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -26380,7 +26380,8 @@
|
|||||||
},
|
},
|
||||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||||
},
|
},
|
||||||
"NewProjectPayload": {
|
"NewProjectOption": {
|
||||||
|
"description": "NewProjectOption options when creating a new project",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"name",
|
"name",
|
||||||
@ -26391,7 +26392,7 @@
|
|||||||
"body": {
|
"body": {
|
||||||
"description": "Keep compatibility with Github API to use \"body\" instead of \"description\"",
|
"description": "Keep compatibility with Github API to use \"body\" instead of \"description\"",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "Description"
|
"x-go-name": "Body"
|
||||||
},
|
},
|
||||||
"card_type": {
|
"card_type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -26403,7 +26404,7 @@
|
|||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "Title"
|
"x-go-name": "Name"
|
||||||
},
|
},
|
||||||
"template_type": {
|
"template_type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -26990,6 +26991,7 @@
|
|||||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||||
},
|
},
|
||||||
"Project": {
|
"Project": {
|
||||||
|
"description": "Project represents a project",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"template_type"
|
"template_type"
|
||||||
@ -26998,7 +27000,7 @@
|
|||||||
"body": {
|
"body": {
|
||||||
"description": "Keep compatibility with Github API to use \"body\" instead of \"description\"",
|
"description": "Keep compatibility with Github API to use \"body\" instead of \"description\"",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "Description"
|
"x-go-name": "Body"
|
||||||
},
|
},
|
||||||
"closed_at": {
|
"closed_at": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -27021,7 +27023,7 @@
|
|||||||
"name": {
|
"name": {
|
||||||
"description": "Keep compatibility with Github API to use \"name\" instead of \"title\"",
|
"description": "Keep compatibility with Github API to use \"name\" instead of \"title\"",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "Title"
|
"x-go-name": "Name"
|
||||||
},
|
},
|
||||||
"owner": {
|
"owner": {
|
||||||
"$ref": "#/definitions/User"
|
"$ref": "#/definitions/User"
|
||||||
@ -28608,7 +28610,8 @@
|
|||||||
},
|
},
|
||||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||||
},
|
},
|
||||||
"UpdateProjectPayload": {
|
"UpdateProjectOption": {
|
||||||
|
"description": "UpdateProjectOption options when updating a project",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"name"
|
"name"
|
||||||
@ -28617,11 +28620,11 @@
|
|||||||
"body": {
|
"body": {
|
||||||
"description": "Keep compatibility with Github API to use \"body\" instead of \"description\"",
|
"description": "Keep compatibility with Github API to use \"body\" instead of \"description\"",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "Description"
|
"x-go-name": "Body"
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "Title"
|
"x-go-name": "Name"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||||
@ -30172,7 +30175,7 @@
|
|||||||
"parameterBodies": {
|
"parameterBodies": {
|
||||||
"description": "parameterBodies",
|
"description": "parameterBodies",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/UpdateProjectPayload"
|
"$ref": "#/definitions/UpdateProjectOption"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"redirect": {
|
"redirect": {
|
||||||
|
Loading…
Reference in New Issue
Block a user