Compare commits

...

4 Commits

Author SHA1 Message Date
ljw
aced098982 add batch delete log #57 2024-11-12 09:08:10 +08:00
ljw
7862a34760 up admin conf 2024-11-12 08:43:49 +08:00
ljw
1384d28cac add admin conf 2024-11-11 22:26:15 +08:00
ljw
24b7338153 up readme 2024-11-09 20:38:11 +08:00
17 changed files with 1192 additions and 28 deletions

View File

@@ -39,6 +39,8 @@
- 自动获取ID服务器和KEY - 自动获取ID服务器和KEY
- 自动获取地址簿 - 自动获取地址簿
- 游客通过临时分享链接直接远程到设备 - 游客通过临时分享链接直接远程到设备
- CLI
- 重置管理员密码
## 使用前准备 ## 使用前准备
@@ -147,6 +149,17 @@
2. PC端文档 `<youer server[:port]>/swagger/index.html` 2. PC端文档 `<youer server[:port]>/swagger/index.html`
![api_swag](docs/api_swag.png) ![api_swag](docs/api_swag.png)
### CLI
```bash
# 查看帮助
./apimain -h
```
#### 重置管理员密码
```bash
./apimain reset-admin-pwd <pwd>
```
## 安装与运行 ## 安装与运行
### 相关配置 ### 相关配置

View File

@@ -38,7 +38,8 @@ desktop software that provides self-hosted solutions.
- Automatically obtain ID server and KEY - Automatically obtain ID server and KEY
- Automatically obtain address book - Automatically obtain address book
- Visitors are remotely to the device via a temporary sharing link - Visitors are remotely to the device via a temporary sharing link
- CLI
- Reset admin password
## Prerequisites ## Prerequisites
### [Rustdesk](https://github.com/rustdesk/rustdesk) ### [Rustdesk](https://github.com/rustdesk/rustdesk)
@@ -153,6 +154,17 @@ installation are `admin` `admin`, please change the password immediately.
2. PC client docs: `<your server[:port]>/swagger/index.html` 2. PC client docs: `<your server[:port]>/swagger/index.html`
![api_swag](docs/api_swag.png) ![api_swag](docs/api_swag.png)
### CLI
```bash
# help
./apimain -h
```
#### Reset admin password
```bash
./apimain reset-admin-pwd <pwd>
```
## Installation and Setup ## Installation and Setup
### Configuration ### Configuration

1
conf/admin/hello.html Normal file
View File

@@ -0,0 +1 @@
👏👏👏 你好 <strong>{{username}}</strong>, 欢迎使用 <a href='https://github.com/lejianwen/rustdesk-api' target='_blank'>RustDesk Api Admin</a>

View File

@@ -2,6 +2,10 @@ lang: "zh-CN"
app: app:
web-client: 1 # 1:启用 0:禁用 web-client: 1 # 1:启用 0:禁用
register: false #是否开启注册 register: false #是否开启注册
admin:
title: "RustDesk Api Admin"
hello-file: "./conf/admin/hello.html" #优先使用file
hello: ""
gin: gin:
api-addr: "0.0.0.0:21114" api-addr: "0.0.0.0:21114"
mode: "release" #release,debug,test mode: "release" #release,debug,test

View File

@@ -17,10 +17,15 @@ type App struct {
WebClient int `mapstructure:"web-client"` WebClient int `mapstructure:"web-client"`
Register bool `mapstructure:"register"` Register bool `mapstructure:"register"`
} }
type Admin struct {
Title string `mapstructure:"title"`
Hello string `mapstructure:"hello"`
HelloFile string `mapstructure:"hello-file"`
}
type Config struct { type Config struct {
Lang string `mapstructure:"lang"` Lang string `mapstructure:"lang"`
App App App App
Admin Admin
Gorm Gorm Gorm Gorm
Mysql Mysql Mysql Mysql
Gin Gin Gin Gin

View File

@@ -958,7 +958,214 @@ const docTemplateadmin = `{
} }
} }
}, },
"/admin/audit_conn/batchDelete": {
"post": {
"security": [
{
"token": []
}
],
"description": "链接日志批量删除",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"链接日志"
],
"summary": "链接日志批量删除",
"parameters": [
{
"description": "链接日志",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/admin.AuditConnLogIds"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Response"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.Response"
}
}
}
}
},
"/admin/audit_conn/delete": { "/admin/audit_conn/delete": {
"post": {
"security": [
{
"token": []
}
],
"description": "链接日志删除",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"链接日志"
],
"summary": "链接日志删除",
"parameters": [
{
"description": "链接日志信息",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/model.AuditConn"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Response"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.Response"
}
}
}
}
},
"/admin/audit_conn/list": {
"get": {
"security": [
{
"token": []
}
],
"description": "链接日志列表",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"链接日志"
],
"summary": "链接日志列表",
"parameters": [
{
"type": "integer",
"description": "页码",
"name": "page",
"in": "query"
},
{
"type": "integer",
"description": "页大小",
"name": "page_size",
"in": "query"
},
{
"type": "integer",
"description": "目标设备",
"name": "peer_id",
"in": "query"
},
{
"type": "integer",
"description": "来源设备",
"name": "from_peer",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/model.AuditConnList"
}
}
}
]
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.Response"
}
}
}
}
},
"/admin/audit_file/batchDelete": {
"post": {
"security": [
{
"token": []
}
],
"description": "文件日志批量删除",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"文件日志"
],
"summary": "文件日志批量删除",
"parameters": [
{
"description": "文件日志",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/admin.AuditFileLogIds"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Response"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.Response"
}
}
}
}
},
"/admin/audit_file/delete": {
"post": { "post": {
"security": [ "security": [
{ {
@@ -1003,7 +1210,7 @@ const docTemplateadmin = `{
} }
} }
}, },
"/admin/audit_conn/list": { "/admin/audit_file/list": {
"get": { "get": {
"security": [ "security": [
{ {
@@ -1075,6 +1282,108 @@ const docTemplateadmin = `{
} }
} }
}, },
"/admin/config/admin": {
"get": {
"security": [
{
"token": []
}
],
"description": "ADMIN服务配置",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ADMIN"
],
"summary": "ADMIN服务配置",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Response"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.Response"
}
}
}
}
},
"/admin/config/app": {
"get": {
"security": [
{
"token": []
}
],
"description": "APP服务配置",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ADMIN"
],
"summary": "APP服务配置",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Response"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.Response"
}
}
}
}
},
"/admin/config/server": {
"get": {
"security": [
{
"token": []
}
],
"description": "服务配置,给webclient提供api-server",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ADMIN"
],
"summary": "RUSTDESK服务配置",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Response"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.Response"
}
}
}
}
},
"/admin/file/oss_token": { "/admin/file/oss_token": {
"get": { "get": {
"security": [ "security": [
@@ -1522,7 +1831,7 @@ const docTemplateadmin = `{
"token": [] "token": []
} }
], ],
"description": "登录日志删除", "description": "登录日志批量删除",
"consumes": [ "consumes": [
"application/json" "application/json"
], ],
@@ -1532,15 +1841,15 @@ const docTemplateadmin = `{
"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.LoginLog" "$ref": "#/definitions/admin.LoginLogIds"
} }
} }
], ],
@@ -3074,7 +3383,7 @@ const docTemplateadmin = `{
"token": [] "token": []
} }
], ],
"description": "设备列表", "description": "我的设备列表",
"consumes": [ "consumes": [
"application/json" "application/json"
], ],
@@ -3084,7 +3393,7 @@ const docTemplateadmin = `{
"tags": [ "tags": [
"设备" "设备"
], ],
"summary": "设备列表", "summary": "我的设备列表",
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
@@ -3452,6 +3761,34 @@ const docTemplateadmin = `{
} }
} }
}, },
"admin.AuditConnLogIds": {
"type": "object",
"required": [
"ids"
],
"properties": {
"ids": {
"type": "array",
"items": {
"type": "integer"
}
}
}
},
"admin.AuditFileLogIds": {
"type": "object",
"required": [
"ids"
],
"properties": {
"ids": {
"type": "array",
"items": {
"type": "integer"
}
}
}
},
"admin.ChangeCurPasswordForm": { "admin.ChangeCurPasswordForm": {
"type": "object", "type": "object",
"required": [ "required": [
@@ -3488,6 +3825,20 @@ const docTemplateadmin = `{
} }
} }
}, },
"admin.LoginLogIds": {
"type": "object",
"required": [
"ids"
],
"properties": {
"ids": {
"type": "array",
"items": {
"type": "integer"
}
}
}
},
"admin.LoginPayload": { "admin.LoginPayload": {
"type": "object", "type": "object",
"properties": { "properties": {

View File

@@ -951,7 +951,214 @@
} }
} }
}, },
"/admin/audit_conn/batchDelete": {
"post": {
"security": [
{
"token": []
}
],
"description": "链接日志批量删除",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"链接日志"
],
"summary": "链接日志批量删除",
"parameters": [
{
"description": "链接日志",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/admin.AuditConnLogIds"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Response"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.Response"
}
}
}
}
},
"/admin/audit_conn/delete": { "/admin/audit_conn/delete": {
"post": {
"security": [
{
"token": []
}
],
"description": "链接日志删除",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"链接日志"
],
"summary": "链接日志删除",
"parameters": [
{
"description": "链接日志信息",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/model.AuditConn"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Response"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.Response"
}
}
}
}
},
"/admin/audit_conn/list": {
"get": {
"security": [
{
"token": []
}
],
"description": "链接日志列表",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"链接日志"
],
"summary": "链接日志列表",
"parameters": [
{
"type": "integer",
"description": "页码",
"name": "page",
"in": "query"
},
{
"type": "integer",
"description": "页大小",
"name": "page_size",
"in": "query"
},
{
"type": "integer",
"description": "目标设备",
"name": "peer_id",
"in": "query"
},
{
"type": "integer",
"description": "来源设备",
"name": "from_peer",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/model.AuditConnList"
}
}
}
]
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.Response"
}
}
}
}
},
"/admin/audit_file/batchDelete": {
"post": {
"security": [
{
"token": []
}
],
"description": "文件日志批量删除",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"文件日志"
],
"summary": "文件日志批量删除",
"parameters": [
{
"description": "文件日志",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/admin.AuditFileLogIds"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Response"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.Response"
}
}
}
}
},
"/admin/audit_file/delete": {
"post": { "post": {
"security": [ "security": [
{ {
@@ -996,7 +1203,7 @@
} }
} }
}, },
"/admin/audit_conn/list": { "/admin/audit_file/list": {
"get": { "get": {
"security": [ "security": [
{ {
@@ -1068,6 +1275,108 @@
} }
} }
}, },
"/admin/config/admin": {
"get": {
"security": [
{
"token": []
}
],
"description": "ADMIN服务配置",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ADMIN"
],
"summary": "ADMIN服务配置",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Response"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.Response"
}
}
}
}
},
"/admin/config/app": {
"get": {
"security": [
{
"token": []
}
],
"description": "APP服务配置",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ADMIN"
],
"summary": "APP服务配置",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Response"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.Response"
}
}
}
}
},
"/admin/config/server": {
"get": {
"security": [
{
"token": []
}
],
"description": "服务配置,给webclient提供api-server",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ADMIN"
],
"summary": "RUSTDESK服务配置",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Response"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.Response"
}
}
}
}
},
"/admin/file/oss_token": { "/admin/file/oss_token": {
"get": { "get": {
"security": [ "security": [
@@ -1515,7 +1824,7 @@
"token": [] "token": []
} }
], ],
"description": "登录日志删除", "description": "登录日志批量删除",
"consumes": [ "consumes": [
"application/json" "application/json"
], ],
@@ -1525,15 +1834,15 @@
"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.LoginLog" "$ref": "#/definitions/admin.LoginLogIds"
} }
} }
], ],
@@ -3067,7 +3376,7 @@
"token": [] "token": []
} }
], ],
"description": "设备列表", "description": "我的设备列表",
"consumes": [ "consumes": [
"application/json" "application/json"
], ],
@@ -3077,7 +3386,7 @@
"tags": [ "tags": [
"设备" "设备"
], ],
"summary": "设备列表", "summary": "我的设备列表",
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
@@ -3445,6 +3754,34 @@
} }
} }
}, },
"admin.AuditConnLogIds": {
"type": "object",
"required": [
"ids"
],
"properties": {
"ids": {
"type": "array",
"items": {
"type": "integer"
}
}
}
},
"admin.AuditFileLogIds": {
"type": "object",
"required": [
"ids"
],
"properties": {
"ids": {
"type": "array",
"items": {
"type": "integer"
}
}
}
},
"admin.ChangeCurPasswordForm": { "admin.ChangeCurPasswordForm": {
"type": "object", "type": "object",
"required": [ "required": [
@@ -3481,6 +3818,20 @@
} }
} }
}, },
"admin.LoginLogIds": {
"type": "object",
"required": [
"ids"
],
"properties": {
"ids": {
"type": "array",
"items": {
"type": "integer"
}
}
}
},
"admin.LoginPayload": { "admin.LoginPayload": {
"type": "object", "type": "object",
"properties": { "properties": {

View File

@@ -57,6 +57,24 @@ definitions:
required: required:
- id - id
type: object type: object
admin.AuditConnLogIds:
properties:
ids:
items:
type: integer
type: array
required:
- ids
type: object
admin.AuditFileLogIds:
properties:
ids:
items:
type: integer
type: array
required:
- ids
type: object
admin.ChangeCurPasswordForm: admin.ChangeCurPasswordForm:
properties: properties:
new_password: new_password:
@@ -82,6 +100,15 @@ definitions:
required: required:
- name - name
type: object type: object
admin.LoginLogIds:
properties:
ids:
items:
type: integer
type: array
required:
- ids
type: object
admin.LoginPayload: admin.LoginPayload:
properties: properties:
avatar: avatar:
@@ -1281,7 +1308,134 @@ paths:
summary: APP服务配置 summary: APP服务配置
tags: tags:
- ADMIN - ADMIN
/admin/audit_conn/batchDelete:
post:
consumes:
- application/json
description: 链接日志批量删除
parameters:
- description: 链接日志
in: body
name: body
required: true
schema:
$ref: '#/definitions/admin.AuditConnLogIds'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Response'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.Response'
security:
- token: []
summary: 链接日志批量删除
tags:
- 链接日志
/admin/audit_conn/delete: /admin/audit_conn/delete:
post:
consumes:
- application/json
description: 链接日志删除
parameters:
- description: 链接日志信息
in: body
name: body
required: true
schema:
$ref: '#/definitions/model.AuditConn'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Response'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.Response'
security:
- token: []
summary: 链接日志删除
tags:
- 链接日志
/admin/audit_conn/list:
get:
consumes:
- application/json
description: 链接日志列表
parameters:
- description: 页码
in: query
name: page
type: integer
- description: 页大小
in: query
name: page_size
type: integer
- description: 目标设备
in: query
name: peer_id
type: integer
- description: 来源设备
in: query
name: from_peer
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.Response'
- properties:
data:
$ref: '#/definitions/model.AuditConnList'
type: object
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.Response'
security:
- token: []
summary: 链接日志列表
tags:
- 链接日志
/admin/audit_file/batchDelete:
post:
consumes:
- application/json
description: 文件日志批量删除
parameters:
- description: 文件日志
in: body
name: body
required: true
schema:
$ref: '#/definitions/admin.AuditFileLogIds'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Response'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.Response'
security:
- token: []
summary: 文件日志批量删除
tags:
- 文件日志
/admin/audit_file/delete:
post: post:
consumes: consumes:
- application/json - application/json
@@ -1309,7 +1463,7 @@ paths:
summary: 文件日志删除 summary: 文件日志删除
tags: tags:
- 文件日志 - 文件日志
/admin/audit_conn/list: /admin/audit_file/list:
get: get:
consumes: consumes:
- application/json - application/json
@@ -1352,6 +1506,69 @@ paths:
summary: 文件日志列表 summary: 文件日志列表
tags: tags:
- 文件日志 - 文件日志
/admin/config/admin:
get:
consumes:
- application/json
description: ADMIN服务配置
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Response'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.Response'
security:
- token: []
summary: ADMIN服务配置
tags:
- ADMIN
/admin/config/app:
get:
consumes:
- application/json
description: APP服务配置
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Response'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.Response'
security:
- token: []
summary: APP服务配置
tags:
- ADMIN
/admin/config/server:
get:
consumes:
- application/json
description: 服务配置,给webclient提供api-server
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Response'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.Response'
security:
- token: []
summary: RUSTDESK服务配置
tags:
- ADMIN
/admin/file/oss_token: /admin/file/oss_token:
get: get:
consumes: consumes:
@@ -1619,14 +1836,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.LoginLog' $ref: '#/definitions/admin.LoginLogIds'
produces: produces:
- application/json - application/json
responses: responses:
@@ -1640,7 +1857,7 @@ paths:
$ref: '#/definitions/response.Response' $ref: '#/definitions/response.Response'
security: security:
- token: [] - token: []
summary: 登录日志删除 summary: 登录日志批量删除
tags: tags:
- 登录日志 - 登录日志
/admin/login_log/detail/{id}: /admin/login_log/detail/{id}:
@@ -2542,7 +2759,7 @@ paths:
get: get:
consumes: consumes:
- application/json - application/json
description: 设备列表 description: 我的设备列表
parameters: parameters:
- description: 页码 - description: 页码
in: query in: query
@@ -2586,7 +2803,7 @@ paths:
$ref: '#/definitions/response.Response' $ref: '#/definitions/response.Response'
security: security:
- token: [] - token: []
summary: 设备列表 summary: 我的设备列表
tags: tags:
- 设备 - 设备
/admin/user/update: /admin/user/update:

View File

@@ -81,6 +81,37 @@ func (a *Audit) ConnDelete(c *gin.Context) {
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound")) response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
} }
// BatchConnDelete 删除
// @Tags 链接日志
// @Summary 链接日志批量删除
// @Description 链接日志批量删除
// @Accept json
// @Produce json
// @Param body body admin.AuditConnLogIds true "链接日志"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/audit_conn/batchDelete [post]
// @Security token
func (a *Audit) BatchConnDelete(c *gin.Context) {
f := &admin.AuditConnLogIds{}
if err := c.ShouldBindJSON(f); err != nil {
response.Fail(c, 101, response.TranslateMsg(c, "ParamsError")+err.Error())
return
}
if len(f.Ids) == 0 {
response.Fail(c, 101, response.TranslateMsg(c, "ParamsError"))
return
}
err := service.AllService.AuditService.BatchDeleteAuditConn(f.Ids)
if err == nil {
response.Success(c, nil)
return
}
response.Fail(c, 101, err.Error())
return
}
// FileList 列表 // FileList 列表
// @Tags 文件日志 // @Tags 文件日志
// @Summary 文件日志列表 // @Summary 文件日志列表
@@ -93,7 +124,7 @@ func (a *Audit) ConnDelete(c *gin.Context) {
// @Param from_peer query int false "来源设备" // @Param from_peer query int false "来源设备"
// @Success 200 {object} response.Response{data=model.AuditFileList} // @Success 200 {object} response.Response{data=model.AuditFileList}
// @Failure 500 {object} response.Response // @Failure 500 {object} response.Response
// @Router /admin/audit_conn/list [get] // @Router /admin/audit_file/list [get]
// @Security token // @Security token
func (a *Audit) FileList(c *gin.Context) { func (a *Audit) FileList(c *gin.Context) {
query := &admin.AuditQuery{} query := &admin.AuditQuery{}
@@ -122,7 +153,7 @@ func (a *Audit) FileList(c *gin.Context) {
// @Param body body model.AuditFile true "文件日志信息" // @Param body body model.AuditFile true "文件日志信息"
// @Success 200 {object} response.Response // @Success 200 {object} response.Response
// @Failure 500 {object} response.Response // @Failure 500 {object} response.Response
// @Router /admin/audit_conn/delete [post] // @Router /admin/audit_file/delete [post]
// @Security token // @Security token
func (a *Audit) FileDelete(c *gin.Context) { func (a *Audit) FileDelete(c *gin.Context) {
f := &model.AuditFile{} f := &model.AuditFile{}
@@ -148,3 +179,34 @@ func (a *Audit) FileDelete(c *gin.Context) {
} }
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound")) response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
} }
// BatchFileDelete 删除
// @Tags 文件日志
// @Summary 文件日志批量删除
// @Description 文件日志批量删除
// @Accept json
// @Produce json
// @Param body body admin.AuditFileLogIds true "文件日志"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/audit_file/batchDelete [post]
// @Security token
func (a *Audit) BatchFileDelete(c *gin.Context) {
f := &admin.AuditFileLogIds{}
if err := c.ShouldBindJSON(f); err != nil {
response.Fail(c, 101, response.TranslateMsg(c, "ParamsError")+err.Error())
return
}
if len(f.Ids) == 0 {
response.Fail(c, 101, response.TranslateMsg(c, "ParamsError"))
return
}
err := service.AllService.AuditService.BatchDeleteAuditFile(f.Ids)
if err == nil {
response.Success(c, nil)
return
}
response.Fail(c, 101, err.Error())
return
}

View File

@@ -0,0 +1,79 @@
package admin
import (
"Gwen/global"
"Gwen/http/response"
"Gwen/service"
"github.com/gin-gonic/gin"
"os"
"strings"
)
type Config struct {
}
// ServerConfig RUSTDESK服务配置
// @Tags ADMIN
// @Summary RUSTDESK服务配置
// @Description 服务配置,给webclient提供api-server
// @Accept json
// @Produce json
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/config/server [get]
// @Security token
func (co *Config) ServerConfig(c *gin.Context) {
cf := &response.ServerConfigResponse{
IdServer: global.Config.Rustdesk.IdServer,
Key: global.Config.Rustdesk.Key,
RelayServer: global.Config.Rustdesk.RelayServer,
ApiServer: global.Config.Rustdesk.ApiServer,
}
response.Success(c, cf)
}
// AppConfig APP服务配置
// @Tags ADMIN
// @Summary APP服务配置
// @Description APP服务配置
// @Accept json
// @Produce json
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/config/app [get]
// @Security token
func (co *Config) AppConfig(c *gin.Context) {
response.Success(c, &gin.H{
"web_client": global.Config.App.WebClient,
})
}
// AdminConfig ADMIN服务配置
// @Tags ADMIN
// @Summary ADMIN服务配置
// @Description ADMIN服务配置
// @Accept json
// @Produce json
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/config/admin [get]
// @Security token
func (co *Config) AdminConfig(c *gin.Context) {
u := service.AllService.UserService.CurUser(c)
hello := global.Config.Admin.Hello
helloFile := global.Config.Admin.HelloFile
if helloFile != "" {
b, err := os.ReadFile(helloFile)
if err == nil && len(b) > 0 {
hello = string(b)
}
}
//replace {{username}} to username
hello = strings.Replace(hello, "{{username}}", u.Username, -1)
response.Success(c, &gin.H{
"title": global.Config.Admin.Title,
"hello": hello,
})
}

View File

@@ -109,3 +109,34 @@ func (ct *LoginLog) Delete(c *gin.Context) {
} }
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound")) response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
} }
// BatchDelete 删除
// @Tags 登录日志
// @Summary 登录日志批量删除
// @Description 登录日志批量删除
// @Accept json
// @Produce json
// @Param body body admin.LoginLogIds true "登录日志"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/login_log/delete [post]
// @Security token
func (ct *LoginLog) BatchDelete(c *gin.Context) {
f := &admin.LoginLogIds{}
if err := c.ShouldBindJSON(f); err != nil {
response.Fail(c, 101, response.TranslateMsg(c, "ParamsError")+err.Error())
return
}
if len(f.Ids) == 0 {
response.Fail(c, 101, response.TranslateMsg(c, "ParamsError"))
return
}
err := service.AllService.LoginLogService.BatchDelete(f.Ids)
if err == nil {
response.Success(c, nil)
return
}
response.Fail(c, 101, err.Error())
return
}

View File

@@ -295,10 +295,10 @@ func (ct *User) MyOauth(c *gin.Context) {
response.Success(c, res) response.Success(c, res)
} }
// List 列表 // MyPeer 列表
// @Tags 设备 // @Tags 设备
// @Summary 设备列表 // @Summary 我的设备列表
// @Description 设备列表 // @Description 我的设备列表
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param page query int false "页码" // @Param page query int false "页码"

View File

@@ -5,3 +5,10 @@ type AuditQuery struct {
FromPeer string `form:"from_peer"` FromPeer string `form:"from_peer"`
PageQuery PageQuery
} }
type AuditConnLogIds struct {
Ids []uint `json:"ids" validate:"required"`
}
type AuditFileLogIds struct {
Ids []uint `json:"ids" validate:"required"`
}

View File

@@ -15,3 +15,7 @@ type LoginTokenQuery struct {
UserId int `form:"user_id"` UserId int `form:"user_id"`
PageQuery PageQuery
} }
type LoginLogIds struct {
Ids []uint `json:"ids" validate:"required"`
}

View File

@@ -31,9 +31,14 @@ func Init(g *gin.Engine) {
AddressBookCollectionBind(adg) AddressBookCollectionBind(adg)
AddressBookCollectionRuleBind(adg) AddressBookCollectionRuleBind(adg)
UserTokenBind(adg) UserTokenBind(adg)
ConfigBind(adg)
//deprecated by ConfigBind
rs := &admin.Rustdesk{} rs := &admin.Rustdesk{}
adg.GET("/server-config", rs.ServerConfig) adg.GET("/server-config", rs.ServerConfig)
adg.GET("/app-config", rs.AppConfig) adg.GET("/app-config", rs.AppConfig)
//deprecated end
//访问静态文件 //访问静态文件
//g.StaticFS("/upload", http.Dir(global.Config.Gin.ResourcesPath+"/upload")) //g.StaticFS("/upload", http.Dir(global.Config.Gin.ResourcesPath+"/upload"))
} }
@@ -149,15 +154,18 @@ func LoginLogBind(rg *gin.RouterGroup) {
cont := &admin.LoginLog{} cont := &admin.LoginLog{}
aR.GET("/list", cont.List) aR.GET("/list", cont.List)
aR.POST("/delete", cont.Delete) aR.POST("/delete", cont.Delete)
aR.POST("/batchDelete", cont.BatchDelete)
} }
func AuditBind(rg *gin.RouterGroup) { func AuditBind(rg *gin.RouterGroup) {
cont := &admin.Audit{} cont := &admin.Audit{}
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)
aR.POST("/batchDelete", cont.BatchConnDelete)
afR := rg.Group("/audit_file").Use(middleware.AdminPrivilege()) afR := rg.Group("/audit_file").Use(middleware.AdminPrivilege())
afR.GET("/list", cont.FileList) afR.GET("/list", cont.FileList)
afR.POST("/delete", cont.FileDelete) afR.POST("/delete", cont.FileDelete)
afR.POST("/batchDelete", cont.BatchFileDelete)
} }
func AddressBookCollectionBind(rg *gin.RouterGroup) { func AddressBookCollectionBind(rg *gin.RouterGroup) {
aR := rg.Group("/address_book_collection") aR := rg.Group("/address_book_collection")
@@ -188,6 +196,13 @@ func UserTokenBind(rg *gin.RouterGroup) {
aR.GET("/list", cont.List) aR.GET("/list", cont.List)
aR.POST("/delete", cont.Delete) aR.POST("/delete", cont.Delete)
} }
func ConfigBind(rg *gin.RouterGroup) {
aR := rg.Group("/config")
rs := &admin.Config{}
aR.GET("/server", rs.ServerConfig)
aR.GET("/app", rs.AppConfig)
aR.GET("/admin", rs.AdminConfig)
}
/* /*
func FileBind(rg *gin.RouterGroup) { func FileBind(rg *gin.RouterGroup) {

View File

@@ -85,3 +85,11 @@ func (as *AuditService) DeleteAuditFile(u *model.AuditFile) error {
func (as *AuditService) UpdateAuditFile(u *model.AuditFile) error { func (as *AuditService) UpdateAuditFile(u *model.AuditFile) error {
return global.DB.Model(u).Updates(u).Error return global.DB.Model(u).Updates(u).Error
} }
func (as *AuditService) BatchDeleteAuditConn(ids []uint) error {
return global.DB.Where("id in (?)", ids).Delete(&model.AuditConn{}).Error
}
func (as *AuditService) BatchDeleteAuditFile(ids []uint) error {
return global.DB.Where("id in (?)", ids).Delete(&model.AuditFile{}).Error
}

View File

@@ -43,3 +43,7 @@ func (us *LoginLogService) Delete(u *model.LoginLog) error {
func (us *LoginLogService) Update(u *model.LoginLog) error { func (us *LoginLogService) Update(u *model.LoginLog) error {
return global.DB.Model(u).Updates(u).Error return global.DB.Model(u).Updates(u).Error
} }
func (us *LoginLogService) BatchDelete(ids []uint) error {
return global.DB.Where("id in (?)", ids).Delete(&model.LoginLog{}).Error
}