Skip to content

Commit

Permalink
feat: Unify the response body of the API interface (#7761)
Browse files Browse the repository at this point in the history
  • Loading branch information
lan-yonghui authored Jan 23, 2025
1 parent 2c31ffc commit 4f57dfc
Show file tree
Hide file tree
Showing 9 changed files with 356 additions and 91 deletions.
5 changes: 4 additions & 1 deletion backend/app/api/v1/app_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ func (b *BaseApi) SearchAppInstalled(c *gin.Context) {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, list)
helper.SuccessWithData(c, dto.PageResult{
Items: list,
Total: int64(len(list)),
})
} else {
total, list, err := appInstallService.Page(req)
if err != nil {
Expand Down
7 changes: 5 additions & 2 deletions backend/app/api/v1/php_extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
// @Summary Page Extensions
// @Accept json
// @Param request body request.PHPExtensionsSearch true "request"
// @Success 200 {array} response.PHPExtensionsDTO
// @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /runtimes/php/extensions/search [post]
Expand All @@ -27,7 +27,10 @@ func (b *BaseApi) PagePHPExtensions(c *gin.Context) {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, list)
helper.SuccessWithData(c, dto.PageResult{
Total: int64(len(list)),
Items: list,
})
} else {
total, list, err := phpExtensionsService.Page(req)
if err != nil {
Expand Down
160 changes: 129 additions & 31 deletions cmd/server/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10013,10 +10013,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/response.PHPExtensionsDTO"
}
"$ref": "#/definitions/dto.PageResult"
}
}
}
Expand Down Expand Up @@ -15485,6 +15482,59 @@ const docTemplate = `{
}
}
},
"/websites/proxies/del": {
"post": {
"security": [
{
"ApiKeyAuth": []
},
{
"Timestamp": []
}
],
"consumes": [
"application/json"
],
"tags": [
"Website"
],
"summary": "Delete proxy conf",
"parameters": [
{
"description": "request",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/request.WebsiteProxyDel"
}
}
],
"responses": {
"200": {
"description": "OK"
}
},
"x-panel-log": {
"BeforeFunctions": [
{
"db": "websites",
"input_column": "id",
"input_value": "id",
"isList": false,
"output_column": "primary_domain",
"output_value": "domain"
}
],
"bodyKeys": [
"id"
],
"formatEN": "Delete domain [domain] proxy config",
"formatZH": "删除网站 [domain] 反向代理配置",
"paramKeys": []
}
}
},
"/websites/proxies/update": {
"post": {
"security": [
Expand Down Expand Up @@ -16700,6 +16750,9 @@ const docTemplate = `{
"crossVersionUpdate": {
"type": "boolean"
},
"description": {
"$ref": "#/definitions/dto.Locale"
},
"document": {
"type": "string"
},
Expand Down Expand Up @@ -19502,6 +19555,32 @@ const docTemplate = `{
}
}
},
"dto.Locale": {
"type": "object",
"properties": {
"en": {
"type": "string"
},
"ja": {
"type": "string"
},
"ms": {
"type": "string"
},
"pt-br": {
"type": "string"
},
"ru": {
"type": "string"
},
"zh": {
"type": "string"
},
"zh-hant": {
"type": "string"
}
}
},
"dto.LogOption": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -19545,6 +19624,7 @@ const docTemplate = `{
"en",
"tw",
"ja",
"ko",
"ru",
"ms",
"pt-BR"
Expand Down Expand Up @@ -21629,6 +21709,9 @@ const docTemplate = `{
"key": {
"type": "string"
},
"locales": {
"$ref": "#/definitions/dto.Locale"
},
"name": {
"type": "string"
},
Expand Down Expand Up @@ -21918,6 +22001,9 @@ const docTemplate = `{
"crossVersionUpdate": {
"type": "boolean"
},
"description": {
"type": "string"
},
"document": {
"type": "string"
},
Expand Down Expand Up @@ -22142,6 +22228,9 @@ const docTemplate = `{
"sort": {
"type": "integer"
},
"translations": {
"type": "string"
},
"updatedAt": {
"type": "string"
}
Expand Down Expand Up @@ -24432,6 +24521,21 @@ const docTemplate = `{
}
}
},
"request.WebsiteProxyDel": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
}
}
},
"request.WebsiteProxyReq": {
"type": "object",
"required": [
Expand Down Expand Up @@ -24808,6 +24912,9 @@ const docTemplate = `{
"crossVersionUpdate": {
"type": "boolean"
},
"description": {
"type": "string"
},
"document": {
"type": "string"
},
Expand Down Expand Up @@ -24977,6 +25084,9 @@ const docTemplate = `{
"response.AppItem": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"icon": {
"type": "string"
},
Expand All @@ -24998,19 +25108,13 @@ const docTemplate = `{
"resource": {
"type": "string"
},
"shortDescEn": {
"type": "string"
},
"shortDescZh": {
"type": "string"
},
"status": {
"type": "string"
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/model.Tag"
"$ref": "#/definitions/response.TagDTO"
}
},
"type": {
Expand Down Expand Up @@ -25492,26 +25596,6 @@ const docTemplate = `{
}
}
},
"response.PHPExtensionsDTO": {
"type": "object",
"properties": {
"createdAt": {
"type": "string"
},
"extensions": {
"type": "string"
},
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"updatedAt": {
"type": "string"
}
}
},
"response.PackageScripts": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -25638,6 +25722,20 @@ const docTemplate = `{
}
}
},
"response.TagDTO": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"key": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"response.WebsiteAcmeAccountDTO": {
"type": "object",
"properties": {
Expand Down
Loading

0 comments on commit 4f57dfc

Please sign in to comment.