add file conn log
This commit is contained in:
@@ -200,7 +200,7 @@ func getTranslatorForLang(lang string) ut.Translator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
func DatabaseAutoUpdate() {
|
func DatabaseAutoUpdate() {
|
||||||
version := 233
|
version := 235
|
||||||
|
|
||||||
db := global.DB
|
db := global.DB
|
||||||
|
|
||||||
@@ -263,6 +263,7 @@ func Migrate(version uint) {
|
|||||||
&model.LoginLog{},
|
&model.LoginLog{},
|
||||||
&model.ShareRecord{},
|
&model.ShareRecord{},
|
||||||
&model.AuditConn{},
|
&model.AuditConn{},
|
||||||
|
&model.AuditFile{},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("migrate err :=>", err)
|
fmt.Println("migrate err :=>", err)
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ const docTemplateadmin = `{
|
|||||||
"token": []
|
"token": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "链接日志删除",
|
"description": "文件日志删除",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
@@ -395,17 +395,17 @@ const docTemplateadmin = `{
|
|||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"链接日志"
|
"文件日志"
|
||||||
],
|
],
|
||||||
"summary": "链接日志删除",
|
"summary": "文件日志删除",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"description": "链接日志信息",
|
"description": "文件日志信息",
|
||||||
"name": "body",
|
"name": "body",
|
||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/model.AuditConn"
|
"$ref": "#/definitions/model.AuditFile"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -432,7 +432,7 @@ const docTemplateadmin = `{
|
|||||||
"token": []
|
"token": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "链接日志列表",
|
"description": "文件日志列表",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
@@ -440,9 +440,9 @@ const docTemplateadmin = `{
|
|||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"链接日志"
|
"文件日志"
|
||||||
],
|
],
|
||||||
"summary": "链接日志列表",
|
"summary": "文件日志列表",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
@@ -481,7 +481,7 @@ const docTemplateadmin = `{
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"data": {
|
"data": {
|
||||||
"$ref": "#/definitions/model.AuditConnList"
|
"$ref": "#/definitions/model.AuditFileList"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2566,6 +2566,9 @@ const docTemplateadmin = `{
|
|||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "integer"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -2925,6 +2928,70 @@ const docTemplateadmin = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"model.AuditFile": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"created_at": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"from_name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"from_peer": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"info": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"ip": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"is_file": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"num": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"path": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"peer_id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"uuid": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"model.AuditFileList": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"list": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/model.AuditFile"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"page": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"page_size": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"total": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"model.Group": {
|
"model.Group": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@@ -380,7 +380,7 @@
|
|||||||
"token": []
|
"token": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "链接日志删除",
|
"description": "文件日志删除",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
@@ -388,17 +388,17 @@
|
|||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"链接日志"
|
"文件日志"
|
||||||
],
|
],
|
||||||
"summary": "链接日志删除",
|
"summary": "文件日志删除",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"description": "链接日志信息",
|
"description": "文件日志信息",
|
||||||
"name": "body",
|
"name": "body",
|
||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/model.AuditConn"
|
"$ref": "#/definitions/model.AuditFile"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -425,7 +425,7 @@
|
|||||||
"token": []
|
"token": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "链接日志列表",
|
"description": "文件日志列表",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
@@ -433,9 +433,9 @@
|
|||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"链接日志"
|
"文件日志"
|
||||||
],
|
],
|
||||||
"summary": "链接日志列表",
|
"summary": "文件日志列表",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
@@ -474,7 +474,7 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"data": {
|
"data": {
|
||||||
"$ref": "#/definitions/model.AuditConnList"
|
"$ref": "#/definitions/model.AuditFileList"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2559,6 +2559,9 @@
|
|||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "integer"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -2918,6 +2921,70 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"model.AuditFile": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"created_at": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"from_name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"from_peer": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"info": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"ip": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"is_file": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"num": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"path": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"peer_id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"uuid": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"model.AuditFileList": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"list": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/model.AuditFile"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"page": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"page_size": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"total": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"model.Group": {
|
"model.Group": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ definitions:
|
|||||||
type: integer
|
type: integer
|
||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
|
type:
|
||||||
|
type: integer
|
||||||
required:
|
required:
|
||||||
- name
|
- name
|
||||||
type: object
|
type: object
|
||||||
@@ -315,6 +317,48 @@ definitions:
|
|||||||
total:
|
total:
|
||||||
type: integer
|
type: integer
|
||||||
type: object
|
type: object
|
||||||
|
model.AuditFile:
|
||||||
|
properties:
|
||||||
|
created_at:
|
||||||
|
type: string
|
||||||
|
from_name:
|
||||||
|
type: string
|
||||||
|
from_peer:
|
||||||
|
type: string
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
info:
|
||||||
|
type: string
|
||||||
|
ip:
|
||||||
|
type: string
|
||||||
|
is_file:
|
||||||
|
type: boolean
|
||||||
|
num:
|
||||||
|
type: integer
|
||||||
|
path:
|
||||||
|
type: string
|
||||||
|
peer_id:
|
||||||
|
type: string
|
||||||
|
type:
|
||||||
|
type: integer
|
||||||
|
updated_at:
|
||||||
|
type: string
|
||||||
|
uuid:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
model.AuditFileList:
|
||||||
|
properties:
|
||||||
|
list:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/model.AuditFile'
|
||||||
|
type: array
|
||||||
|
page:
|
||||||
|
type: integer
|
||||||
|
page_size:
|
||||||
|
type: integer
|
||||||
|
total:
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
model.Group:
|
model.Group:
|
||||||
properties:
|
properties:
|
||||||
created_at:
|
created_at:
|
||||||
@@ -765,14 +809,14 @@ paths:
|
|||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
- application/json
|
- application/json
|
||||||
description: 链接日志删除
|
description: 文件日志删除
|
||||||
parameters:
|
parameters:
|
||||||
- description: 链接日志信息
|
- description: 文件日志信息
|
||||||
in: body
|
in: body
|
||||||
name: body
|
name: body
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/model.AuditConn'
|
$ref: '#/definitions/model.AuditFile'
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
@@ -786,14 +830,14 @@ paths:
|
|||||||
$ref: '#/definitions/response.Response'
|
$ref: '#/definitions/response.Response'
|
||||||
security:
|
security:
|
||||||
- token: []
|
- token: []
|
||||||
summary: 链接日志删除
|
summary: 文件日志删除
|
||||||
tags:
|
tags:
|
||||||
- 链接日志
|
- 文件日志
|
||||||
/admin/audit_conn/list:
|
/admin/audit_conn/list:
|
||||||
get:
|
get:
|
||||||
consumes:
|
consumes:
|
||||||
- application/json
|
- application/json
|
||||||
description: 链接日志列表
|
description: 文件日志列表
|
||||||
parameters:
|
parameters:
|
||||||
- description: 页码
|
- description: 页码
|
||||||
in: query
|
in: query
|
||||||
@@ -821,7 +865,7 @@ paths:
|
|||||||
- $ref: '#/definitions/response.Response'
|
- $ref: '#/definitions/response.Response'
|
||||||
- properties:
|
- properties:
|
||||||
data:
|
data:
|
||||||
$ref: '#/definitions/model.AuditConnList'
|
$ref: '#/definitions/model.AuditFileList'
|
||||||
type: object
|
type: object
|
||||||
"500":
|
"500":
|
||||||
description: Internal Server Error
|
description: Internal Server Error
|
||||||
@@ -829,9 +873,9 @@ paths:
|
|||||||
$ref: '#/definitions/response.Response'
|
$ref: '#/definitions/response.Response'
|
||||||
security:
|
security:
|
||||||
- token: []
|
- token: []
|
||||||
summary: 链接日志列表
|
summary: 文件日志列表
|
||||||
tags:
|
tags:
|
||||||
- 链接日志
|
- 文件日志
|
||||||
/admin/file/oss_token:
|
/admin/file/oss_token:
|
||||||
get:
|
get:
|
||||||
consumes:
|
consumes:
|
||||||
|
|||||||
@@ -727,6 +727,46 @@ const docTemplateapi = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/audit/file": {
|
||||||
|
"post": {
|
||||||
|
"description": "审计文件",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"审计"
|
||||||
|
],
|
||||||
|
"summary": "审计文件",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "审计文件",
|
||||||
|
"name": "body",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/api.AuditFileForm"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.Response"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/heartbeat": {
|
"/heartbeat": {
|
||||||
"post": {
|
"post": {
|
||||||
"description": "心跳",
|
"description": "心跳",
|
||||||
@@ -1259,6 +1299,32 @@ const docTemplateapi = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"api.AuditFileForm": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"info": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"is_file": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"path": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"peer_id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"uuid": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"api.DeviceInfoInLogin": {
|
"api.DeviceInfoInLogin": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@@ -720,6 +720,46 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/audit/file": {
|
||||||
|
"post": {
|
||||||
|
"description": "审计文件",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"审计"
|
||||||
|
],
|
||||||
|
"summary": "审计文件",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "审计文件",
|
||||||
|
"name": "body",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/api.AuditFileForm"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.Response"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/heartbeat": {
|
"/heartbeat": {
|
||||||
"post": {
|
"post": {
|
||||||
"description": "心跳",
|
"description": "心跳",
|
||||||
@@ -1252,6 +1292,32 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"api.AuditFileForm": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"info": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"is_file": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"path": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"peer_id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"uuid": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"api.DeviceInfoInLogin": {
|
"api.DeviceInfoInLogin": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@@ -27,6 +27,23 @@ definitions:
|
|||||||
uuid:
|
uuid:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
|
api.AuditFileForm:
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
info:
|
||||||
|
type: string
|
||||||
|
is_file:
|
||||||
|
type: boolean
|
||||||
|
path:
|
||||||
|
type: string
|
||||||
|
peer_id:
|
||||||
|
type: string
|
||||||
|
type:
|
||||||
|
type: integer
|
||||||
|
uuid:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
api.DeviceInfoInLogin:
|
api.DeviceInfoInLogin:
|
||||||
properties:
|
properties:
|
||||||
name:
|
name:
|
||||||
@@ -609,6 +626,32 @@ paths:
|
|||||||
summary: 审计连接
|
summary: 审计连接
|
||||||
tags:
|
tags:
|
||||||
- 审计
|
- 审计
|
||||||
|
/audit/file:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: 审计文件
|
||||||
|
parameters:
|
||||||
|
- description: 审计文件
|
||||||
|
in: body
|
||||||
|
name: body
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/api.AuditFileForm'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.Response'
|
||||||
|
summary: 审计文件
|
||||||
|
tags:
|
||||||
|
- 审计
|
||||||
/heartbeat:
|
/heartbeat:
|
||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ func (a *Audit) ConnDelete(c *gin.Context) {
|
|||||||
response.Fail(c, 101, errList[0])
|
response.Fail(c, 101, errList[0])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
l := service.AllService.AuditService.InfoById(f.Id)
|
l := service.AllService.AuditService.ConnInfoById(f.Id)
|
||||||
if l.Id > 0 {
|
if l.Id > 0 {
|
||||||
err := service.AllService.AuditService.DeleteAuditConn(l)
|
err := service.AllService.AuditService.DeleteAuditConn(l)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -79,3 +79,70 @@ func (a *Audit) ConnDelete(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
|
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FileList 列表
|
||||||
|
// @Tags 文件日志
|
||||||
|
// @Summary 文件日志列表
|
||||||
|
// @Description 文件日志列表
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param page query int false "页码"
|
||||||
|
// @Param page_size query int false "页大小"
|
||||||
|
// @Param peer_id query int false "目标设备"
|
||||||
|
// @Param from_peer query int false "来源设备"
|
||||||
|
// @Success 200 {object} response.Response{data=model.AuditFileList}
|
||||||
|
// @Failure 500 {object} response.Response
|
||||||
|
// @Router /admin/audit_conn/list [get]
|
||||||
|
// @Security token
|
||||||
|
func (a *Audit) FileList(c *gin.Context) {
|
||||||
|
query := &admin.AuditQuery{}
|
||||||
|
if err := c.ShouldBindQuery(query); err != nil {
|
||||||
|
response.Fail(c, 101, response.TranslateMsg(c, "ParamsError")+err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res := service.AllService.AuditService.AuditFileList(query.Page, query.PageSize, func(tx *gorm.DB) {
|
||||||
|
if query.PeerId != "" {
|
||||||
|
tx.Where("peer_id like ?", "%"+query.PeerId+"%")
|
||||||
|
}
|
||||||
|
if query.FromPeer != "" {
|
||||||
|
tx.Where("from_peer like ?", "%"+query.FromPeer+"%")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
response.Success(c, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FileDelete 删除
|
||||||
|
// @Tags 文件日志
|
||||||
|
// @Summary 文件日志删除
|
||||||
|
// @Description 文件日志删除
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param body body model.AuditFile true "文件日志信息"
|
||||||
|
// @Success 200 {object} response.Response
|
||||||
|
// @Failure 500 {object} response.Response
|
||||||
|
// @Router /admin/audit_conn/delete [post]
|
||||||
|
// @Security token
|
||||||
|
func (a *Audit) FileDelete(c *gin.Context) {
|
||||||
|
f := &model.AuditFile{}
|
||||||
|
if err := c.ShouldBindJSON(f); err != nil {
|
||||||
|
response.Fail(c, 101, response.TranslateMsg(c, "ParamsError")+err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
id := f.Id
|
||||||
|
errList := global.Validator.ValidVar(c, id, "required,gt=0")
|
||||||
|
if len(errList) > 0 {
|
||||||
|
response.Fail(c, 101, errList[0])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
l := service.AllService.AuditService.FileInfoById(f.Id)
|
||||||
|
if l.Id > 0 {
|
||||||
|
err := service.AllService.AuditService.DeleteAuditFile(l)
|
||||||
|
if err == nil {
|
||||||
|
response.Success(c, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.Fail(c, 101, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
|
||||||
|
}
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ func (a *Audit) AuditConn(c *gin.Context) {
|
|||||||
response.Error(c, response.TranslateMsg(c, "ParamsError")+err.Error())
|
response.Error(c, response.TranslateMsg(c, "ParamsError")+err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//fmt.Println(af)
|
/*ttt := &gin.H{}
|
||||||
|
c.ShouldBindBodyWith(ttt, binding.JSON)
|
||||||
|
fmt.Println(ttt)*/
|
||||||
ac := af.ToAuditConn()
|
ac := af.ToAuditConn()
|
||||||
if af.Action == model.AuditActionNew {
|
if af.Action == model.AuditActionNew {
|
||||||
service.AllService.AuditService.CreateAuditConn(ac)
|
service.AllService.AuditService.CreateAuditConn(ac)
|
||||||
@@ -48,9 +50,35 @@ func (a *Audit) AuditConn(c *gin.Context) {
|
|||||||
FromPeer: ac.FromPeer,
|
FromPeer: ac.FromPeer,
|
||||||
FromName: ac.FromName,
|
FromName: ac.FromName,
|
||||||
SessionId: ac.SessionId,
|
SessionId: ac.SessionId,
|
||||||
|
Type: ac.Type,
|
||||||
}
|
}
|
||||||
service.AllService.AuditService.UpdateAuditConn(up)
|
service.AllService.AuditService.UpdateAuditConn(up)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
response.Success(c, "")
|
response.Success(c, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AuditFile
|
||||||
|
// @Tags 审计
|
||||||
|
// @Summary 审计文件
|
||||||
|
// @Description 审计文件
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param body body request.AuditFileForm true "审计文件"
|
||||||
|
// @Success 200 {string} string ""
|
||||||
|
// @Failure 500 {object} response.Response
|
||||||
|
// @Router /audit/file [post]
|
||||||
|
func (a *Audit) AuditFile(c *gin.Context) {
|
||||||
|
aff := &request.AuditFileForm{}
|
||||||
|
err := c.ShouldBindBodyWith(aff, binding.JSON)
|
||||||
|
if err != nil {
|
||||||
|
response.Error(c, response.TranslateMsg(c, "ParamsError")+err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//ttt := &gin.H{}
|
||||||
|
//c.ShouldBindBodyWith(ttt, binding.JSON)
|
||||||
|
//fmt.Println(ttt)
|
||||||
|
af := aff.ToAuditFile()
|
||||||
|
service.AllService.AuditService.CreateAuditFile(af)
|
||||||
|
response.Success(c, "")
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"Gwen/global"
|
||||||
"Gwen/model"
|
"Gwen/model"
|
||||||
|
"encoding/json"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -38,3 +40,39 @@ func (a *AuditConnForm) ToAuditConn() *model.AuditConn {
|
|||||||
Uuid: a.Uuid,
|
Uuid: a.Uuid,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AuditFileForm struct {
|
||||||
|
Id string `json:"id"`
|
||||||
|
Info string `json:"info"`
|
||||||
|
IsFile bool `json:"is_file"`
|
||||||
|
Path string `json:"path"`
|
||||||
|
PeerId string `json:"peer_id"`
|
||||||
|
Type int `json:"type"`
|
||||||
|
Uuid string `json:"uuid"`
|
||||||
|
}
|
||||||
|
type AuditFileInfo struct {
|
||||||
|
Ip string `json:"ip"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Num int `json:"num"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *AuditFileForm) ToAuditFile() *model.AuditFile {
|
||||||
|
fi := &AuditFileInfo{}
|
||||||
|
err := json.Unmarshal([]byte(a.Info), fi)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Warn("ToAuditFile", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &model.AuditFile{
|
||||||
|
PeerId: a.Id,
|
||||||
|
Info: a.Info,
|
||||||
|
IsFile: a.IsFile,
|
||||||
|
FromPeer: a.PeerId,
|
||||||
|
Path: a.Path,
|
||||||
|
Type: a.Type,
|
||||||
|
Uuid: a.Uuid,
|
||||||
|
FromName: fi.Name,
|
||||||
|
Ip: fi.Ip,
|
||||||
|
Num: fi.Num,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -148,6 +148,9 @@ func AuditBind(rg *gin.RouterGroup) {
|
|||||||
aR := rg.Group("/audit_conn").Use(middleware.AdminPrivilege())
|
aR := rg.Group("/audit_conn").Use(middleware.AdminPrivilege())
|
||||||
aR.GET("/list", cont.ConnList)
|
aR.GET("/list", cont.ConnList)
|
||||||
aR.POST("/delete", cont.ConnDelete)
|
aR.POST("/delete", cont.ConnDelete)
|
||||||
|
afR := rg.Group("/audit_file").Use(middleware.AdminPrivilege())
|
||||||
|
afR.GET("/list", cont.FileList)
|
||||||
|
afR.POST("/delete", cont.FileDelete)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ func ApiInit(g *gin.Engine) {
|
|||||||
au := &api.Audit{}
|
au := &api.Audit{}
|
||||||
//[method:POST] [uri:/api/audit/conn]
|
//[method:POST] [uri:/api/audit/conn]
|
||||||
frg.POST("/audit/conn", au.AuditConn)
|
frg.POST("/audit/conn", au.AuditConn)
|
||||||
|
//[method:POST] [uri:/api/audit/file]
|
||||||
|
frg.POST("/audit/file", au.AuditFile)
|
||||||
frg.Use(middleware.RustAuth())
|
frg.Use(middleware.RustAuth())
|
||||||
{
|
{
|
||||||
u := &api.User{}
|
u := &api.User{}
|
||||||
|
|||||||
@@ -24,3 +24,23 @@ type AuditConnList struct {
|
|||||||
AuditConns []*AuditConn `json:"list"`
|
AuditConns []*AuditConn `json:"list"`
|
||||||
Pagination
|
Pagination
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AuditFile struct {
|
||||||
|
IdModel
|
||||||
|
FromPeer string `json:"from_peer" gorm:"default:'';not null;index"`
|
||||||
|
Info string `json:"info" gorm:"default:'';not null;"`
|
||||||
|
IsFile bool `json:"is_file" gorm:"default:0;not null;"`
|
||||||
|
Path string `json:"path" gorm:"default:'';not null;"`
|
||||||
|
PeerId string `json:"peer_id" gorm:"default:'';not null;index"`
|
||||||
|
Type int `json:"type" gorm:"default:0;not null;"`
|
||||||
|
Uuid string `json:"uuid" gorm:"default:'';not null;"`
|
||||||
|
Ip string `json:"ip" gorm:"default:'';not null;"`
|
||||||
|
Num int `json:"num" gorm:"default:0;not null;"`
|
||||||
|
FromName string `json:"from_name" gorm:"default:'';not null;"`
|
||||||
|
TimeModel
|
||||||
|
}
|
||||||
|
|
||||||
|
type AuditFileList struct {
|
||||||
|
AuditFiles []*AuditFile `json:"list"`
|
||||||
|
Pagination
|
||||||
|
}
|
||||||
|
|||||||
@@ -44,9 +44,44 @@ func (as *AuditService) InfoByPeerIdAndConnId(peerId string, connId int64) (res
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// InfoById
|
// ConnInfoById
|
||||||
func (as *AuditService) InfoById(id uint) (res *model.AuditConn) {
|
func (as *AuditService) ConnInfoById(id uint) (res *model.AuditConn) {
|
||||||
res = &model.AuditConn{}
|
res = &model.AuditConn{}
|
||||||
global.DB.Where("id = ?", id).First(res)
|
global.DB.Where("id = ?", id).First(res)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FileInfoById
|
||||||
|
func (as *AuditService) FileInfoById(id uint) (res *model.AuditFile) {
|
||||||
|
res = &model.AuditFile{}
|
||||||
|
global.DB.Where("id = ?", id).First(res)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (as *AuditService) AuditFileList(page, pageSize uint, where func(tx *gorm.DB)) (res *model.AuditFileList) {
|
||||||
|
res = &model.AuditFileList{}
|
||||||
|
res.Page = int64(page)
|
||||||
|
res.PageSize = int64(pageSize)
|
||||||
|
tx := global.DB.Model(&model.AuditFile{})
|
||||||
|
if where != nil {
|
||||||
|
where(tx)
|
||||||
|
}
|
||||||
|
tx.Count(&res.Total)
|
||||||
|
tx.Scopes(Paginate(page, pageSize))
|
||||||
|
tx.Find(&res.AuditFiles)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateAuditFile
|
||||||
|
func (as *AuditService) CreateAuditFile(u *model.AuditFile) error {
|
||||||
|
res := global.DB.Create(u).Error
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
func (as *AuditService) DeleteAuditFile(u *model.AuditFile) error {
|
||||||
|
return global.DB.Delete(u).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update 更新
|
||||||
|
func (as *AuditService) UpdateAuditFile(u *model.AuditFile) error {
|
||||||
|
return global.DB.Model(u).Updates(u).Error
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user