diff --git a/backend/app/api/v1/app.go b/backend/app/api/v1/app.go index 345dbd1ff..2518fe2b3 100644 --- a/backend/app/api/v1/app.go +++ b/backend/app/api/v1/app.go @@ -155,7 +155,7 @@ func (b *BaseApi) GetIgnoredApp(c *gin.Context) { // @Success 200 {object} model.AppInstall // @Security ApiKeyAuth // @Router /apps/install [post] -// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[{"input_column":"name","input_value":"name","isList":false,"db":"app_installs","output_column":"app_id","output_value":"appId"},{"info":"appId","isList":false,"db":"apps","output_column":"key","output_value":"appKey"}],"formatZH":"安装应用 [appKey]-[name]","formatEN":"Install app [appKey]-[name]"} +// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"安装应用 [name]","formatEN":"Install app [name]"} func (b *BaseApi) InstallApp(c *gin.Context) { var req request.AppInstallCreate if err := helper.CheckBindAndValidate(&req, c); err != nil { diff --git a/backend/middleware/operation.go b/backend/middleware/operation.go index 6609bdfe8..7af64f521 100644 --- a/backend/middleware/operation.go +++ b/backend/middleware/operation.go @@ -7,6 +7,7 @@ import ( "fmt" "io" "net/http" + "reflect" "strings" "time" @@ -110,12 +111,21 @@ func OperationLog() gin.HandlerFunc { } for key, value := range formatMap { if strings.Contains(operationDic.FormatEN, "["+key+"]") { - if arrays, ok := value.([]string); ok { - operationDic.FormatZH = strings.ReplaceAll(operationDic.FormatZH, "["+key+"]", fmt.Sprintf("[%v]", strings.Join(arrays, ","))) - operationDic.FormatEN = strings.ReplaceAll(operationDic.FormatEN, "["+key+"]", fmt.Sprintf("[%v]", strings.Join(arrays, ","))) - } else { + t := reflect.TypeOf(value) + if t.Kind() != reflect.Array && t.Kind() != reflect.Slice { operationDic.FormatZH = strings.ReplaceAll(operationDic.FormatZH, "["+key+"]", fmt.Sprintf("[%v]", value)) operationDic.FormatEN = strings.ReplaceAll(operationDic.FormatEN, "["+key+"]", fmt.Sprintf("[%v]", value)) + } else { + val := reflect.ValueOf(value) + length := val.Len() + + var elements []string + for i := 0; i < length; i++ { + element := val.Index(i).Interface().(string) + elements = append(elements, element) + } + operationDic.FormatZH = strings.ReplaceAll(operationDic.FormatZH, "["+key+"]", fmt.Sprintf("[%v]", strings.Join(elements, ","))) + operationDic.FormatEN = strings.ReplaceAll(operationDic.FormatEN, "["+key+"]", fmt.Sprintf("[%v]", strings.Join(elements, ","))) } } } diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go index b004a49f5..2d5684495 100644 --- a/cmd/server/docs/docs.go +++ b/cmd/server/docs/docs.go @@ -1,5 +1,4 @@ -// Code generated by swaggo/swag. DO NOT EDIT. - +// Package docs Code generated by swaggo/swag. DO NOT EDIT package docs import "github.com/swaggo/swag" @@ -216,28 +215,12 @@ const docTemplate = `{ } }, "x-panel-log": { - "BeforeFunctions": [ - { - "db": "app_installs", - "input_column": "name", - "input_value": "name", - "isList": false, - "output_column": "app_id", - "output_value": "appId" - }, - { - "db": "apps", - "info": "appId", - "isList": false, - "output_column": "key", - "output_value": "appKey" - } - ], + "BeforeFunctions": [], "bodyKeys": [ "name" ], - "formatEN": "Install app [appKey]-[name]", - "formatZH": "安装应用 [appKey]-[name]", + "formatEN": "Install app [name]", + "formatZH": "安装应用 [name]", "paramKeys": [] } } @@ -11486,7 +11469,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dto.SearchWithPage" + "$ref": "#/definitions/dto.SearchClamWithPage" } } ], @@ -19321,6 +19304,42 @@ const docTemplate = `{ } } }, + "dto.SearchClamWithPage": { + "type": "object", + "required": [ + "order", + "orderBy", + "page", + "pageSize" + ], + "properties": { + "info": { + "type": "string" + }, + "order": { + "type": "string", + "enum": [ + "null", + "ascending", + "descending" + ] + }, + "orderBy": { + "type": "string", + "enum": [ + "name", + "status", + "created_at" + ] + }, + "page": { + "type": "integer" + }, + "pageSize": { + "type": "integer" + } + } + }, "dto.SearchForTree": { "type": "object", "properties": { @@ -23457,6 +23476,8 @@ var SwaggerInfo = &swag.Spec{ Description: "开源Linux面板", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", } func init() { diff --git a/cmd/server/docs/swagger.json b/cmd/server/docs/swagger.json index de2b02277..c6bd7ff77 100644 --- a/cmd/server/docs/swagger.json +++ b/cmd/server/docs/swagger.json @@ -209,28 +209,12 @@ } }, "x-panel-log": { - "BeforeFunctions": [ - { - "db": "app_installs", - "input_column": "name", - "input_value": "name", - "isList": false, - "output_column": "app_id", - "output_value": "appId" - }, - { - "db": "apps", - "info": "appId", - "isList": false, - "output_column": "key", - "output_value": "appKey" - } - ], + "BeforeFunctions": [], "bodyKeys": [ "name" ], - "formatEN": "Install app [appKey]-[name]", - "formatZH": "安装应用 [appKey]-[name]", + "formatEN": "Install app [name]", + "formatZH": "安装应用 [name]", "paramKeys": [] } } @@ -11479,7 +11463,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dto.SearchWithPage" + "$ref": "#/definitions/dto.SearchClamWithPage" } } ], @@ -19314,6 +19298,42 @@ } } }, + "dto.SearchClamWithPage": { + "type": "object", + "required": [ + "order", + "orderBy", + "page", + "pageSize" + ], + "properties": { + "info": { + "type": "string" + }, + "order": { + "type": "string", + "enum": [ + "null", + "ascending", + "descending" + ] + }, + "orderBy": { + "type": "string", + "enum": [ + "name", + "status", + "created_at" + ] + }, + "page": { + "type": "integer" + }, + "pageSize": { + "type": "integer" + } + } + }, "dto.SearchForTree": { "type": "object", "properties": { diff --git a/cmd/server/docs/swagger.yaml b/cmd/server/docs/swagger.yaml index 9dabd1965..8a571e9c6 100644 --- a/cmd/server/docs/swagger.yaml +++ b/cmd/server/docs/swagger.yaml @@ -2748,6 +2748,32 @@ definitions: - ssl - sslType type: object + dto.SearchClamWithPage: + properties: + info: + type: string + order: + enum: + - "null" + - ascending + - descending + type: string + orderBy: + enum: + - name + - status + - created_at + type: string + page: + type: integer + pageSize: + type: integer + required: + - order + - orderBy + - page + - pageSize + type: object dto.SearchForTree: properties: info: @@ -5633,22 +5659,11 @@ paths: tags: - App x-panel-log: - BeforeFunctions: - - db: app_installs - input_column: name - input_value: name - isList: false - output_column: app_id - output_value: appId - - db: apps - info: appId - isList: false - output_column: key - output_value: appKey + BeforeFunctions: [] bodyKeys: - name - formatEN: Install app [appKey]-[name] - formatZH: 安装应用 [appKey]-[name] + formatEN: Install app [name] + formatZH: 安装应用 [name] paramKeys: [] /apps/installed/check: post: @@ -12769,7 +12784,7 @@ paths: name: request required: true schema: - $ref: '#/definitions/dto.SearchWithPage' + $ref: '#/definitions/dto.SearchClamWithPage' responses: "200": description: OK