fix: 解决系统日志解析错误的问题 (#5917)

This commit is contained in:
ssongliu 2024-07-23 15:57:32 +08:00 committed by GitHub
parent f04be521e5
commit 1cf3a0143c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 128 additions and 62 deletions

View file

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

View file

@ -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, ",")))
}
}
}

View file

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

View file

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

View file

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