1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-02-27 18:44:13 +08:00

feat: Unify the response body of the API interface ()

This commit is contained in:
2025-01-23 16:28:04 +08:00 committed by GitHub
parent 2c31ffc66b
commit 4f57dfc76e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 356 additions and 91 deletions
backend/app/api/v1
cmd/server/docs
frontend/src
api/modules
views/website
runtime/php/create
website/create

@ -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 {

@ -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]
@ -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 {

@ -10013,10 +10013,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/response.PHPExtensionsDTO"
}
"$ref": "#/definitions/dto.PageResult"
}
}
}
@ -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": [
@ -16700,6 +16750,9 @@ const docTemplate = `{
"crossVersionUpdate": {
"type": "boolean"
},
"description": {
"$ref": "#/definitions/dto.Locale"
},
"document": {
"type": "string"
},
@ -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": {
@ -19545,6 +19624,7 @@ const docTemplate = `{
"en",
"tw",
"ja",
"ko",
"ru",
"ms",
"pt-BR"
@ -21629,6 +21709,9 @@ const docTemplate = `{
"key": {
"type": "string"
},
"locales": {
"$ref": "#/definitions/dto.Locale"
},
"name": {
"type": "string"
},
@ -21918,6 +22001,9 @@ const docTemplate = `{
"crossVersionUpdate": {
"type": "boolean"
},
"description": {
"type": "string"
},
"document": {
"type": "string"
},
@ -22142,6 +22228,9 @@ const docTemplate = `{
"sort": {
"type": "integer"
},
"translations": {
"type": "string"
},
"updatedAt": {
"type": "string"
}
@ -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": [
@ -24808,6 +24912,9 @@ const docTemplate = `{
"crossVersionUpdate": {
"type": "boolean"
},
"description": {
"type": "string"
},
"document": {
"type": "string"
},
@ -24977,6 +25084,9 @@ const docTemplate = `{
"response.AppItem": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"icon": {
"type": "string"
},
@ -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": {
@ -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": {
@ -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": {

@ -10010,10 +10010,7 @@
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/response.PHPExtensionsDTO"
}
"$ref": "#/definitions/dto.PageResult"
}
}
}
@ -15482,6 +15479,59 @@
}
}
},
"/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": [
@ -16697,6 +16747,9 @@
"crossVersionUpdate": {
"type": "boolean"
},
"description": {
"$ref": "#/definitions/dto.Locale"
},
"document": {
"type": "string"
},
@ -19499,6 +19552,32 @@
}
}
},
"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": {
@ -19542,6 +19621,7 @@
"en",
"tw",
"ja",
"ko",
"ru",
"ms",
"pt-BR"
@ -21626,6 +21706,9 @@
"key": {
"type": "string"
},
"locales": {
"$ref": "#/definitions/dto.Locale"
},
"name": {
"type": "string"
},
@ -21915,6 +21998,9 @@
"crossVersionUpdate": {
"type": "boolean"
},
"description": {
"type": "string"
},
"document": {
"type": "string"
},
@ -22139,6 +22225,9 @@
"sort": {
"type": "integer"
},
"translations": {
"type": "string"
},
"updatedAt": {
"type": "string"
}
@ -24429,6 +24518,21 @@
}
}
},
"request.WebsiteProxyDel": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
}
}
},
"request.WebsiteProxyReq": {
"type": "object",
"required": [
@ -24805,6 +24909,9 @@
"crossVersionUpdate": {
"type": "boolean"
},
"description": {
"type": "string"
},
"document": {
"type": "string"
},
@ -24974,6 +25081,9 @@
"response.AppItem": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"icon": {
"type": "string"
},
@ -24995,19 +25105,13 @@
"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": {
@ -25489,26 +25593,6 @@
}
}
},
"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": {
@ -25635,6 +25719,20 @@
}
}
},
"response.TagDTO": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"key": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"response.WebsiteAcmeAccountDTO": {
"type": "object",
"properties": {

@ -102,6 +102,8 @@ definitions:
type: array
crossVersionUpdate:
type: boolean
description:
$ref: '#/definitions/dto.Locale'
document:
type: string
github:
@ -1983,6 +1985,23 @@ definitions:
- id
- type
type: object
dto.Locale:
properties:
en:
type: string
ja:
type: string
ms:
type: string
pt-br:
type: string
ru:
type: string
zh:
type: string
zh-hant:
type: string
type: object
dto.LogOption:
properties:
logMaxFile:
@ -2009,6 +2028,7 @@ definitions:
- en
- tw
- ja
- ko
- ru
- ms
- pt-BR
@ -3429,6 +3449,8 @@ definitions:
properties:
key:
type: string
locales:
$ref: '#/definitions/dto.Locale'
name:
type: string
sort:
@ -3618,6 +3640,8 @@ definitions:
type: string
crossVersionUpdate:
type: boolean
description:
type: string
document:
type: string
github:
@ -3766,6 +3790,8 @@ definitions:
type: string
sort:
type: integer
translations:
type: string
updatedAt:
type: string
type: object
@ -5303,6 +5329,16 @@ definitions:
- proxyHost
- proxyPass
type: object
request.WebsiteProxyDel:
properties:
id:
type: integer
name:
type: string
required:
- id
- name
type: object
request.WebsiteProxyReq:
properties:
id:
@ -5556,6 +5592,8 @@ definitions:
type: string
crossVersionUpdate:
type: boolean
description:
type: string
document:
type: string
github:
@ -5668,6 +5706,8 @@ definitions:
type: object
response.AppItem:
properties:
description:
type: string
icon:
type: string
id:
@ -5682,15 +5722,11 @@ definitions:
type: string
resource:
type: string
shortDescEn:
type: string
shortDescZh:
type: string
status:
type: string
tags:
items:
$ref: '#/definitions/model.Tag'
$ref: '#/definitions/response.TagDTO'
type: array
type:
type: string
@ -6005,19 +6041,6 @@ definitions:
uploadMaxSize:
type: string
type: object
response.PHPExtensionsDTO:
properties:
createdAt:
type: string
extensions:
type: string
id:
type: integer
name:
type: string
updatedAt:
type: string
type: object
response.PackageScripts:
properties:
name:
@ -6101,6 +6124,15 @@ definitions:
user:
type: string
type: object
response.TagDTO:
properties:
id:
type: integer
key:
type: string
name:
type: string
type: object
response.WebsiteAcmeAccountDTO:
properties:
createdAt:
@ -12427,9 +12459,7 @@ paths:
"200":
description: OK
schema:
items:
$ref: '#/definitions/response.PHPExtensionsDTO'
type: array
$ref: '#/definitions/dto.PageResult'
security:
- ApiKeyAuth: []
- Timestamp: []
@ -15816,6 +15846,39 @@ paths:
summary: Get proxy conf
tags:
- Website
/websites/proxies/del:
post:
consumes:
- application/json
parameters:
- description: request
in: body
name: request
required: true
schema:
$ref: '#/definitions/request.WebsiteProxyDel'
responses:
"200":
description: OK
security:
- ApiKeyAuth: []
- Timestamp: []
summary: Delete proxy conf
tags:
- Website
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:
consumes:

@ -64,7 +64,7 @@ export const AppInstalledDeleteCheck = (appInstallId: number) => {
};
export const GetAppInstalled = (search: App.AppInstalledSearch) => {
return http.post<App.AppInstalled[]>('apps/installed/search', search);
return http.post<ResPage<App.AppInstalled>>('apps/installed/search', search);
};
export const InstalledOp = (op: App.AppInstalledOp) => {

@ -49,7 +49,7 @@ export const SearchPHPExtensions = (req: ReqPage) => {
};
export const ListPHPExtensions = (req: Runtime.PHPExtensionsList) => {
return http.post<Runtime.PHPExtensions[]>(`/runtimes/php/extensions/search`, req);
return http.post<ResPage<Runtime.PHPExtensions>>(`/runtimes/php/extensions/search`, req);
};
export const CreatePHPExtensions = (req: Runtime.PHPExtensionsCreate) => {

@ -396,7 +396,7 @@ const listPHPExtensions = async () => {
page: 1,
pageSize: 100,
});
phpExtensions.value = res.data;
phpExtensions.value = res.data.items;
} catch (error) {}
};

@ -505,8 +505,8 @@ const changeType = (type: string) => {
const searchAppInstalled = () => {
GetAppInstalled({ type: 'website', unused: true, all: true, page: 1, pageSize: 100 }).then((res) => {
appInstalls.value = res.data;
if (res.data && res.data.length > 0) {
appInstalls.value = res.data.items;
if (res.data.items && res.data.items.length > 0) {
website.value.appInstallId = res.data[0].id;
}
});