Compare commits

..
16 Commits
Author SHA1 Message Date
ssongliu 67ce559b12 fix: 概览页磁盘信息获取增加锁 (#3100) 2023-11-29 15:34:51 +08:00
ssongliu 71869b7264 fix: 概览页磁盘显示优化 (#3096) 2023-11-29 14:44:02 +08:00
ssongliu 03774bbba6 fix: 概览页磁盘信息获取增加超时时间 (#3074)
Refs #2825
2023-11-28 15:10:35 +08:00
igophper e07b6bc050 fix: 类名重命名 2023-11-28 15:10:26 +08:00
igophper b1935d8368 fix: 修复网站404重定向次数过多 (#3054) (#3056)
Refs #3054
2023-11-28 15:10:17 +08:00
江杭辉 f8e344db76 fix: 修复登录菜单消失 2023-11-23 22:20:06 +08:00
江杭辉 2c3a8dd6af fix: 修复登录菜单消失 2023-11-23 22:20:01 +08:00
江杭辉 86e5fc36f4 fix: 修复登录菜单消失 2023-11-23 22:19:56 +08:00
江杭辉 858cefc0c9 fix: mfa登录菜单消失 2023-11-23 22:19:53 +08:00
ssongliu 4535c0b90b fix: 解决镜像仓库编辑失败的问题 (#3029) 2023-11-23 22:19:43 +08:00
zhengkunwang 136489e346 fix: 解决网站某些设置会报服务器内部错误的问题 (#2973)
Refs https://github.com/1Panel-dev/1Panel/issues/2955
2023-11-23 22:18:20 +08:00
wanghe e2882fd1cc Update sonar-project.properties (#3004) 2023-11-23 22:17:15 +08:00
hzz dba97076df fix: 本地数据备份命令增加 --default-character-set 参数 与备份还原的编码保持一致 2023-11-23 22:17:02 +08:00
QuentinHsu 000bcd37c1 fix: FileRole 初始化 (#2956) 2023-11-23 22:16:53 +08:00
wanghe bf28223745 Update README.md (#2937) 2023-11-23 22:16:47 +08:00
maninhill 1fed5c4d15 Update README.md 2023-11-23 22:16:42 +08:00
970 changed files with 38617 additions and 170874 deletions
-4
View File
@@ -1,5 +1 @@
*.ts linguist-language=Go *.ts linguist-language=Go
*.js linguist-language=Go
*.css linguist-language=Go
*.scss linguist-language=Go
*.html linguist-language=Go
+1
View File
@@ -0,0 +1 @@
custom: ["https://afdian.net/a/1Panel"]
-50
View File
@@ -1,50 +0,0 @@
name: 'Bug Report'
description: 'Report an Bug'
title: '[Bug] '
assignees: wanghe-fit2cloud
body:
- type: markdown
attributes:
value: "## Contact Information"
- type: input
validations:
required: false
attributes:
label: "Contact Information"
description: "The ways to quickly contact you: WeChat group number and nickname, email, etc."
- type: markdown
attributes:
value: "## Environment Information"
- type: input
validations:
required: true
attributes:
label: "1Panel Version"
description: "Log in to the 1Panel Web console and check the current version at the bottom right of the page."
- type: markdown
attributes:
value: "## Detailed information"
- type: textarea
attributes:
label: "Problem Description"
description: "Briefly describe the issue you’ve encountered."
validations:
required: true
- type: textarea
attributes:
label: "Steps to Reproduce"
description: "How can this issue be reproduced."
validations:
required: true
- type: textarea
attributes:
label: "The expected correct result"
- type: textarea
attributes:
label: "Related log output"
description: "Please paste any relevant log output here. It will automatically be formatted as code, so no backticks are necessary."
render: shell
- type: textarea
attributes:
label: "Additional Information"
description: "If you have any additional information to provide, you can include it here (screenshots, videos, etc., are welcome)."
@@ -1,29 +0,0 @@
name: 'Feature Request'
description: 'Suggest an idea'
title: '[Feature] '
assignees: wanghe-fit2cloud
body:
- type: markdown
attributes:
value: "## Environment Information"
- type: input
validations:
required: true
attributes:
label: "1Panel Version"
description: "Log in to the 1Panel Web console and check the current version at the bottom right of the page."
- type: markdown
attributes:
value: "## Detailed information"
- type: textarea
attributes:
label: "Please describe your needs or suggestions for improvements"
validations:
required: true
- type: textarea
attributes:
label: "Please describe the solution you suggest"
- type: textarea
attributes:
label: "Additional Information"
description: "If you have any additional information to provide, you can include it here (screenshots, videos, etc., are welcome)."
+61
View File
@@ -0,0 +1,61 @@
name: BUG 提交
description: 提交产品缺陷帮助我们更好的改进
title: "[BUG]"
labels: "类型: 缺陷"
assignees: wanghe-fit2cloud
body:
- type: markdown
id: contacts_title
attributes:
value: "## 联系方式"
- type: input
id: contacts
validations:
required: false
attributes:
label: "联系方式"
description: "可以快速联系到您的方式:交流群号及昵称、邮箱等"
- type: markdown
id: environment
attributes:
value: "## 环境信息"
- type: input
id: version
validations:
required: true
attributes:
label: "1Panel 版本"
description: "登录 1Panel Web 控制台,在页面右下角查看当前版本。"
- type: markdown
id: details
attributes:
value: "## 详细信息"
- type: textarea
id: what-happened
attributes:
label: "问题描述"
description: "简要描述您碰到的问题"
validations:
required: true
- type: textarea
id: how-happened
attributes:
label: "重现步骤"
description: "如果操作可以重现该问题"
validations:
required: true
- type: textarea
id: expect
attributes:
label: "期待的正确结果"
- type: textarea
id: logs
attributes:
label: "相关日志输出"
description: "请复制并粘贴任何相关的日志输出。 这将自动格式化为代码,因此无需反引号。"
render: shell
- type: textarea
id: additional-information
attributes:
label: "附加信息"
description: "如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。"
+6 -3
View File
@@ -1,5 +1,8 @@
blank_issues_enabled: false blank_issues_enabled: false
contact_links: contact_links:
- name: Questions & Discussions - name: 对 1Panel 项目有其他问题
url: https://github.com/1Panel-dev/1Panel/discussions url: https://1panel.cn
about: Raise questions about the installation, deployment, use and other aspects of the project. about: 如果想要进一步了解 1Panel 项目,欢迎发送邮件到 support@fit2cloud.com 进行提问。
- name: 反馈安全问题 (Report Security Bug)
url: mailto://support@fit2cloud.com
about: 请通过邮箱 support@fit2cloud.com 反馈安全问题 (Please report security vulnerabilities to support@fit2cloud.com)
+36
View File
@@ -0,0 +1,36 @@
name: 需求建议
description: 提出针对本项目的想法和建议
title: "[FEATURE]"
labels: enhancement
assignees: wanghe-fit2cloud
body:
- type: markdown
id: environment
attributes:
value: "## 环境信息"
- type: input
id: version
validations:
required: true
attributes:
label: "1Panel 版本"
description: "登录 1Panel Web 控制台,在页面右下角查看当前版本。"
- type: markdown
id: details
attributes:
value: "## 详细信息"
- type: textarea
id: description
attributes:
label: "请描述您的需求或者改进建议"
validations:
required: true
- type: textarea
id: solution
attributes:
label: "请描述你建议的实现方案"
- type: textarea
id: additional-information
attributes:
label: "附加信息"
description: "如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。"
+12
View File
@@ -0,0 +1,12 @@
name: 问题咨询
description: 提出针对本项目安装部署、使用及其他方面的相关问题
title: "[QUESTION]"
labels: question
assignees: wanghe-fit2cloud
body:
- type: textarea
id: description
attributes:
label: "请描述您的问题"
validations:
required: true
+6 -3
View File
@@ -1,13 +1,16 @@
name: General PR Handling for 1Panel
on: pull_request on: pull_request
name: 1Panel 通用 PR 处理
permissions: permissions:
pull-requests: write pull-requests: write
jobs: jobs:
generic_handler: generic_handler:
name: Add Labels to PR name: 为 PR 添加标签
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v2
- uses: actions-ecosystem/action-add-labels@v1 - uses: actions-ecosystem/action-add-labels@v1
with: with:
github_token: ${{ secrets.GITHUBTOKEN }} github_token: ${{ secrets.GITHUBTOKEN }}
@@ -1,47 +0,0 @@
name: Create Release And Upload assets
on:
push:
tags:
- 'v*'
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '22.19.0'
- name: Build Web
run: |
cd frontend && npm install && npm run build:pro
env:
NODE_OPTIONS: --max-old-space-size=8192
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Build Release
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: release --skip=publish --clean
- name: Upload Assets
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
files: |
dist/*.tar.gz
dist/checksums.txt
- name: Setup OSSUTIL
uses: yizhoumo/setup-ossutil@v2
with:
endpoint: ${{ secrets.OSS_ENDPOINT }}
access-key-id: ${{ secrets.OSS_ACCESS_KEY_ID }}
access-key-secret: ${{ secrets.OSS_ACCESS_KEY_SECRET }}
ossutil-version: '1.7.18'
- name: Upload Assets to OSS
run: ossutil cp -r dist/ oss://resource-fit2cloud-com/1panel/package/stable/${{ github.ref_name }}/release/ --include "*.tar.gz" --include "checksums.txt" --only-current-dir --force
-45
View File
@@ -1,45 +0,0 @@
name: Create Release And Upload Cloudflare R2
on:
push:
tags:
- 'v*'
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '22.19.0'
- name: Build Web
run: |
cd frontend && npm install && npm run build:pro
env:
NODE_OPTIONS: --max-old-space-size=8192
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Build Release
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: release --skip=publish --clean
- name: Upload Assets
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
files: |
dist/*.tar.gz
dist/checksums.txt
- name: Setup Rclone
uses: AnimMouse/setup-rclone@v1
with:
rclone_config: ${{ secrets.RCLONE_CONFIG }}
- name: Upload to Cloudflare R2
run: |
rclone copy dist/ cloudflare_r2:package/stable/${{ github.ref_name }}/release/ --include "*.tar.gz" --include "checksums.txt" --progress
+34
View File
@@ -0,0 +1,34 @@
on:
pull_request:
branches:
- dev
push:
branches:
- dev
name: Build Test
jobs:
build-linux-binary:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '18.14'
- name: Build Web
id: build_frontend
run: |
cd frontend && npm install && npm run build:pro
env:
NODE_OPTIONS: --max-old-space-size=8192
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.20.x'
- name: Build Server
uses: goreleaser/goreleaser-action@v4
with:
args: release --snapshot --clean
@@ -1,4 +1,4 @@
name: SonarCloud Scan name: Build
on: on:
push: push:
branches: branches:
+17
View File
@@ -0,0 +1,17 @@
on:
schedule:
- cron: "0 1 * * *"
name: Check recent handle issues
jobs:
check-recent-issues-not-handle:
runs-on: ubuntu-latest
steps:
- name: Check recent issues and send msg
uses: jumpserver/action-issues-alert@master
with:
hook: ${{ secrets.WECHAT_GROUP_WEB_HOOK }}
type: recent
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-14
View File
@@ -1,14 +0,0 @@
name: Issue Translator
on:
issue_comment:
types: [created]
issues:
types: [opened]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: usthe/issues-translate-action@v2.7
with:
IS_MODIFY_TITLE: true
BOT_GITHUB_TOKEN: ${{ secrets.ISSUE_TRANSLATOR_TOKEN }}
@@ -0,0 +1,17 @@
on:
schedule:
- cron: "0 9 * * 1-5"
name: Check untimely handle issues
jobs:
check-untimely-handle-issues:
runs-on: ubuntu-latest
steps:
- name: Check untimely issues and send msg
uses: jumpserver/action-issues-alert@master
with:
hook: ${{ secrets.WECHAT_GROUP_WEB_HOOK }}
type: untimely
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-25
View File
@@ -1,25 +0,0 @@
name: LLM Code Review
permissions:
contents: read
pull-requests: write
on:
pull_request:
types: [opened, reopened, synchronize]
jobs:
llm-code-review:
runs-on: ubuntu-latest
steps:
- uses: fit2cloud/LLM-CodeReview-Action@main
env:
GITHUB_TOKEN: ${{ secrets.FIT2CLOUDRD_LLM_CODE_REVIEW_TOKEN }}
OPENAI_API_KEY: ${{ secrets.ALIYUN_LLM_API_KEY }}
LANGUAGE: English
OPENAI_API_ENDPOINT: https://dashscope.aliyuncs.com/compatible-mode/v1
MODEL: qwen2.5-coder-3b-instruct
PROMPT: "Please check the following code differences for any irregularities, potential issues, or optimization suggestions, and provide your answers in English."
top_p: 1
temperature: 1
# max_tokens: 10000
MAX_PATCH_LENGTH: 10000
IGNORE_PATTERNS: "/node_modules,*.md,/dist,/.github"
FILE_PATTERNS: "*.java,*.go,*.py,*.vue,*.ts,*.js,*.css,*.scss,*.html"
+66
View File
@@ -0,0 +1,66 @@
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
name: Create Release And Upload assets
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '18.14'
- name: Build Web
run: |
cd frontend && npm install && npm run build:pro
env:
NODE_OPTIONS: --max-old-space-size=8192
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.20.x'
- name: Build Release
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --skip-publish --clean
- name: Upload Assets
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
body: |
# 一、安装和升级
## 1.1 一键安装
```sh
curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && sudo bash quick_start.sh
```
## 1.2 在线升级
登录 1Panel Web 控制台,在页面右下角点击 **【检查更新】** 进行在线升级。
>更多信息请查阅在线文档:https://1panel.cn/docs/
# 二、更新日志
files: |
dist/*.tar.gz
dist/checksums.txt
- name: Setup OSSUTIL
uses: yizhoumo/setup-ossutil@v1
with:
endpoint: ${{ secrets.OSS_ENDPOINT }}
access-key-id: ${{ secrets.OSS_ACCESS_KEY_ID }}
access-key-secret: ${{ secrets.OSS_ACCESS_KEY_SECRET }}
ossutil-version: '1.7.14'
- name: Upload Assets to OSS
run: ossutil cp -r dist/ oss://resource-fit2cloud-com/1panel/package/stable/${{ github.ref_name }}/release/ --include "*.tar.gz" --include "checksums.txt" --only-current-dir --force
+3 -2
View File
@@ -1,5 +1,6 @@
name: Synchronize to Gitee name: sync2gitee
on: [push] on: [push]
jobs: jobs:
repo-sync: repo-sync:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -8,7 +9,7 @@ jobs:
uses: Yikun/hub-mirror-action@master uses: Yikun/hub-mirror-action@master
with: with:
src: 'github/1Panel-dev' src: 'github/1Panel-dev'
dst: 'gitee/fit2cloud-feizhiyun' dst: 'gitee/fit2cloud-xlab'
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }} dst_token: ${{ secrets.GITEE_TOKEN }}
static_list: "1Panel" static_list: "1Panel"
-11
View File
@@ -1,11 +0,0 @@
name: Typos Check
on: pull_request
jobs:
run:
name: Spell Check with Typos
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v2
- name: Check spelling
uses: crate-ci/typos@master
+10 -6
View File
@@ -16,12 +16,19 @@ build/1panel
*.factorypath *.factorypath
# IntelliJ IDEA # IntelliJ IDEA
.idea/* .idea
!.idea/icon.png
*.iws *.iws
*.iml *.iml
*.ipr *.ipr
# NetBeans
nbproject/private/
build/
nbbuild/
dist/
nbdist/
.nb-gradle/
# Test binary, built with `go test -c` # Test binary, built with `go test -c`
*.test *.test
@@ -37,9 +44,7 @@ cmd/server/web/monacoeditorwork
cmd/server/web/index.html cmd/server/web/index.html
frontend/auto-imports.d.ts frontend/auto-imports.d.ts
frontend/components.d.ts frontend/components.d.ts
frontend/src/xpack
backend/xpack
*_xpack.go
.history/ .history/
dist/ dist/
1pctl 1pctl
@@ -48,4 +53,3 @@ install.sh
quick_start.sh quick_start.sh
cmd/server/fileList.txt cmd/server/fileList.txt
.fileList.txt .fileList.txt
1Panel.code-workspace
+21 -19
View File
@@ -1,13 +1,11 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json # This is an example .goreleaser.yml file with some sensible defaults.
# vim: set ts=2 sw=2 tw=0 fo=jcroql # Make sure to check the documentation at https://goreleaser.com
version: 2
before: before:
hooks: hooks:
# - export NODE_OPTIONS="--max-old-space-size=8192" # - export NODE_OPTIONS="--max-old-space-size=8192"
# - make build_web # - make build_web
- chmod +x ./ci/script.sh - chmod +x ./script.sh
- ./ci/script.sh - ./script.sh
- sed -i 's@ORIGINAL_VERSION=.*@ORIGINAL_VERSION=v{{ .Version }}@g' 1pctl - sed -i 's@ORIGINAL_VERSION=.*@ORIGINAL_VERSION=v{{ .Version }}@g' 1pctl
- go mod tidy - go mod tidy
@@ -15,7 +13,6 @@ builds:
- main: ./cmd/server/main.go - main: ./cmd/server/main.go
binary: 1panel binary: 1panel
flags: flags:
- -tags=xpack
- -trimpath - -trimpath
ldflags: ldflags:
- -w -s - -w -s
@@ -31,26 +28,31 @@ builds:
- arm - arm
- ppc64le - ppc64le
- s390x - s390x
- riscv64
archives: archives:
- formats: [ 'tar.gz' ] - format: tar.gz
name_template: "1panel-v{{ .Version }}-{{ .Os }}-{{ .Arch }}{{- if .Arm }}v{{ .Arm }}{{ end }}" name_template: "1panel-v{{ .Version }}-{{ .Os }}-{{ .Arch }}{{- if .Arm }}v{{ .Arm }}{{ end }}"
wrap_in_directory: true wrap_in_directory: true
files: files:
- 1pctl - 1pctl
- install.sh
- 1panel.service - 1panel.service
- initscript/* - install.sh
- lang/* - README.md
- GeoIP.mmdb - LICENSE
checksum: checksum:
name_template: 'checksums.txt' name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
release:
draft: true
mode: append
extra_files:
- glob: dist/*.tar.gz
- glob: dist/checksums.txt
name_template: "Release {{.Tag}}"
changelog: # The lines beneath this are called `modelines`. See `:help modeline`
sort: asc # Feel free to remove those if you don't want/use them.
filters: # yaml-language-server: $schema=https://goreleaser.com/static/schema.json
exclude: # vim: set ts=2 sw=2 tw=0 fo=cnqoj
- "^docs:"
- "^test:"
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

+3
View File
@@ -0,0 +1,3 @@
{
"ansible.python.interpreterPath": "/opt/homebrew/bin/python3"
}
+2 -7
View File
@@ -1,16 +1,11 @@
# Contributing # Contributing
As a contributor, you should agree that:
- The producer can adjust the open-source agreement to be more strict or relaxed as deemed necessary.
- Your contributed code may be used for commercial purposes, including but not limited to its cloud business operations.
## Create pull request ## Create pull request
PR are always welcome, even if they only contain small fixes like typos or a few lines of code. If there will be a significant effort, please document it as an issue and get a discussion going before starting to work on it. PR are always welcome, even if they only contain small fixes like typos or a few lines of code. If there will be a significant effort, please document it as an issue and get a discussion going before starting to work on it.
Please submit a PR broken down into small changes bit by bit. A PR consisting of a lot of features and code changes may be hard to review. It is recommended to submit PRs in an incremental fashion. Please submit a PR broken down into small changes bit by bit. A PR consisting of a lot features and code changes may be hard to review. It is recommended to submit PRs in an incremental fashion.
This [development guideline](https://docs.1panel.pro/dev_manual/dev_manual/) contains information about repository structure, how to set up development environment, how to run it, and more. This [development guideline](https://kubeoperator.io/docs/dev/dev_manual/) contains information about repository structure, how to setup development environment, how to run it, and more.
Note: If you split your pull request to small changes, please make sure any of the changes goes to master will not break anything. Otherwise, it can not be merged until this feature complete. Note: If you split your pull request to small changes, please make sure any of the changes goes to master will not break anything. Otherwise, it can not be merged until this feature complete.
+9 -9
View File
@@ -2,15 +2,15 @@ GOCMD=go
GOBUILD=$(GOCMD) build GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean GOCLEAN=$(GOCMD) clean
GOARCH=$(shell go env GOARCH) GOARCH=$(shell go env GOARCH)
GOOS=$(shell go env GOOS) GOOS=$(shell go env GOOS )
BASE_PATH := $(shell pwd) BASE_PAH := $(shell pwd)
BUILD_PATH = $(BASE_PATH)/build BUILD_PATH = $(BASE_PAH)/build
WEB_PATH=$(BASE_PATH)/frontend WEB_PATH=$(BASE_PAH)/frontend
SERVER_PATH=$(BASE_PATH)/backend SERVER_PATH=$(BASE_PAH)/backend
MAIN= $(BASE_PATH)/cmd/server/main.go MAIN= $(BASE_PAH)/cmd/server/main.go
APP_NAME=1panel APP_NAME=1panel
ASSERT_PATH= $(BASE_PATH)/cmd/server/web/assets ASSERT_PATH= $(BASE_PAH)/cmd/server/web/assets
clean_assets: clean_assets:
rm -rf $(ASSERT_PATH) rm -rf $(ASSERT_PATH)
@@ -23,7 +23,7 @@ build_frontend:
build_backend_on_linux: build_backend_on_linux:
cd $(SERVER_PATH) \ cd $(SERVER_PATH) \
&& CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) $(GOBUILD) -trimpath -ldflags '-s -w' -o $(BUILD_PATH)/$(APP_NAME) $(MAIN) && GOOS=$(GOOS) GOARCH=$(GOARCH) $(GOBUILD) -trimpath -ldflags '-s -w' -o $(BUILD_PATH)/$(APP_NAME) $(MAIN)
build_backend_on_darwin: build_backend_on_darwin:
cd $(SERVER_PATH) \ cd $(SERVER_PATH) \
@@ -31,4 +31,4 @@ build_backend_on_darwin:
build_all: build_frontend build_backend_on_linux build_all: build_frontend build_backend_on_linux
build_on_local: clean_assets build_frontend build_backend_on_darwin build_on_local: clean_assets build_frontend build_backend_on_darwin upx_bin
+4 -2
View File
@@ -1,9 +1,11 @@
reviewers: reviewers:
- wanghe-fit2cloud
- zhengkunwang223 - zhengkunwang223
- ssongliu - ssongliu
- wanghe-fit2cloud
- wangdan-fit2cloud
approvers: approvers:
- wanghe-fit2cloud
- zhengkunwang223 - zhengkunwang223
- ssongliu - ssongliu
- wanghe-fit2cloud
- wangdan-fit2cloud
+41 -56
View File
@@ -1,87 +1,72 @@
<p align="center"><a href="https://1panel.pro"><img src="https://resource.1panel.pro/img/1panel-logo.png" alt="1Panel" width="300" /></a></p> <p align="center"><a href="https://1panel.cn"><img src="http://1panel.oss-cn-hangzhou.aliyuncs.com/img/1panel-logo.png" alt="1Panel" width="300" /></a></p>
<p align="center"><b>Simplify Linux Server Management</b></p> <p align="center"><b>现代化、开源的 Linux 服务器运维管理面板</b></p>
<p align="center">
<a href="https://trendshift.io/repositories/2462" target="_blank"><img src="https://trendshift.io/api/badge/repositories/2462" alt="1Panel-dev%2F1Panel | Trendshift" style="width: 240px; height: auto;" /></a>
</p>
<p align="center"> <p align="center">
<a href="https://www.gnu.org/licenses/gpl-3.0.html"><img src="https://shields.io/github/license/1Panel-dev/1Panel?color=%231890FF" alt="License: GPL v3"></a> <a href="https://www.gnu.org/licenses/gpl-3.0.html"><img src="https://shields.io/github/license/1Panel-dev/1Panel?color=%231890FF" alt="License: GPL v3"></a>
<a href="https://app.codacy.com/gh/1Panel-dev/1Panel?utm_source=github.com&utm_medium=referral&utm_content=1Panel-dev/1Panel&utm_campaign=Badge_Grade_Dashboard"><img src="https://app.codacy.com/project/badge/Grade/da67574fd82b473992781d1386b937ef" alt="Codacy"></a> <a href="https://app.codacy.com/gh/1Panel-dev/1Panel?utm_source=github.com&utm_medium=referral&utm_content=1Panel-dev/1Panel&utm_campaign=Badge_Grade_Dashboard"><img src="https://app.codacy.com/project/badge/Grade/da67574fd82b473992781d1386b937ef" alt="Codacy"></a>
<a href="https://discord.gg/bUpUqWqdRr" target="_blank">
<img src="https://img.shields.io/discord/1318846410149335080?logo=discord&labelColor=%20%235462eb&logoColor=%20%23f5f5f5&color=%20%235462eb"
alt="chat on Discord"></a>
<a href="https://github.com/1Panel-dev/1Panel/releases"><img src="https://img.shields.io/github/v/release/1Panel-dev/1Panel" alt="GitHub release"></a> <a href="https://github.com/1Panel-dev/1Panel/releases"><img src="https://img.shields.io/github/v/release/1Panel-dev/1Panel" alt="GitHub release"></a>
<a href="https://github.com/1Panel-dev/1Panel"><img src="https://img.shields.io/github/stars/1Panel-dev/1Panel?color=%231890FF&style=flat-square" alt="Stars"></a><br> <a href="https://github.com/1Panel-dev/1Panel"><img src="https://img.shields.io/github/stars/1Panel-dev/1Panel?color=%231890FF&style=flat-square" alt="Stars"></a>
</p> <a href="https://app.fossa.com/projects/git%2Bgithub.com%2F1Panel-dev%2F1Panel?ref=badge_shield"><img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2F1Panel-dev%2F1Panel.svg?type=shield" alt="FOSSA Status"></a><br>
<p align="center"> [<a href="docs/README_TW.md">中文(繁體)</a>] | [<a href="docs/README_EN.md">English</a>] | [<a href="docs/README_JP.md">日本語</a>]
<a href="/README.md"><img alt="English" src="https://img.shields.io/badge/English-d9d9d9"></a>
<a href="/docs/README.zh-Hans.md"><img alt="中文(简体)" src="https://img.shields.io/badge/中文(简体)-d9d9d9"></a>
<a href="/docs/README.ja.md"><img alt="日本語" src="https://img.shields.io/badge/日本語-d9d9d9"></a>
<a href="/docs/README.pt-br.md"><img alt="Português (Brasil)" src="https://img.shields.io/badge/Português (Brasil)-d9d9d9"></a>
<a href="/docs/README.ar.md"><img alt="العربية" src="https://img.shields.io/badge/العربية-d9d9d9"></a>
<a href="/docs/README.de.md"><img alt="Deutsch" src="https://img.shields.io/badge/Deutsch-d9d9d9"></a>
<a href="/docs/README.es.md"><img alt="Español" src="https://img.shields.io/badge/Español-d9d9d9"></a><br>
<a href="/docs/README.fr.md"><img alt="français" src="https://img.shields.io/badge/français-d9d9d9"></a>
<a href="/docs/README.ko.md"><img alt="한국어" src="https://img.shields.io/badge/한국어-d9d9d9"></a>
<a href="/docs/README.id.md"><img alt="Bahasa Indonesia" src="https://img.shields.io/badge/Bahasa Indonesia-d9d9d9"></a>
<a href="/docs/README.zh-Hant.md"><img alt="中文(繁體)" src="https://img.shields.io/badge/中文(繁體)-d9d9d9"></a>
<a href="/docs/README.tr.md"><img alt="Türkçe" src="https://img.shields.io/badge/Türkçe-d9d9d9"></a>
<a href="/docs/README.ru.md"><img alt="Русский" src="https://img.shields.io/badge/%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9-d9d9d9"></a>
<a href="/docs/README.ms.md"><img alt="Bahasa Melayu" src="https://img.shields.io/badge/Bahasa Melayu-d9d9d9"></a>
</p> </p>
------------------------------ ------------------------------
1Panel provides an intuitive web interface and MCP Server to manage websites, files, containers, databases, and LLMs on a Linux server. 1Panel 是一个现代化、开源的 Linux 服务器运维管理面板。1Panel 的功能和优势包括:
- **Efficient Management**: Through a user-friendly web graphical interface, 1Panel enables users to effortlessly manage their Linux servers. Key features include host monitoring, file management, database administration, container management, LLMs management. - **快速建站**:深度集成 Wordpress 和 [Halo](https://github.com/halo-dev/halo/),域名绑定、SSL 证书配置等一键搞定;
- **Rapid Website Deployment**: With deep integration of the popular open-source website building software WordPress, 1Panel streamlines the process of domain binding and SSL certificate configuration, all achievable with just one click. - **高效管理**:通过 Web 端轻松管理 Linux 服务器,包括主机监控、文件管理、数据库管理、容器管理等;
- **Application Store**: 1Panel curates a wide range of high-quality open-source tools and applications, facilitating easy installation and updates for its users. - **安全可靠**:基于容器来管理和部署应用,最小漏洞暴露面,提供防火墙和日志审计等功能;
- **Security and Reliability**: By leveraging containerization and secure application deployment practices, 1Panel minimizes vulnerability exposure. It further enhances security through integrated firewall management and log auditing capabilities. - **一键备份**:支持一键备份和恢复,备份数据到各类云端存储,永不丢失;
- **One-Click Backup & Restore**: Data protection is made simple with 1Panel's one-click backup and restore functionality, supporting various cloud storage solutions to ensure data integrity and availability. - **应用商店**:精选各类高质量开源工具和应用软件,助力您轻松安装和升级。
- **MCP Server**: [1Panel MCP Server](https://github.com/1Panel-dev/mcp-1panel) allow user to execute server operations via natural language.
## Quick Start ## UI 展示
Execute the script below and follow the prompts to install 1Panel: ![UI展示](https://resource.fit2cloud.com/1panel/img/overview.png)
```bash ## 快速开始
curl -sSL https://resource.1panel.pro/quick_start.sh -o quick_start.sh && bash quick_start.sh
**在线体验**
- 环境地址:<https://demo.1panel.cn/>
- 用户名:demo
- 密码:1panel
**一键安装**
执行如下命令一键安装 1Panel:
```sh
curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && sudo bash quick_start.sh
``` ```
Please refer to our [documentation](https://docs.1panel.pro/quick_start/) for more details. **学习资料**
中国用户请使用此 [安装脚本](https://1panel.cn/docs/v2/installation/online_installation/),默认安装 V2 版本,应用数量相较国际版本更丰富。 - [在线文档](https://1panel.cn/docs/)
- [教学视频](https://space.bilibili.com/510493147/channel/collectiondetail?sid=1199760)
- [社区论坛](https://bbs.fit2cloud.com/c/1p/7)
- [如何加入微信交流群?](https://bbs.fit2cloud.com/t/topic/2147)
## Screenshot ## 安全说明
![UI Display](https://resource.1panel.pro/img/1panel.png) 如果您在使用过程中发现任何安全问题,请通过以下方式直接联系我们:
- 邮箱:support@fit2cloud.com
- 电话:400-052-0755
## Star History ## Star History
[![Star History Chart](https://api.star-history.com/svg?repos=1Panel-dev/1Panel&type=Date)](https://star-history.com/#1Panel-dev/1Panel&Date) [![Star History Chart](https://api.star-history.com/svg?repos=1Panel-dev/1Panel&type=Date)](https://star-history.com/#1Panel-dev/1Panel&Date)
## Pro Edition ## FOSSA Status
Compared to the OSS Edition, 1Panel Pro Edition provides users with a wealth of enhanced features and technical support services. Enhanced features include WAF enhancement, Website monitoring, Mobile APP, custom logo and theme, etc. [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2F1Panel-dev%2F1Panel.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2F1Panel-dev%2F1Panel?ref=badge_large)
[Click to see Pro Edition details](https://1panel.pro/pricing).
## Security Information
If you discover any security issues, please refer to [SECURITY.md](/SECURITY.md).
## GitAds Sponsored
[![Sponsored by GitAds](https://gitads.dev/v1/ad-serve?source=1panel-dev/1panel@github)](https://gitads.dev/v1/ad-track?source=1panel-dev/1panel@github)
## License ## License
Copyright (c) 2014-2023 [FIT2CLOUD 飞致云](https://fit2cloud.com/), All rights reserved.
Licensed under The GNU General Public License version 3 (GPLv3) (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Licensed under The GNU General Public License version 3 (GPLv3) (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
<https://www.gnu.org/licenses/gpl-3.0.html> <https://www.gnu.org/licenses/gpl-3.0.html>
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
<!-- GitAds-Verify: 9M8AMBB11GYJ3RUNXGB5R1MR71KPATU9 -->
+16 -8
View File
@@ -1,13 +1,21 @@
# Security policy # 安全说明
## Supported versions 如果您发现安全问题,请直接联系我们:
| Version | Supported | - wanghe@fit2cloud.com
| ------- | ------------------ | - zhengkun@fit2cloud.com
| v1.x | :white_check_mark: | - support@fit2cloud.com
- 400-052-0755
## Reporting a vulnerability 感谢您的支持!
We first appreciate and are very thankful that you've found a vulnerability issue in 1Panel! By disclosing such issue to 1Panel development team you are helping 1Panel to become a much more safer project than before! ;) # Security Policy
To protect the existing users of 1Panel, we kindly ask you to not disclose the vulnerability to anyone except the 1Panel development team before a fix has been rolled out. Send an email to `wanghe@fit2cloud.com` instead. All security bugs should be reported to the contact as below:
- wanghe@fit2cloud.com
- zhengkun@fit2cloud.com
- support@fit2cloud.com
- 400-052-0755
Thanks for your support!
-257
View File
@@ -1,257 +0,0 @@
package v1
import (
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/backend/utils/ai_tools/gpu"
"github.com/1Panel-dev/1Panel/backend/utils/ai_tools/gpu/common"
"github.com/1Panel-dev/1Panel/backend/utils/ai_tools/xpu"
"github.com/gin-gonic/gin"
)
// @Tags AI
// @Summary Create Ollama model
// @Accept json
// @Param request body dto.OllamaModelName true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /ai/ollama/model [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"添加 Ollama 模型 [name]","formatEN":"add Ollama model [name]"}
func (b *BaseApi) CreateOllamaModel(c *gin.Context) {
var req dto.OllamaModelName
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := AIToolService.Create(req.Name); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags AI
// @Summary Rereate Ollama model
// @Accept json
// @Param request body dto.OllamaModelName true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /ai/ollama/model/recreate [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"添加 Ollama 模型重试 [name]","formatEN":"re-add Ollama model [name]"}
func (b *BaseApi) RecreateOllamaModel(c *gin.Context) {
var req dto.OllamaModelName
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := AIToolService.Recreate(req.Name); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags AI
// @Summary Close Ollama model conn
// @Accept json
// @Param request body dto.OllamaModelName true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /ai/ollama/model/close [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"关闭 Ollama 模型连接 [name]","formatEN":"close conn for Ollama model [name]"}
func (b *BaseApi) CloseOllamaModel(c *gin.Context) {
var req dto.OllamaModelName
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := AIToolService.Close(req.Name); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags AI
// @Summary Sync Ollama model list
// @Success 200 {array} dto.OllamaModelDropList
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /ai/ollama/model/sync [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"同步 Ollama 模型列表","formatEN":"sync Ollama model list"}
func (b *BaseApi) SyncOllamaModel(c *gin.Context) {
list, err := AIToolService.Sync()
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, list)
}
// @Tags AI
// @Summary Page Ollama models
// @Accept json
// @Param request body dto.SearchWithPage true "request"
// @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /ai/ollama/model/search [post]
func (b *BaseApi) SearchOllamaModel(c *gin.Context) {
var req dto.SearchWithPage
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
total, list, err := AIToolService.Search(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, dto.PageResult{
Items: list,
Total: total,
})
}
// @Tags AI
// @Summary Page Ollama models
// @Accept json
// @Param request body dto.OllamaModelName true "request"
// @Success 200 {string} details
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /ai/ollama/model/load [post]
func (b *BaseApi) LoadOllamaModelDetail(c *gin.Context) {
var req dto.OllamaModelName
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
detail, err := AIToolService.LoadDetail(req.Name)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, detail)
}
// @Tags AI
// @Summary Delete Ollama model
// @Accept json
// @Param request body dto.ForceDelete true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /ai/ollama/model/del [post]
// @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"ollama_models","output_column":"name","output_value":"names"}],"formatZH":"删除 Ollama 模型 [names]","formatEN":"remove Ollama model [names]"}
func (b *BaseApi) DeleteOllamaModel(c *gin.Context) {
var req dto.ForceDelete
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := AIToolService.Delete(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
// @Tags AI
// @Summary Load gpu / xpu info
// @Accept json
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /ai/gpu/load [get]
func (b *BaseApi) LoadGpuInfo(c *gin.Context) {
ok, client := gpu.New()
if ok {
info, err := client.LoadGpuInfo()
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, info)
return
}
xpuOK, xpuClient := xpu.New()
if xpuOK {
info, err := xpuClient.LoadGpuInfo()
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, info)
return
}
helper.SuccessWithData(c, &common.GpuInfo{})
}
// @Tags AI
// @Summary Bind domain
// @Accept json
// @Param request body dto.OllamaBindDomain true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /ai/domain/bind [post]
func (b *BaseApi) BindDomain(c *gin.Context) {
var req dto.OllamaBindDomain
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := AIToolService.BindDomain(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
// @Tags AI
// @Summary Get bind domain
// @Accept json
// @Param request body dto.OllamaBindDomainReq true "request"
// @Success 200 {object} dto.OllamaBindDomainRes
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /ai/domain/get [post]
func (b *BaseApi) GetBindDomain(c *gin.Context) {
var req dto.OllamaBindDomainReq
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
res, err := AIToolService.GetBindDomain(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, res)
}
// Tags AI
// Summary Update bind domain
// Accept json
// Param request body dto.OllamaBindDomain true "request"
// Success 200
// Security ApiKeyAuth
// Security Timestamp
// Router /ai/domain/update [post]
func (b *BaseApi) UpdateBindDomain(c *gin.Context) {
var req dto.OllamaBindDomain
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := AIToolService.UpdateBindDomain(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
+21 -21
View File
@@ -11,18 +11,18 @@ import (
// @Tags App // @Tags App
// @Summary List apps // @Summary List apps
// @Description 获取应用列表
// @Accept json // @Accept json
// @Param request body request.AppSearch true "request" // @Param request body request.AppSearch true "request"
// @Success 200 {object} response.AppRes // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /apps/search [post] // @Router /apps/search [post]
func (b *BaseApi) SearchApp(c *gin.Context) { func (b *BaseApi) SearchApp(c *gin.Context) {
var req request.AppSearch var req request.AppSearch
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }
list, err := appService.PageApp(c, req) list, err := appService.PageApp(req)
if err != nil { if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
@@ -32,9 +32,9 @@ func (b *BaseApi) SearchApp(c *gin.Context) {
// @Tags App // @Tags App
// @Summary Sync app list // @Summary Sync app list
// @Description 同步应用列表
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /apps/sync [post] // @Router /apps/sync [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"应用商店同步","formatEN":"App store synchronization"} // @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"应用商店同步","formatEN":"App store synchronization"}
func (b *BaseApi) SyncApp(c *gin.Context) { func (b *BaseApi) SyncApp(c *gin.Context) {
@@ -63,19 +63,19 @@ func (b *BaseApi) SyncApp(c *gin.Context) {
// @Tags App // @Tags App
// @Summary Search app by key // @Summary Search app by key
// @Description 通过 key 获取应用信息
// @Accept json // @Accept json
// @Param key path string true "app key" // @Param key path string true "app key"
// @Success 200 {object} response.AppDTO // @Success 200 {object} response.AppDTO
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /apps/:key [get]
// @Router /apps/{key} [get]
func (b *BaseApi) GetApp(c *gin.Context) { func (b *BaseApi) GetApp(c *gin.Context) {
appKey, err := helper.GetStrParamByKey(c, "key") appKey, err := helper.GetStrParamByKey(c, "key")
if err != nil { if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err) helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
return return
} }
appDTO, err := appService.GetApp(c, appKey) appDTO, err := appService.GetApp(appKey)
if err != nil { if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
@@ -85,14 +85,14 @@ func (b *BaseApi) GetApp(c *gin.Context) {
// @Tags App // @Tags App
// @Summary Search app detail by appid // @Summary Search app detail by appid
// @Description 通过 appid 获取应用详情
// @Accept json // @Accept json
// @Param appId path integer true "app id" // @Param appId path integer true "app id"
// @Param version path string true "app version" // @Param version path string true "app 版本"
// @Param type path string true "app type" // @Param version path string true "app 类型"
// @Success 200 {object} response.AppDetailDTO // @Success 200 {object} response.AppDetailDTO
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /apps/detail/:appId/:version/:type [get]
// @Router /apps/detail/{appId}/{version}/{type} [get]
func (b *BaseApi) GetAppDetail(c *gin.Context) { func (b *BaseApi) GetAppDetail(c *gin.Context) {
appID, err := helper.GetIntParamByKey(c, "appId") appID, err := helper.GetIntParamByKey(c, "appId")
if err != nil { if err != nil {
@@ -111,12 +111,12 @@ func (b *BaseApi) GetAppDetail(c *gin.Context) {
// @Tags App // @Tags App
// @Summary Get app detail by id // @Summary Get app detail by id
// @Description 通过 id 获取应用详情
// @Accept json // @Accept json
// @Param id path integer true "id" // @Param appId path integer true "id"
// @Success 200 {object} response.AppDetailDTO // @Success 200 {object} response.AppDetailDTO
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /apps/details/:id [get]
// @Router /apps/details/{id} [get]
func (b *BaseApi) GetAppDetailByID(c *gin.Context) { func (b *BaseApi) GetAppDetailByID(c *gin.Context) {
appDetailID, err := helper.GetIntParamByKey(c, "id") appDetailID, err := helper.GetIntParamByKey(c, "id")
if err != nil { if err != nil {
@@ -133,11 +133,11 @@ func (b *BaseApi) GetAppDetailByID(c *gin.Context) {
// @Tags App // @Tags App
// @Summary Get Ignore App // @Summary Get Ignore App
// @Description 获取忽略的应用版本
// @Accept json // @Accept json
// @Success 200 {object} response.IgnoredApp // @Success 200 {object} response.IgnoredApp
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /apps/ingored [get]
// @Router /apps/ignored [get]
func (b *BaseApi) GetIgnoredApp(c *gin.Context) { func (b *BaseApi) GetIgnoredApp(c *gin.Context) {
res, err := appService.GetIgnoredApp() res, err := appService.GetIgnoredApp()
if err != nil { if err != nil {
@@ -149,13 +149,13 @@ func (b *BaseApi) GetIgnoredApp(c *gin.Context) {
// @Tags App // @Tags App
// @Summary Install app // @Summary Install app
// @Description 安装应用
// @Accept json // @Accept json
// @Param request body request.AppInstallCreate true "request" // @Param request body request.AppInstallCreate true "request"
// @Success 200 {object} model.AppInstall // @Success 200 {object} model.AppInstall
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /apps/install [post] // @Router /apps/install [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"安装应用 [name]","formatEN":"Install app [name]"} // @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]"}
func (b *BaseApi) InstallApp(c *gin.Context) { func (b *BaseApi) InstallApp(c *gin.Context) {
var req request.AppInstallCreate var req request.AppInstallCreate
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
@@ -173,7 +173,7 @@ func (b *BaseApi) InstallApp(c *gin.Context) {
} }
func (b *BaseApi) GetAppTags(c *gin.Context) { func (b *BaseApi) GetAppTags(c *gin.Context) {
tags, err := appService.GetAppTags(c) tags, err := appService.GetAppTags()
if err != nil { if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
@@ -183,9 +183,9 @@ func (b *BaseApi) GetAppTags(c *gin.Context) {
// @Tags App // @Tags App
// @Summary Get app list update // @Summary Get app list update
// @Success 200 {object} response.AppUpdateRes // @Description 获取应用更新版本
// @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /apps/checkupdate [get] // @Router /apps/checkupdate [get]
func (b *BaseApi) GetAppListUpdate(c *gin.Context) { func (b *BaseApi) GetAppListUpdate(c *gin.Context) {
res, err := appService.GetAppUpdate() res, err := appService.GetAppUpdate()
+35 -32
View File
@@ -6,16 +6,17 @@ import (
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/backend/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/backend/global"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
// @Tags App // @Tags App
// @Summary Page app installed // @Summary Page app installed
// @Description 分页获取已安装应用列表
// @Accept json // @Accept json
// @Param request body request.AppInstalledSearch true "request" // @Param request body request.AppInstalledSearch true "request"
// @Success 200 {object} dto.PageResult // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /apps/installed/search [post] // @Router /apps/installed/search [post]
func (b *BaseApi) SearchAppInstalled(c *gin.Context) { func (b *BaseApi) SearchAppInstalled(c *gin.Context) {
var req request.AppInstalledSearch var req request.AppInstalledSearch
@@ -28,10 +29,7 @@ func (b *BaseApi) SearchAppInstalled(c *gin.Context) {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
} }
helper.SuccessWithData(c, dto.PageResult{ helper.SuccessWithData(c, list)
Items: list,
Total: int64(len(list)),
})
} else { } else {
total, list, err := appInstallService.Page(req) total, list, err := appInstallService.Page(req)
if err != nil { if err != nil {
@@ -47,10 +45,10 @@ func (b *BaseApi) SearchAppInstalled(c *gin.Context) {
// @Tags App // @Tags App
// @Summary List app installed // @Summary List app installed
// @Description 获取已安装应用列表
// @Accept json // @Accept json
// @Success 200 {array} dto.AppInstallInfo // @Success 200 array dto.AppInstallInfo
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /apps/installed/list [get] // @Router /apps/installed/list [get]
func (b *BaseApi) ListAppInstalled(c *gin.Context) { func (b *BaseApi) ListAppInstalled(c *gin.Context) {
list, err := appInstallService.GetInstallList() list, err := appInstallService.GetInstallList()
@@ -63,17 +61,21 @@ func (b *BaseApi) ListAppInstalled(c *gin.Context) {
// @Tags App // @Tags App
// @Summary Check app installed // @Summary Check app installed
// @Description 检查应用安装情况
// @Accept json // @Accept json
// @Param request body request.AppInstalledInfo true "request" // @Param request body request.AppInstalledInfo true "request"
// @Success 200 {object} response.AppInstalledCheck // @Success 200 {object} response.AppInstalledCheck
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /apps/installed/check [post] // @Router /apps/installed/check [post]
func (b *BaseApi) CheckAppInstalled(c *gin.Context) { func (b *BaseApi) CheckAppInstalled(c *gin.Context) {
var req request.AppInstalledInfo var req request.AppInstalledInfo
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }
if err := global.VALID.Struct(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
return
}
checkData, err := appInstallService.CheckExist(req) checkData, err := appInstallService.CheckExist(req)
if err != nil { if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
@@ -84,11 +86,11 @@ func (b *BaseApi) CheckAppInstalled(c *gin.Context) {
// @Tags App // @Tags App
// @Summary Search app port by key // @Summary Search app port by key
// @Description 获取应用端口
// @Accept json // @Accept json
// @Param request body dto.OperationWithNameAndType true "request" // @Param request body dto.OperationWithNameAndType true "request"
// @Success 200 {integer} port // @Success 200 {integer} port
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /apps/installed/loadport [post] // @Router /apps/installed/loadport [post]
func (b *BaseApi) LoadPort(c *gin.Context) { func (b *BaseApi) LoadPort(c *gin.Context) {
var req dto.OperationWithNameAndType var req dto.OperationWithNameAndType
@@ -105,13 +107,12 @@ func (b *BaseApi) LoadPort(c *gin.Context) {
// @Tags App // @Tags App
// @Summary Search app password by key // @Summary Search app password by key
// @Description 获取应用连接信息
// @Accept json // @Accept json
// @Param request body dto.OperationWithNameAndType true "request" // @Param request body dto.OperationWithNameAndType true "request"
// @Param key path string true "key" // @Success 200 {string} response.DatabaseConn
// @Success 200 {object} response.DatabaseConn
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /apps/installed/conninfo/:key [get]
// @Router /apps/installed/conninfo/{key} [get]
func (b *BaseApi) LoadConnInfo(c *gin.Context) { func (b *BaseApi) LoadConnInfo(c *gin.Context) {
var req dto.OperationWithNameAndType var req dto.OperationWithNameAndType
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
@@ -127,12 +128,12 @@ func (b *BaseApi) LoadConnInfo(c *gin.Context) {
// @Tags App // @Tags App
// @Summary Check before delete // @Summary Check before delete
// @Description 删除前检查
// @Accept json // @Accept json
// @Param appInstallId path integer true "App install id" // @Param appInstallId path integer true "App install id"
// @Success 200 {array} dto.AppResource // @Success 200 {array} dto.AppResource
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /apps/installed/delete/check/:appInstallId [get]
// @Router /apps/installed/delete/check/{appInstallId} [get]
func (b *BaseApi) DeleteCheck(c *gin.Context) { func (b *BaseApi) DeleteCheck(c *gin.Context) {
appInstallId, err := helper.GetIntParamByKey(c, "appInstallId") appInstallId, err := helper.GetIntParamByKey(c, "appInstallId")
if err != nil { if err != nil {
@@ -150,9 +151,9 @@ func (b *BaseApi) DeleteCheck(c *gin.Context) {
// Sync app installed // Sync app installed
// @Tags App // @Tags App
// @Summary Sync app installed // @Summary Sync app installed
// @Description 同步已安装应用列表
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /apps/installed/sync [post] // @Router /apps/installed/sync [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"同步已安装应用列表","formatEN":"Sync the list of installed apps"} // @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"同步已安装应用列表","formatEN":"Sync the list of installed apps"}
func (b *BaseApi) SyncInstalled(c *gin.Context) { func (b *BaseApi) SyncInstalled(c *gin.Context) {
@@ -165,11 +166,11 @@ func (b *BaseApi) SyncInstalled(c *gin.Context) {
// @Tags App // @Tags App
// @Summary Operate installed app // @Summary Operate installed app
// @Description 操作已安装应用
// @Accept json // @Accept json
// @Param request body request.AppInstalledOperate true "request" // @Param request body request.AppInstalledOperate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /apps/installed/op [post] // @Router /apps/installed/op [post]
// @x-panel-log {"bodyKeys":["installId","operate"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"installId","isList":false,"db":"app_installs","output_column":"app_id","output_value":"appId"},{"input_column":"id","input_value":"installId","isList":false,"db":"app_installs","output_column":"name","output_value":"appName"},{"input_column":"id","input_value":"appId","isList":false,"db":"apps","output_column":"key","output_value":"appKey"}],"formatZH":"[operate] 应用 [appKey][appName]","formatEN":"[operate] App [appKey][appName]"} // @x-panel-log {"bodyKeys":["installId","operate"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"installId","isList":false,"db":"app_installs","output_column":"app_id","output_value":"appId"},{"input_column":"id","input_value":"installId","isList":false,"db":"app_installs","output_column":"name","output_value":"appName"},{"input_column":"id","input_value":"appId","isList":false,"db":"apps","output_column":"key","output_value":"appKey"}],"formatZH":"[operate] 应用 [appKey][appName]","formatEN":"[operate] App [appKey][appName]"}
func (b *BaseApi) OperateInstalled(c *gin.Context) { func (b *BaseApi) OperateInstalled(c *gin.Context) {
@@ -186,12 +187,12 @@ func (b *BaseApi) OperateInstalled(c *gin.Context) {
// @Tags App // @Tags App
// @Summary Search app service by key // @Summary Search app service by key
// @Description 通过 key 获取应用 service
// @Accept json // @Accept json
// @Param key path string true "request" // @Param key path string true "request"
// @Success 200 {array} response.AppService // @Success 200 {array} response.AppService
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /apps/services/:key [get]
// @Router /apps/services/{key} [get]
func (b *BaseApi) GetServices(c *gin.Context) { func (b *BaseApi) GetServices(c *gin.Context) {
key := c.Param("key") key := c.Param("key")
services, err := appInstallService.GetServices(key) services, err := appInstallService.GetServices(key)
@@ -204,17 +205,19 @@ func (b *BaseApi) GetServices(c *gin.Context) {
// @Tags App // @Tags App
// @Summary Search app update version by install id // @Summary Search app update version by install id
// @Description 通过 install id 获取应用更新版本
// @Accept json // @Accept json
// @Param appInstallId path integer true "request"
// @Success 200 {array} dto.AppVersion // @Success 200 {array} dto.AppVersion
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /apps/installed/:appInstallId/versions [get]
// @Router /apps/installed/update/versions [post]
func (b *BaseApi) GetUpdateVersions(c *gin.Context) { func (b *BaseApi) GetUpdateVersions(c *gin.Context) {
var req request.AppUpdateVersion appInstallId, err := helper.GetIntParamByKey(c, "appInstallId")
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
return return
} }
versions, err := appInstallService.GetUpdateVersions(req) versions, err := appInstallService.GetUpdateVersions(appInstallId)
if err != nil { if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
@@ -224,11 +227,11 @@ func (b *BaseApi) GetUpdateVersions(c *gin.Context) {
// @Tags App // @Tags App
// @Summary Change app port // @Summary Change app port
// @Description 修改应用端口
// @Accept json // @Accept json
// @Param request body request.PortUpdate true "request" // @Param request body request.PortUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /apps/installed/port/change [post] // @Router /apps/installed/port/change [post]
// @x-panel-log {"bodyKeys":["key","name","port"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"应用端口修改 [key]-[name] => [port]","formatEN":"Application port update [key]-[name] => [port]"} // @x-panel-log {"bodyKeys":["key","name","port"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"应用端口修改 [key]-[name] => [port]","formatEN":"Application port update [key]-[name] => [port]"}
func (b *BaseApi) ChangeAppPort(c *gin.Context) { func (b *BaseApi) ChangeAppPort(c *gin.Context) {
@@ -245,11 +248,11 @@ func (b *BaseApi) ChangeAppPort(c *gin.Context) {
// @Tags App // @Tags App
// @Summary Search default config by key // @Summary Search default config by key
// @Description 通过 key 获取应用默认配置
// @Accept json // @Accept json
// @Param request body dto.OperationWithNameAndType true "request" // @Param request body dto.OperationWithNameAndType true "request"
// @Success 200 {string} content // @Success 200 {string} content
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /apps/installed/conf [post] // @Router /apps/installed/conf [post]
func (b *BaseApi) GetDefaultConfig(c *gin.Context) { func (b *BaseApi) GetDefaultConfig(c *gin.Context) {
var req dto.OperationWithNameAndType var req dto.OperationWithNameAndType
@@ -267,12 +270,12 @@ func (b *BaseApi) GetDefaultConfig(c *gin.Context) {
// @Tags App // @Tags App
// @Summary Search params by appInstallId // @Summary Search params by appInstallId
// @Description 通过 install id 获取应用参数
// @Accept json // @Accept json
// @Param appInstallId path string true "request" // @Param appInstallId path string true "request"
// @Success 200 {object} response.AppConfig // @Success 200 {object} response.AppParam
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /apps/installed/params/:appInstallId [get]
// @Router /apps/installed/params/{appInstallId} [get]
func (b *BaseApi) GetParams(c *gin.Context) { func (b *BaseApi) GetParams(c *gin.Context) {
appInstallId, err := helper.GetIntParamByKey(c, "appInstallId") appInstallId, err := helper.GetIntParamByKey(c, "appInstallId")
if err != nil { if err != nil {
@@ -289,11 +292,11 @@ func (b *BaseApi) GetParams(c *gin.Context) {
// @Tags App // @Tags App
// @Summary Change app params // @Summary Change app params
// @Description 修改应用参数
// @Accept json // @Accept json
// @Param request body request.AppInstalledUpdate true "request" // @Param request body request.AppInstalledUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /apps/installed/params/update [post] // @Router /apps/installed/params/update [post]
// @x-panel-log {"bodyKeys":["installId"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"应用参数修改 [installId]","formatEN":"Application param update [installId]"} // @x-panel-log {"bodyKeys":["installId"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"应用参数修改 [installId]","formatEN":"Application param update [installId]"}
func (b *BaseApi) UpdateInstalled(c *gin.Context) { func (b *BaseApi) UpdateInstalled(c *gin.Context) {
@@ -310,11 +313,11 @@ func (b *BaseApi) UpdateInstalled(c *gin.Context) {
// @Tags App // @Tags App
// @Summary ignore App Update // @Summary ignore App Update
// @Description 忽略应用升级版本
// @Accept json // @Accept json
// @Param request body request.AppInstalledIgnoreUpgrade true "request" // @Param request body request.AppInstalledIgnoreUpgrade true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /apps/installed/ignore [post] // @Router /apps/installed/ignore [post]
// @x-panel-log {"bodyKeys":["installId"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"忽略应用 [installId] 版本升级","formatEN":"Application param update [installId]"} // @x-panel-log {"bodyKeys":["installId"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"忽略应用 [installId] 版本升级","formatEN":"Application param update [installId]"}
func (b *BaseApi) IgnoreUpgrade(c *gin.Context) { func (b *BaseApi) IgnoreUpgrade(c *gin.Context) {
+31 -38
View File
@@ -9,7 +9,7 @@ import (
"github.com/1Panel-dev/1Panel/backend/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/backend/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/1Panel-dev/1Panel/backend/utils/captcha" "github.com/1Panel-dev/1Panel/backend/utils/captcha"
"github.com/1Panel-dev/1Panel/backend/utils/common" "github.com/1Panel-dev/1Panel/backend/utils/qqwry"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
@@ -17,8 +17,9 @@ type BaseApi struct{}
// @Tags Auth // @Tags Auth
// @Summary User login // @Summary User login
// @Description 用户登录
// @Accept json // @Accept json
// @Param EntranceCode header string true "Secure entrance base64 encrypted string" // @Param EntranceCode header string true "安全入口 base64 加密串"
// @Param request body dto.Login true "request" // @Param request body dto.Login true "request"
// @Success 200 {object} dto.UserLoginInfo // @Success 200 {object} dto.UserLoginInfo
// @Router /auth/login [post] // @Router /auth/login [post]
@@ -28,45 +29,35 @@ func (b *BaseApi) Login(c *gin.Context) {
return return
} }
ip := common.GetRealClientIP(c) if req.AuthMethod != "jwt" && !req.IgnoreCaptcha {
needCaptcha := global.IPTracker.NeedCaptcha(ip)
if needCaptcha {
if err := captcha.VerifyCode(req.CaptchaID, req.Captcha); err != nil { if err := captcha.VerifyCode(req.CaptchaID, req.Captcha); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
} }
} }
entranceItem := c.Request.Header.Get("EntranceCode") entranceItem := c.Request.Header.Get("EntranceCode")
var entrance []byte var entrance []byte
if len(entranceItem) != 0 { if len(entranceItem) != 0 {
entrance, _ = base64.StdEncoding.DecodeString(entranceItem) entrance, _ = base64.StdEncoding.DecodeString(entranceItem)
} }
if len(entrance) == 0 {
cookieValue, err := c.Cookie("SecurityEntrance")
if err == nil {
entrance, _ = base64.StdEncoding.DecodeString(cookieValue)
}
}
user, err := authService.Login(c, req, string(entrance)) user, err := authService.Login(c, req, string(entrance))
go saveLoginLogs(c, err) go saveLoginLogs(c, err)
if err != nil { if err != nil {
global.IPTracker.SetNeedCaptcha(ip)
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
} }
global.IPTracker.Clear(ip)
helper.SuccessWithData(c, user) helper.SuccessWithData(c, user)
} }
// @Tags Auth // @Tags Auth
// @Summary User login with mfa // @Summary User login with mfa
// @Description 用户 mfa 登录
// @Accept json // @Accept json
// @Param request body dto.MFALogin true "request" // @Param request body dto.MFALogin true "request"
// @Success 200 {object} dto.UserLoginInfo // @Success 200 {object} dto.UserLoginInfo
// @Router /auth/mfalogin [post] // @Router /auth/mfalogin [post]
// @Header 200 {string} EntranceCode // @Header 200 {string} EntranceCode "安全入口"
func (b *BaseApi) MFALogin(c *gin.Context) { func (b *BaseApi) MFALogin(c *gin.Context) {
var req dto.MFALogin var req dto.MFALogin
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
@@ -89,9 +80,9 @@ func (b *BaseApi) MFALogin(c *gin.Context) {
// @Tags Auth // @Tags Auth
// @Summary User logout // @Summary User logout
// @Description 用户登出
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /auth/logout [post] // @Router /auth/logout [post]
func (b *BaseApi) LogOut(c *gin.Context) { func (b *BaseApi) LogOut(c *gin.Context) {
if err := authService.LogOut(c); err != nil { if err := authService.LogOut(c); err != nil {
@@ -103,6 +94,7 @@ func (b *BaseApi) LogOut(c *gin.Context) {
// @Tags Auth // @Tags Auth
// @Summary Load captcha // @Summary Load captcha
// @Description 加载验证码
// @Success 200 {object} dto.CaptchaResponse // @Success 200 {object} dto.CaptchaResponse
// @Router /auth/captcha [get] // @Router /auth/captcha [get]
func (b *BaseApi) Captcha(c *gin.Context) { func (b *BaseApi) Captcha(c *gin.Context) {
@@ -114,47 +106,42 @@ func (b *BaseApi) Captcha(c *gin.Context) {
helper.SuccessWithData(c, captcha) helper.SuccessWithData(c, captcha)
} }
func (b *BaseApi) GetResponsePage(c *gin.Context) { // @Tags Auth
pageCode, err := authService.GetResponsePage() // @Summary Load safety status
// @Description 获取系统安全登录状态
// @Success 200
// @Router /auth/issafety [get]
func (b *BaseApi) CheckIsSafety(c *gin.Context) {
code := c.DefaultQuery("code", "")
status, err := authService.CheckIsSafety(code)
if err != nil { if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
} }
helper.SuccessWithData(c, pageCode) helper.SuccessWithData(c, status)
} }
// @Tags Auth // @Tags Auth
// @Summary Check System isDemo // @Summary Check System isDemo
// @Success 200 {boolean} isDemo // @Description 判断是否为demo环境
// @Success 200
// @Router /auth/demo [get] // @Router /auth/demo [get]
func (b *BaseApi) CheckIsDemo(c *gin.Context) { func (b *BaseApi) CheckIsDemo(c *gin.Context) {
helper.SuccessWithData(c, global.CONF.System.IsDemo) helper.SuccessWithData(c, global.CONF.System.IsDemo)
} }
// @Tags Auth // @Tags Auth
// @Summary Check System isIntl // @Summary Load System Language
// @Success 200 {boolean} isIntl // @Description 获取系统语言设置
// @Router /auth/intl [get] // @Success 200
func (b *BaseApi) CheckIsIntl(c *gin.Context) { // @Router /auth/language [get]
helper.SuccessWithData(c, global.CONF.System.IsIntl) func (b *BaseApi) GetLanguage(c *gin.Context) {
}
// @Tags Auth
// @Summary Load System Setting for login
// @Success 200 {object} dto.LoginSetting
// @Router /auth/setting [get]
func (b *BaseApi) GetAuthSetting(c *gin.Context) {
settingInfo, err := settingService.GetSettingInfo() settingInfo, err := settingService.GetSettingInfo()
if err != nil { if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
} }
ip := common.GetRealClientIP(c) helper.SuccessWithData(c, settingInfo.Language)
needCaptcha := global.IPTracker.NeedCaptcha(ip)
helper.SuccessWithData(c, dto.LoginSetting{
NeedCaptcha: needCaptcha,
Language: settingInfo.Language,
})
} }
func saveLoginLogs(c *gin.Context, err error) { func saveLoginLogs(c *gin.Context, err error) {
@@ -166,6 +153,12 @@ func saveLoginLogs(c *gin.Context, err error) {
logs.Status = constant.StatusSuccess logs.Status = constant.StatusSuccess
} }
logs.IP = c.ClientIP() logs.IP = c.ClientIP()
qqWry, err := qqwry.NewQQwry()
if err != nil {
global.LOG.Errorf("load qqwry datas failed: %s", err)
}
res := qqWry.Find(logs.IP)
logs.Agent = c.GetHeader("User-Agent") logs.Agent = c.GetHeader("User-Agent")
logs.Address = res.Area
_ = logService.CreateLoginLog(logs) _ = logService.CreateLoginLog(logs)
} }
+37 -128
View File
@@ -13,11 +13,11 @@ import (
// @Tags Backup Account // @Tags Backup Account
// @Summary Create backup account // @Summary Create backup account
// @Description 创建备份账号
// @Accept json // @Accept json
// @Param request body dto.BackupOperate true "request" // @Param request body dto.BackupOperate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/backup [post] // @Router /settings/backup [post]
// @x-panel-log {"bodyKeys":["type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建备份账号 [type]","formatEN":"create backup account [type]"} // @x-panel-log {"bodyKeys":["type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建备份账号 [type]","formatEN":"create backup account [type]"}
func (b *BaseApi) CreateBackup(c *gin.Context) { func (b *BaseApi) CreateBackup(c *gin.Context) {
@@ -49,24 +49,13 @@ func (b *BaseApi) CreateBackup(c *gin.Context) {
helper.SuccessWithData(c, nil) helper.SuccessWithData(c, nil)
} }
// @Tags Backup Account
// @Summary Refresh OneDrive token
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/backup/refresh/onedrive [post]
func (b *BaseApi) RefreshOneDriveToken(c *gin.Context) {
backupService.Run()
helper.SuccessWithData(c, nil)
}
// @Tags Backup Account // @Tags Backup Account
// @Summary List buckets // @Summary List buckets
// @Description 获取 bucket 列表
// @Accept json // @Accept json
// @Param request body dto.ForBuckets true "request" // @Param request body dto.ForBuckets true "request"
// @Success 200 {array} object // @Success 200 {array} string
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/backup/search [post] // @Router /settings/backup/search [post]
func (b *BaseApi) ListBuckets(c *gin.Context) { func (b *BaseApi) ListBuckets(c *gin.Context) {
var req dto.ForBuckets var req dto.ForBuckets
@@ -100,29 +89,29 @@ func (b *BaseApi) ListBuckets(c *gin.Context) {
// @Tags Backup Account // @Tags Backup Account
// @Summary Load OneDrive info // @Summary Load OneDrive info
// @Description 获取 OneDrive 信息
// @Accept json // @Accept json
// @Success 200 {object} dto.OneDriveInfo // @Success 200 string clientID
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/backup/onedrive [get] // @Router /settings/backup/onedrive [get]
func (b *BaseApi) LoadOneDriveInfo(c *gin.Context) { func (b *BaseApi) LoadOneDriveInfo(c *gin.Context) {
data, err := backupService.LoadOneDriveInfo() clientID, err := backupService.LoadOneDriveInfo()
if err != nil { if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
} }
helper.SuccessWithData(c, data) helper.SuccessWithData(c, clientID)
} }
// @Tags Backup Account // @Tags Backup Account
// @Summary Delete backup account // @Summary Delete backup account
// @Description 删除备份账号
// @Accept json // @Accept json
// @Param request body dto.OperateByID true "request" // @Param request body dto.BatchDeleteReq true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/backup/del [post] // @Router /settings/backup/del [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"backup_accounts","output_column":"type","output_value":"types"}],"formatZH":"删除备份账号 [types]","formatEN":"delete backup account [types]"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":true,"db":"backup_accounts","output_column":"type","output_value":"types"}],"formatZH":"删除备份账号 [types]","formatEN":"delete backup account [types]"}
func (b *BaseApi) DeleteBackup(c *gin.Context) { func (b *BaseApi) DeleteBackup(c *gin.Context) {
var req dto.OperateByID var req dto.OperateByID
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
@@ -138,11 +127,11 @@ func (b *BaseApi) DeleteBackup(c *gin.Context) {
// @Tags Backup Account // @Tags Backup Account
// @Summary Page backup records // @Summary Page backup records
// @Description 获取备份记录列表分页
// @Accept json // @Accept json
// @Param request body dto.RecordSearch true "request" // @Param request body dto.RecordSearch true "request"
// @Success 200 {object} dto.PageResult // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/backup/record/search [post] // @Router /settings/backup/record/search [post]
func (b *BaseApi) SearchBackupRecords(c *gin.Context) { func (b *BaseApi) SearchBackupRecords(c *gin.Context) {
var req dto.RecordSearch var req dto.RecordSearch
@@ -162,85 +151,13 @@ func (b *BaseApi) SearchBackupRecords(c *gin.Context) {
}) })
} }
// @Tags Backup Account
// @Summary Load backup records size
// @Accept json
// @Param request body dto.RecordSearch true "request"
// @Success 200 {array} dto.BackupFile
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/backup/record/size [post]
func (b *BaseApi) LoadBackupSize(c *gin.Context) {
var req dto.RecordSearch
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
list, err := backupService.LoadSize(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, list)
}
// @Tags Backup Account
// @Summary Page backup records by cronjob
// @Accept json
// @Param request body dto.RecordSearchByCronjob true "request"
// @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/backup/record/search/bycronjob [post]
func (b *BaseApi) SearchBackupRecordsByCronjob(c *gin.Context) {
var req dto.RecordSearchByCronjob
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
total, list, err := backupService.SearchRecordsByCronjobWithPage(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, dto.PageResult{
Items: list,
Total: total,
})
}
// @Tags Backup Account
// @Summary Load backup records size for cronjob
// @Accept json
// @Param request body dto.RecordSearchByCronjob true "request"
// @Success 200 {array} dto.BackupFile
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/backup/record/size/bycronjob [post]
func (b *BaseApi) LoadBackupSizeByCronjob(c *gin.Context) {
var req dto.RecordSearchByCronjob
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
list, err := backupService.LoadSizeByCronjob(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, list)
}
// @Tags Backup Account // @Tags Backup Account
// @Summary Download backup record // @Summary Download backup record
// @Description 下载备份记录
// @Accept json // @Accept json
// @Param request body dto.DownloadRecord true "request" // @Param request body dto.DownloadRecord true "request"
// @Success 200 {string} filePath // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/backup/record/download [post] // @Router /settings/backup/record/download [post]
// @x-panel-log {"bodyKeys":["source","fileName"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"下载备份记录 [source][fileName]","formatEN":"download backup records [source][fileName]"} // @x-panel-log {"bodyKeys":["source","fileName"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"下载备份记录 [source][fileName]","formatEN":"download backup records [source][fileName]"}
func (b *BaseApi) DownloadRecord(c *gin.Context) { func (b *BaseApi) DownloadRecord(c *gin.Context) {
@@ -259,11 +176,11 @@ func (b *BaseApi) DownloadRecord(c *gin.Context) {
// @Tags Backup Account // @Tags Backup Account
// @Summary Delete backup record // @Summary Delete backup record
// @Description 删除备份记录
// @Accept json // @Accept json
// @Param request body dto.BatchDeleteReq true "request" // @Param request body dto.BatchDeleteReq true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/backup/record/del [post] // @Router /settings/backup/record/del [post]
// @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"backup_records","output_column":"file_name","output_value":"files"}],"formatZH":"删除备份记录 [files]","formatEN":"delete backup records [files]"} // @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"backup_records","output_column":"file_name","output_value":"files"}],"formatZH":"删除备份记录 [files]","formatEN":"delete backup records [files]"}
func (b *BaseApi) DeleteBackupRecord(c *gin.Context) { func (b *BaseApi) DeleteBackupRecord(c *gin.Context) {
@@ -281,11 +198,11 @@ func (b *BaseApi) DeleteBackupRecord(c *gin.Context) {
// @Tags Backup Account // @Tags Backup Account
// @Summary Update backup account // @Summary Update backup account
// @Description 更新备份账号信息
// @Accept json // @Accept json
// @Param request body dto.BackupOperate true "request" // @Param request body dto.BackupOperate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/backup/update [post] // @Router /settings/backup/update [post]
// @x-panel-log {"bodyKeys":["type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新备份账号 [types]","formatEN":"update backup account [types]"} // @x-panel-log {"bodyKeys":["type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新备份账号 [types]","formatEN":"update backup account [types]"}
func (b *BaseApi) UpdateBackup(c *gin.Context) { func (b *BaseApi) UpdateBackup(c *gin.Context) {
@@ -320,9 +237,9 @@ func (b *BaseApi) UpdateBackup(c *gin.Context) {
// @Tags Backup Account // @Tags Backup Account
// @Summary List backup accounts // @Summary List backup accounts
// @Description 获取备份账号列表
// @Success 200 {array} dto.BackupInfo // @Success 200 {array} dto.BackupInfo
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/backup/search [get] // @Router /settings/backup/search [get]
func (b *BaseApi) ListBackup(c *gin.Context) { func (b *BaseApi) ListBackup(c *gin.Context) {
data, err := backupService.List() data, err := backupService.List()
@@ -336,11 +253,11 @@ func (b *BaseApi) ListBackup(c *gin.Context) {
// @Tags Backup Account // @Tags Backup Account
// @Summary List files from backup accounts // @Summary List files from backup accounts
// @Description 获取备份账号内文件列表
// @Accept json // @Accept json
// @Param request body dto.BackupSearchFile true "request" // @Param request body dto.BackupSearchFile true "request"
// @Success 200 {array} string // @Success 200 {array} string
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/backup/search/files [post] // @Router /settings/backup/search/files [post]
func (b *BaseApi) LoadFilesFromBackup(c *gin.Context) { func (b *BaseApi) LoadFilesFromBackup(c *gin.Context) {
var req dto.BackupSearchFile var req dto.BackupSearchFile
@@ -348,18 +265,23 @@ func (b *BaseApi) LoadFilesFromBackup(c *gin.Context) {
return return
} }
data := backupService.ListFiles(req) data, err := backupService.ListFiles(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, data) helper.SuccessWithData(c, data)
} }
// @Tags Backup Account // @Tags Backup Account
// @Summary Backup system data // @Summary Backup system data
// @Description 备份系统数据
// @Accept json // @Accept json
// @Param request body dto.CommonBackup true "request" // @Param request body dto.CommonBackup true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /settings/backup/ [post]
// @Router /settings/backup/backup [post]
// @x-panel-log {"bodyKeys":["type","name","detailName"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"备份 [type] 数据 [name][detailName]","formatEN":"backup [type] data [name][detailName]"} // @x-panel-log {"bodyKeys":["type","name","detailName"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"备份 [type] 数据 [name][detailName]","formatEN":"backup [type] data [name][detailName]"}
func (b *BaseApi) Backup(c *gin.Context) { func (b *BaseApi) Backup(c *gin.Context) {
var req dto.CommonBackup var req dto.CommonBackup
@@ -369,7 +291,7 @@ func (b *BaseApi) Backup(c *gin.Context) {
switch req.Type { switch req.Type {
case "app": case "app":
if _, err := backupService.AppBackup(req); err != nil { if err := backupService.AppBackup(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
} }
@@ -378,18 +300,13 @@ func (b *BaseApi) Backup(c *gin.Context) {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
} }
case constant.AppPostgresql:
if err := backupService.PostgresqlBackup(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
case "website": case "website":
if err := backupService.WebsiteBackup(req); err != nil { if err := backupService.WebsiteBackup(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
} }
case "redis": case "redis":
if err := backupService.RedisBackup(req); err != nil { if err := backupService.RedisBackup(); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
} }
@@ -399,11 +316,11 @@ func (b *BaseApi) Backup(c *gin.Context) {
// @Tags Backup Account // @Tags Backup Account
// @Summary Recover system data // @Summary Recover system data
// @Description 恢复系统数据
// @Accept json // @Accept json
// @Param request body dto.CommonRecover true "request" // @Param request body dto.CommonRecover true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/backup/recover [post] // @Router /settings/backup/recover [post]
// @x-panel-log {"bodyKeys":["type","name","detailName","file"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"从 [file] 恢复 [type] 数据 [name][detailName]","formatEN":"recover [type] data [name][detailName] from [file]"} // @x-panel-log {"bodyKeys":["type","name","detailName","file"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"从 [file] 恢复 [type] 数据 [name][detailName]","formatEN":"recover [type] data [name][detailName] from [file]"}
func (b *BaseApi) Recover(c *gin.Context) { func (b *BaseApi) Recover(c *gin.Context) {
@@ -412,23 +329,20 @@ func (b *BaseApi) Recover(c *gin.Context) {
return return
} }
downloadPath, err := backupService.DownloadRecord(dto.DownloadRecord{Source: req.Source, FileDir: path.Dir(req.File), FileName: path.Base(req.File)}) if req.Source != "LOCAL" {
if err != nil { downloadPath, err := backupService.DownloadRecord(dto.DownloadRecord{Source: req.Source, FileDir: path.Dir(req.File), FileName: path.Base(req.File)})
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, fmt.Errorf("download file failed, err: %v", err)) if err != nil {
return helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, fmt.Errorf("download file failed, err: %v", err))
return
}
req.File = downloadPath
} }
req.File = downloadPath
switch req.Type { switch req.Type {
case "mysql", "mariadb": case "mysql", "mariadb":
if err := backupService.MysqlRecover(req); err != nil { if err := backupService.MysqlRecover(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
} }
case constant.AppPostgresql:
if err := backupService.PostgresqlRecover(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
case "website": case "website":
if err := backupService.WebsiteRecover(req); err != nil { if err := backupService.WebsiteRecover(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
@@ -450,11 +364,11 @@ func (b *BaseApi) Recover(c *gin.Context) {
// @Tags Backup Account // @Tags Backup Account
// @Summary Recover system data by upload // @Summary Recover system data by upload
// @Description 从上传恢复系统数据
// @Accept json // @Accept json
// @Param request body dto.CommonRecover true "request" // @Param request body dto.CommonRecover true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/backup/recover/byupload [post] // @Router /settings/backup/recover/byupload [post]
// @x-panel-log {"bodyKeys":["type","name","detailName","file"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"从 [file] 恢复 [type] 数据 [name][detailName]","formatEN":"recover [type] data [name][detailName] from [file]"} // @x-panel-log {"bodyKeys":["type","name","detailName","file"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"从 [file] 恢复 [type] 数据 [name][detailName]","formatEN":"recover [type] data [name][detailName] from [file]"}
func (b *BaseApi) RecoverByUpload(c *gin.Context) { func (b *BaseApi) RecoverByUpload(c *gin.Context) {
@@ -469,11 +383,6 @@ func (b *BaseApi) RecoverByUpload(c *gin.Context) {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
} }
case constant.AppPostgresql:
if err := backupService.PostgresqlRecoverByUpload(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
case "app": case "app":
if err := backupService.AppRecover(req); err != nil { if err := backupService.AppRecover(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
-298
View File
@@ -1,298 +0,0 @@
package v1
import (
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/backend/constant"
"github.com/gin-gonic/gin"
)
// @Tags Clam
// @Summary Create clam
// @Accept json
// @Param request body dto.ClamCreate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/clam [post]
// @x-panel-log {"bodyKeys":["name","path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建扫描规则 [name][path]","formatEN":"create clam [name][path]"}
func (b *BaseApi) CreateClam(c *gin.Context) {
var req dto.ClamCreate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := clamService.Create(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Clam
// @Summary Update clam
// @Accept json
// @Param request body dto.ClamUpdate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/clam/update [post]
// @x-panel-log {"bodyKeys":["name","path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改扫描规则 [name][path]","formatEN":"update clam [name][path]"}
func (b *BaseApi) UpdateClam(c *gin.Context) {
var req dto.ClamUpdate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := clamService.Update(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Clam
// @Summary Update clam status
// @Accept json
// @Param request body dto.ClamUpdateStatus true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/clam/status/update [post]
// @x-panel-log {"bodyKeys":["id","status"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"clams","output_column":"name","output_value":"name"}],"formatZH":"修改扫描规则 [name] 状态为 [status]","formatEN":"change the status of clam [name] to [status]."}
func (b *BaseApi) UpdateClamStatus(c *gin.Context) {
var req dto.ClamUpdateStatus
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := clamService.UpdateStatus(req.ID, req.Status); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Clam
// @Summary Page clam
// @Accept json
// @Param request body dto.SearchClamWithPage true "request"
// @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/clam/search [post]
func (b *BaseApi) SearchClam(c *gin.Context) {
var req dto.SearchClamWithPage
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
total, list, err := clamService.SearchWithPage(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, dto.PageResult{
Items: list,
Total: total,
})
}
// @Tags Clam
// @Summary Load clam base info
// @Accept json
// @Success 200 {object} dto.ClamBaseInfo
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/clam/base [get]
func (b *BaseApi) LoadClamBaseInfo(c *gin.Context) {
info, err := clamService.LoadBaseInfo()
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, info)
}
// @Tags Clam
// @Summary Operate Clam
// @Accept json
// @Param request body dto.Operate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/clam/operate [post]
// @x-panel-log {"bodyKeys":["operation"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"[operation] Clam","formatEN":"[operation] FTP"}
func (b *BaseApi) OperateClam(c *gin.Context) {
var req dto.Operate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := clamService.Operate(req.Operation); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Clam
// @Summary Clean clam record
// @Accept json
// @Param request body dto.OperateByID true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/clam/record/clean [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":true,"db":"clams","output_column":"name","output_value":"name"}],"formatZH":"清空扫描报告 [name]","formatEN":"clean clam record [name]"}
func (b *BaseApi) CleanClamRecord(c *gin.Context) {
var req dto.OperateByID
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := clamService.CleanRecord(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Clam
// @Summary Page clam record
// @Accept json
// @Param request body dto.ClamLogSearch true "request"
// @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/clam/record/search [post]
func (b *BaseApi) SearchClamRecord(c *gin.Context) {
var req dto.ClamLogSearch
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
total, list, err := clamService.LoadRecords(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, dto.PageResult{
Items: list,
Total: total,
})
}
// @Tags Clam
// @Summary Load clam record detail
// @Accept json
// @Param request body dto.ClamLogReq true "request"
// @Success 200 {string} content
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/clam/record/log [post]
func (b *BaseApi) LoadClamRecordLog(c *gin.Context) {
var req dto.ClamLogReq
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
content, err := clamService.LoadRecordLog(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, content)
}
// @Tags Clam
// @Summary Load clam file
// @Accept json
// @Param request body dto.ClamFileReq true "request"
// @Success 200 {string} content
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/clam/file/search [post]
func (b *BaseApi) SearchClamFile(c *gin.Context) {
var req dto.ClamFileReq
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
content, err := clamService.LoadFile(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, content)
}
// @Tags Clam
// @Summary Update clam file
// @Accept json
// @Param request body dto.UpdateByNameAndFile true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/clam/file/update [post]
func (b *BaseApi) UpdateFile(c *gin.Context) {
var req dto.UpdateByNameAndFile
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := clamService.UpdateFile(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
// @Tags Clam
// @Summary Delete clam
// @Accept json
// @Param request body dto.ClamDelete true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/clam/del [post]
// @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"clams","output_column":"name","output_value":"names"}],"formatZH":"删除扫描规则 [names]","formatEN":"delete clam [names]"}
func (b *BaseApi) DeleteClam(c *gin.Context) {
var req dto.ClamDelete
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := clamService.Delete(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Clam
// @Summary Handle clam scan
// @Accept json
// @Param request body dto.OperateByID true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/clam/handle [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":true,"db":"clams","output_column":"name","output_value":"name"}],"formatZH":"执行病毒扫描 [name]","formatEN":"handle clam scan [name]"}
func (b *BaseApi) HandleClamScan(c *gin.Context) {
var req dto.OperateByID
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := clamService.HandleOnce(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
+7 -93
View File
@@ -9,11 +9,11 @@ import (
// @Tags Command // @Tags Command
// @Summary Create command // @Summary Create command
// @Description 创建快速命令
// @Accept json // @Accept json
// @Param request body dto.CommandOperate true "request" // @Param request body dto.CommandOperate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/command [post] // @Router /hosts/command [post]
// @x-panel-log {"bodyKeys":["name","command"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建快捷命令 [name][command]","formatEN":"create quick command [name][command]"} // @x-panel-log {"bodyKeys":["name","command"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建快捷命令 [name][command]","formatEN":"create quick command [name][command]"}
func (b *BaseApi) CreateCommand(c *gin.Context) { func (b *BaseApi) CreateCommand(c *gin.Context) {
@@ -29,35 +29,13 @@ func (b *BaseApi) CreateCommand(c *gin.Context) {
helper.SuccessWithData(c, nil) helper.SuccessWithData(c, nil)
} }
// @Tags Redis Command
// @Summary Save redis command
// @Accept json
// @Param request body dto.RedisCommand true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/command/redis [post]
// @x-panel-log {"bodyKeys":["name","command"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"保存 redis 快捷命令 [name][command]","formatEN":"save quick command for redis [name][command]"}
func (b *BaseApi) SaveRedisCommand(c *gin.Context) {
var req dto.RedisCommand
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := commandService.SaveRedisCommand(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Command // @Tags Command
// @Summary Page commands // @Summary Page commands
// @Description 获取快速命令列表分页
// @Accept json // @Accept json
// @Param request body dto.SearchWithPage true "request" // @Param request body dto.SearchWithPage true "request"
// @Success 200 {object} dto.PageResult // @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/command/search [post] // @Router /hosts/command/search [post]
func (b *BaseApi) SearchCommand(c *gin.Context) { func (b *BaseApi) SearchCommand(c *gin.Context) {
var req dto.SearchCommandWithPage var req dto.SearchCommandWithPage
@@ -77,38 +55,12 @@ func (b *BaseApi) SearchCommand(c *gin.Context) {
}) })
} }
// @Tags Redis Command
// @Summary Page redis commands
// @Accept json
// @Param request body dto.SearchWithPage true "request"
// @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/command/redis/search [post]
func (b *BaseApi) SearchRedisCommand(c *gin.Context) {
var req dto.SearchWithPage
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
total, list, err := commandService.SearchRedisCommandWithPage(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, dto.PageResult{
Items: list,
Total: total,
})
}
// @Tags Command // @Tags Command
// @Summary Tree commands // @Summary Tree commands
// @Description 获取快速命令树
// @Accept json // @Accept json
// @Success 200 {array} dto.CommandTree // @Success 200 {Array} dto.CommandTree
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/command/tree [get] // @Router /hosts/command/tree [get]
func (b *BaseApi) SearchCommandTree(c *gin.Context) { func (b *BaseApi) SearchCommandTree(c *gin.Context) {
list, err := commandService.SearchForTree() list, err := commandService.SearchForTree()
@@ -120,27 +72,11 @@ func (b *BaseApi) SearchCommandTree(c *gin.Context) {
helper.SuccessWithData(c, list) helper.SuccessWithData(c, list)
} }
// @Tags Redis Command
// @Summary List redis commands
// @Success 200 {array} dto.RedisCommand
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/command/redis [get]
func (b *BaseApi) ListRedisCommand(c *gin.Context) {
list, err := commandService.ListRedisCommand()
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, list)
}
// @Tags Command // @Tags Command
// @Summary List commands // @Summary List commands
// @Description 获取快速命令列表
// @Success 200 {object} dto.CommandInfo // @Success 200 {object} dto.CommandInfo
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/command [get] // @Router /hosts/command [get]
func (b *BaseApi) ListCommand(c *gin.Context) { func (b *BaseApi) ListCommand(c *gin.Context) {
list, err := commandService.List() list, err := commandService.List()
@@ -154,11 +90,11 @@ func (b *BaseApi) ListCommand(c *gin.Context) {
// @Tags Command // @Tags Command
// @Summary Delete command // @Summary Delete command
// @Description 删除快速命令
// @Accept json // @Accept json
// @Param request body dto.BatchDeleteReq true "request" // @Param request body dto.BatchDeleteReq true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/command/del [post] // @Router /hosts/command/del [post]
// @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"commands","output_column":"name","output_value":"names"}],"formatZH":"删除快捷命令 [names]","formatEN":"delete quick command [names]"} // @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"commands","output_column":"name","output_value":"names"}],"formatZH":"删除快捷命令 [names]","formatEN":"delete quick command [names]"}
func (b *BaseApi) DeleteCommand(c *gin.Context) { func (b *BaseApi) DeleteCommand(c *gin.Context) {
@@ -174,35 +110,13 @@ func (b *BaseApi) DeleteCommand(c *gin.Context) {
helper.SuccessWithData(c, nil) helper.SuccessWithData(c, nil)
} }
// @Tags Redis Command
// @Summary Delete redis command
// @Accept json
// @Param request body dto.BatchDeleteReq true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/command/redis/del [post]
// @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"redis_commands","output_column":"name","output_value":"names"}],"formatZH":"删除 redis 快捷命令 [names]","formatEN":"delete quick command of redis [names]"}
func (b *BaseApi) DeleteRedisCommand(c *gin.Context) {
var req dto.BatchDeleteReq
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := commandService.DeleteRedisCommand(req.Ids); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Command // @Tags Command
// @Summary Update command // @Summary Update command
// @Description 更新快速命令
// @Accept json // @Accept json
// @Param request body dto.CommandOperate true "request" // @Param request body dto.CommandOperate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/command/update [post] // @Router /hosts/command/update [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新快捷命令 [name]","formatEN":"update quick command [name]"} // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新快捷命令 [name]","formatEN":"update quick command [name]"}
func (b *BaseApi) UpdateCommand(c *gin.Context) { func (b *BaseApi) UpdateCommand(c *gin.Context) {
+5 -5
View File
@@ -9,11 +9,11 @@ import (
// @Tags Container Compose-template // @Tags Container Compose-template
// @Summary Create compose template // @Summary Create compose template
// @Description 创建容器编排模版
// @Accept json // @Accept json
// @Param request body dto.ComposeTemplateCreate true "request" // @Param request body dto.ComposeTemplateCreate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/template [post] // @Router /containers/template [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建 compose 模版 [name]","formatEN":"create compose template [name]"} // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建 compose 模版 [name]","formatEN":"create compose template [name]"}
func (b *BaseApi) CreateComposeTemplate(c *gin.Context) { func (b *BaseApi) CreateComposeTemplate(c *gin.Context) {
@@ -31,12 +31,12 @@ func (b *BaseApi) CreateComposeTemplate(c *gin.Context) {
// @Tags Container Compose-template // @Tags Container Compose-template
// @Summary Page compose templates // @Summary Page compose templates
// @Description 获取容器编排模版列表分页
// @Accept json // @Accept json
// @Param request body dto.SearchWithPage true "request" // @Param request body dto.SearchWithPage true "request"
// @Produce json // @Produce json
// @Success 200 {object} dto.PageResult // @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/template/search [post] // @Router /containers/template/search [post]
func (b *BaseApi) SearchComposeTemplate(c *gin.Context) { func (b *BaseApi) SearchComposeTemplate(c *gin.Context) {
var req dto.SearchWithPage var req dto.SearchWithPage
@@ -58,10 +58,10 @@ func (b *BaseApi) SearchComposeTemplate(c *gin.Context) {
// @Tags Container Compose-template // @Tags Container Compose-template
// @Summary List compose templates // @Summary List compose templates
// @Description 获取容器编排模版列表
// @Produce json // @Produce json
// @Success 200 {array} dto.ComposeTemplateInfo // @Success 200 {array} dto.ComposeTemplateInfo
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/template [get] // @Router /containers/template [get]
func (b *BaseApi) ListComposeTemplate(c *gin.Context) { func (b *BaseApi) ListComposeTemplate(c *gin.Context) {
list, err := composeTemplateService.List() list, err := composeTemplateService.List()
@@ -75,11 +75,11 @@ func (b *BaseApi) ListComposeTemplate(c *gin.Context) {
// @Tags Container Compose-template // @Tags Container Compose-template
// @Summary Delete compose template // @Summary Delete compose template
// @Description 删除容器编排模版
// @Accept json // @Accept json
// @Param request body dto.BatchDelete true "request" // @Param request body dto.BatchDelete true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/template/del [post] // @Router /containers/template/del [post]
// @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"compose_templates","output_column":"name","output_value":"names"}],"formatZH":"删除 compose 模版 [names]","formatEN":"delete compose template [names]"} // @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"compose_templates","output_column":"name","output_value":"names"}],"formatZH":"删除 compose 模版 [names]","formatEN":"delete compose template [names]"}
func (b *BaseApi) DeleteComposeTemplate(c *gin.Context) { func (b *BaseApi) DeleteComposeTemplate(c *gin.Context) {
@@ -97,11 +97,11 @@ func (b *BaseApi) DeleteComposeTemplate(c *gin.Context) {
// @Tags Container Compose-template // @Tags Container Compose-template
// @Summary Update compose template // @Summary Update compose template
// @Description 更新容器编排模版
// @Accept json // @Accept json
// @Param request body dto.ComposeTemplateUpdate true "request" // @Param request body dto.ComposeTemplateUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/template/update [post] // @Router /containers/template/update [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"compose_templates","output_column":"name","output_value":"name"}],"formatZH":"更新 compose 模版 [name]","formatEN":"update compose template information [name]"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"compose_templates","output_column":"name","output_value":"name"}],"formatZH":"更新 compose 模版 [name]","formatEN":"update compose template information [name]"}
func (b *BaseApi) UpdateComposeTemplate(c *gin.Context) { func (b *BaseApi) UpdateComposeTemplate(c *gin.Context) {
+49 -91
View File
@@ -1,8 +1,6 @@
package v1 package v1
import ( import (
"strconv"
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/backend/constant" "github.com/1Panel-dev/1Panel/backend/constant"
@@ -13,12 +11,12 @@ import (
// @Tags Container // @Tags Container
// @Summary Page containers // @Summary Page containers
// @Description 获取容器列表分页
// @Accept json // @Accept json
// @Param request body dto.PageContainer true "request" // @Param request body dto.PageContainer true "request"
// @Produce json // @Produce json
// @Success 200 {object} dto.PageResult // @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/search [post] // @Router /containers/search [post]
func (b *BaseApi) SearchContainer(c *gin.Context) { func (b *BaseApi) SearchContainer(c *gin.Context) {
var req dto.PageContainer var req dto.PageContainer
@@ -39,11 +37,11 @@ func (b *BaseApi) SearchContainer(c *gin.Context) {
// @Tags Container // @Tags Container
// @Summary List containers // @Summary List containers
// @Description 获取容器名称
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Success 200 {array} string // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/list [post] // @Router /containers/list [post]
func (b *BaseApi) ListContainer(c *gin.Context) { func (b *BaseApi) ListContainer(c *gin.Context) {
list, err := containerService.List() list, err := containerService.List()
@@ -56,11 +54,11 @@ func (b *BaseApi) ListContainer(c *gin.Context) {
// @Tags Container Compose // @Tags Container Compose
// @Summary Page composes // @Summary Page composes
// @Description 获取编排列表分页
// @Accept json // @Accept json
// @Param request body dto.SearchWithPage true "request" // @Param request body dto.SearchWithPage true "request"
// @Success 200 {object} dto.PageResult // @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/compose/search [post] // @Router /containers/compose/search [post]
func (b *BaseApi) SearchCompose(c *gin.Context) { func (b *BaseApi) SearchCompose(c *gin.Context) {
var req dto.SearchWithPage var req dto.SearchWithPage
@@ -81,11 +79,11 @@ func (b *BaseApi) SearchCompose(c *gin.Context) {
// @Tags Container Compose // @Tags Container Compose
// @Summary Test compose // @Summary Test compose
// @Description 测试 compose 是否可用
// @Accept json // @Accept json
// @Param request body dto.ComposeCreate true "request" // @Param request body dto.ComposeCreate true "request"
// @Success 200 {boolean} isOK // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/compose/test [post] // @Router /containers/compose/test [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"检测 compose [name] 格式","formatEN":"check compose [name]"} // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"检测 compose [name] 格式","formatEN":"check compose [name]"}
func (b *BaseApi) TestCompose(c *gin.Context) { func (b *BaseApi) TestCompose(c *gin.Context) {
@@ -104,11 +102,11 @@ func (b *BaseApi) TestCompose(c *gin.Context) {
// @Tags Container Compose // @Tags Container Compose
// @Summary Create compose // @Summary Create compose
// @Description 创建容器编排
// @Accept json // @Accept json
// @Param request body dto.ComposeCreate true "request" // @Param request body dto.ComposeCreate true "request"
// @Success 200 {string} log // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/compose [post] // @Router /containers/compose [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建 compose [name]","formatEN":"create compose [name]"} // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建 compose [name]","formatEN":"create compose [name]"}
func (b *BaseApi) CreateCompose(c *gin.Context) { func (b *BaseApi) CreateCompose(c *gin.Context) {
@@ -127,11 +125,11 @@ func (b *BaseApi) CreateCompose(c *gin.Context) {
// @Tags Container Compose // @Tags Container Compose
// @Summary Operate compose // @Summary Operate compose
// @Description 容器编排操作
// @Accept json // @Accept json
// @Param request body dto.ComposeOperation true "request" // @Param request body dto.ComposeOperation true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/compose/operate [post] // @Router /containers/compose/operate [post]
// @x-panel-log {"bodyKeys":["name","operation"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"compose [operation] [name]","formatEN":"compose [operation] [name]"} // @x-panel-log {"bodyKeys":["name","operation"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"compose [operation] [name]","formatEN":"compose [operation] [name]"}
func (b *BaseApi) OperatorCompose(c *gin.Context) { func (b *BaseApi) OperatorCompose(c *gin.Context) {
@@ -149,11 +147,11 @@ func (b *BaseApi) OperatorCompose(c *gin.Context) {
// @Tags Container // @Tags Container
// @Summary Update container // @Summary Update container
// @Description 更新容器
// @Accept json // @Accept json
// @Param request body dto.ContainerOperate true "request" // @Param request body dto.ContainerOperate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/update [post] // @Router /containers/update [post]
// @x-panel-log {"bodyKeys":["name","image"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新容器 [name][image]","formatEN":"update container [name][image]"} // @x-panel-log {"bodyKeys":["name","image"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新容器 [name][image]","formatEN":"update container [name][image]"}
func (b *BaseApi) ContainerUpdate(c *gin.Context) { func (b *BaseApi) ContainerUpdate(c *gin.Context) {
@@ -171,11 +169,11 @@ func (b *BaseApi) ContainerUpdate(c *gin.Context) {
// @Tags Container // @Tags Container
// @Summary Load container info // @Summary Load container info
// @Description 获取容器表单信息
// @Accept json // @Accept json
// @Param request body dto.OperationWithName true "request" // @Param request body dto.OperationWithName true "request"
// @Success 200 {object} dto.ContainerOperate // @Success 200 {object} dto.ContainerOperate
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/info [post] // @Router /containers/info [post]
func (b *BaseApi) ContainerInfo(c *gin.Context) { func (b *BaseApi) ContainerInfo(c *gin.Context) {
var req dto.OperationWithName var req dto.OperationWithName
@@ -192,9 +190,9 @@ func (b *BaseApi) ContainerInfo(c *gin.Context) {
} }
// @Summary Load container limits // @Summary Load container limits
// @Description 获取容器限制
// @Success 200 {object} dto.ResourceLimit // @Success 200 {object} dto.ResourceLimit
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/limit [get] // @Router /containers/limit [get]
func (b *BaseApi) LoadResourceLimit(c *gin.Context) { func (b *BaseApi) LoadResourceLimit(c *gin.Context) {
data, err := containerService.LoadResourceLimit() data, err := containerService.LoadResourceLimit()
@@ -206,9 +204,9 @@ func (b *BaseApi) LoadResourceLimit(c *gin.Context) {
} }
// @Summary Load container stats // @Summary Load container stats
// @Description 获取容器列表资源占用
// @Success 200 {array} dto.ContainerListStats // @Success 200 {array} dto.ContainerListStats
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/list/stats [get] // @Router /containers/list/stats [get]
func (b *BaseApi) ContainerListStats(c *gin.Context) { func (b *BaseApi) ContainerListStats(c *gin.Context) {
data, err := containerService.ContainerListStats() data, err := containerService.ContainerListStats()
@@ -221,11 +219,11 @@ func (b *BaseApi) ContainerListStats(c *gin.Context) {
// @Tags Container // @Tags Container
// @Summary Create container // @Summary Create container
// @Description 创建容器
// @Accept json // @Accept json
// @Param request body dto.ContainerOperate true "request" // @Param request body dto.ContainerOperate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers [post] // @Router /containers [post]
// @x-panel-log {"bodyKeys":["name","image"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建容器 [name][image]","formatEN":"create container [name][image]"} // @x-panel-log {"bodyKeys":["name","image"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建容器 [name][image]","formatEN":"create container [name][image]"}
func (b *BaseApi) ContainerCreate(c *gin.Context) { func (b *BaseApi) ContainerCreate(c *gin.Context) {
@@ -243,11 +241,11 @@ func (b *BaseApi) ContainerCreate(c *gin.Context) {
// @Tags Container // @Tags Container
// @Summary Upgrade container // @Summary Upgrade container
// @Description 更新容器镜像
// @Accept json // @Accept json
// @Param request body dto.ContainerUpgrade true "request" // @Param request body dto.ContainerUpgrade true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/upgrade [post] // @Router /containers/upgrade [post]
// @x-panel-log {"bodyKeys":["name","image"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新容器镜像 [name][image]","formatEN":"upgrade container image [name][image]"} // @x-panel-log {"bodyKeys":["name","image"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新容器镜像 [name][image]","formatEN":"upgrade container image [name][image]"}
func (b *BaseApi) ContainerUpgrade(c *gin.Context) { func (b *BaseApi) ContainerUpgrade(c *gin.Context) {
@@ -265,11 +263,11 @@ func (b *BaseApi) ContainerUpgrade(c *gin.Context) {
// @Tags Container // @Tags Container
// @Summary Clean container // @Summary Clean container
// @Description 容器清理
// @Accept json // @Accept json
// @Param request body dto.ContainerPrune true "request" // @Param request body dto.ContainerPrune true "request"
// @Success 200 {object} dto.ContainerPruneReport // @Success 200 {object} dto.ContainerPruneReport
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/prune [post] // @Router /containers/prune [post]
// @x-panel-log {"bodyKeys":["pruneType"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清理容器 [pruneType]","formatEN":"clean container [pruneType]"} // @x-panel-log {"bodyKeys":["pruneType"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清理容器 [pruneType]","formatEN":"clean container [pruneType]"}
func (b *BaseApi) ContainerPrune(c *gin.Context) { func (b *BaseApi) ContainerPrune(c *gin.Context) {
@@ -288,11 +286,11 @@ func (b *BaseApi) ContainerPrune(c *gin.Context) {
// @Tags Container // @Tags Container
// @Summary Clean container log // @Summary Clean container log
// @Description 清理容器日志
// @Accept json // @Accept json
// @Param request body dto.OperationWithName true "request" // @Param request body dto.OperationWithName true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/clean/log [post] // @Router /containers/clean/log [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清理容器 [name] 日志","formatEN":"clean container [name] logs"} // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清理容器 [name] 日志","formatEN":"clean container [name] logs"}
func (b *BaseApi) CleanContainerLog(c *gin.Context) { func (b *BaseApi) CleanContainerLog(c *gin.Context) {
@@ -310,11 +308,11 @@ func (b *BaseApi) CleanContainerLog(c *gin.Context) {
// @Tags Container // @Tags Container
// @Summary Load container log // @Summary Load container log
// @Description 获取容器操作日志
// @Accept json // @Accept json
// @Param request body dto.OperationWithNameAndType true "request" // @Param request body dto.OperationWithNameAndType true "request"
// @Success 200 {string} content // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/load/log [post] // @Router /containers/load/log [post]
func (b *BaseApi) LoadContainerLog(c *gin.Context) { func (b *BaseApi) LoadContainerLog(c *gin.Context) {
var req dto.OperationWithNameAndType var req dto.OperationWithNameAndType
@@ -328,11 +326,11 @@ func (b *BaseApi) LoadContainerLog(c *gin.Context) {
// @Tags Container // @Tags Container
// @Summary Rename Container // @Summary Rename Container
// @Description 容器重命名
// @Accept json // @Accept json
// @Param request body dto.ContainerRename true "request" // @Param request body dto.ContainerRename true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/rename [post] // @Router /containers/rename [post]
// @x-panel-log {"bodyKeys":["name","newName"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"容器重命名 [name] => [newName]","formatEN":"rename container [name] => [newName]"} // @x-panel-log {"bodyKeys":["name","newName"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"容器重命名 [name] => [newName]","formatEN":"rename container [name] => [newName]"}
func (b *BaseApi) ContainerRename(c *gin.Context) { func (b *BaseApi) ContainerRename(c *gin.Context) {
@@ -348,32 +346,13 @@ func (b *BaseApi) ContainerRename(c *gin.Context) {
helper.SuccessWithData(c, nil) helper.SuccessWithData(c, nil)
} }
// @Tags Container
// @Summary Commit Container
// @Accept json
// @Param request body dto.ContainerCommit true "request"
// @Success 200
// @Router /containers/commit [post]
func (b *BaseApi) ContainerCommit(c *gin.Context) {
var req dto.ContainerCommit
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := containerService.ContainerCommit(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Container // @Tags Container
// @Summary Operate Container // @Summary Operate Container
// @Description 容器操作
// @Accept json // @Accept json
// @Param request body dto.ContainerOperation true "request" // @Param request body dto.ContainerOperation true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/operate [post] // @Router /containers/operate [post]
// @x-panel-log {"bodyKeys":["names","operation"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"容器 [names] 执行 [operation]","formatEN":"container [operation] [names]"} // @x-panel-log {"bodyKeys":["names","operation"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"容器 [names] 执行 [operation]","formatEN":"container [operation] [names]"}
func (b *BaseApi) ContainerOperation(c *gin.Context) { func (b *BaseApi) ContainerOperation(c *gin.Context) {
@@ -391,11 +370,11 @@ func (b *BaseApi) ContainerOperation(c *gin.Context) {
// @Tags Container // @Tags Container
// @Summary Container stats // @Summary Container stats
// @Param id path string true "container id" // @Description 容器监控信息
// @Param id path integer true "容器id"
// @Success 200 {object} dto.ContainerStats // @Success 200 {object} dto.ContainerStats
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /containers/stats/:id [get]
// @Router /containers/stats/{id} [get]
func (b *BaseApi) ContainerStats(c *gin.Context) { func (b *BaseApi) ContainerStats(c *gin.Context) {
containerID, ok := c.Params.Get("id") containerID, ok := c.Params.Get("id")
if !ok { if !ok {
@@ -413,11 +392,11 @@ func (b *BaseApi) ContainerStats(c *gin.Context) {
// @Tags Container // @Tags Container
// @Summary Container inspect // @Summary Container inspect
// @Description 容器详情
// @Accept json // @Accept json
// @Param request body dto.InspectReq true "request" // @Param request body dto.InspectReq true "request"
// @Success 200 {string} result // @Success 200 {string} result
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/inspect [post] // @Router /containers/inspect [post]
func (b *BaseApi) Inspect(c *gin.Context) { func (b *BaseApi) Inspect(c *gin.Context) {
var req dto.InspectReq var req dto.InspectReq
@@ -435,13 +414,12 @@ func (b *BaseApi) Inspect(c *gin.Context) {
// @Tags Container // @Tags Container
// @Summary Container logs // @Summary Container logs
// @Param container query string false "container name" // @Description 容器日志
// @Param since query string false "since" // @Param container query string false "容器名称"
// @Param follow query string false "follow" // @Param since query string false "时间筛选"
// @Param tail query string false "tail" // @Param follow query string false "是否追踪"
// @Success 200 // @Param tail query string false "显示行号"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/search/log [post] // @Router /containers/search/log [post]
func (b *BaseApi) ContainerLogs(c *gin.Context) { func (b *BaseApi) ContainerLogs(c *gin.Context) {
wsConn, err := upGrader.Upgrade(c.Writer, c.Request, nil) wsConn, err := upGrader.Upgrade(c.Writer, c.Request, nil)
@@ -462,33 +440,14 @@ func (b *BaseApi) ContainerLogs(c *gin.Context) {
} }
} }
// @Tags Container
// @Summary Download Container logs
// @Accept json
// @Param request body dto.ContainerLog true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/download/log [post]
func (b *BaseApi) DownloadContainerLogs(c *gin.Context) {
var req dto.ContainerLog
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
err := containerService.DownloadContainerLogs(req.ContainerType, req.Container, req.Since, strconv.Itoa(int(req.Tail)), c)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
}
}
// @Tags Container Network // @Tags Container Network
// @Summary Page networks // @Summary Page networks
// @Description 获取容器网络列表分页
// @Accept json // @Accept json
// @Param request body dto.SearchWithPage true "request" // @Param request body dto.SearchWithPage true "request"
// @Produce json // @Produce json
// @Success 200 {object} dto.PageResult // @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/network/search [post] // @Router /containers/network/search [post]
func (b *BaseApi) SearchNetwork(c *gin.Context) { func (b *BaseApi) SearchNetwork(c *gin.Context) {
var req dto.SearchWithPage var req dto.SearchWithPage
@@ -509,11 +468,11 @@ func (b *BaseApi) SearchNetwork(c *gin.Context) {
// @Tags Container Network // @Tags Container Network
// @Summary List networks // @Summary List networks
// @Description 获取容器网络列表
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Success 200 {array} dto.Options // @Success 200 {array} dto.Options
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/network [get] // @Router /containers/network [get]
func (b *BaseApi) ListNetwork(c *gin.Context) { func (b *BaseApi) ListNetwork(c *gin.Context) {
list, err := containerService.ListNetwork() list, err := containerService.ListNetwork()
@@ -526,11 +485,11 @@ func (b *BaseApi) ListNetwork(c *gin.Context) {
// @Tags Container Network // @Tags Container Network
// @Summary Delete network // @Summary Delete network
// @Description 删除容器网络
// @Accept json // @Accept json
// @Param request body dto.BatchDelete true "request" // @Param request body dto.BatchDelete true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/network/del [post] // @Router /containers/network/del [post]
// @x-panel-log {"bodyKeys":["names"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"删除容器网络 [names]","formatEN":"delete container network [names]"} // @x-panel-log {"bodyKeys":["names"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"删除容器网络 [names]","formatEN":"delete container network [names]"}
func (b *BaseApi) DeleteNetwork(c *gin.Context) { func (b *BaseApi) DeleteNetwork(c *gin.Context) {
@@ -548,11 +507,11 @@ func (b *BaseApi) DeleteNetwork(c *gin.Context) {
// @Tags Container Network // @Tags Container Network
// @Summary Create network // @Summary Create network
// @Description 创建容器网络
// @Accept json // @Accept json
// @Param request body dto.NetworkCreate true "request" // @Param request body dto.NetworkCreate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/network [post] // @Router /containers/network [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建容器网络 name","formatEN":"create container network [name]"} // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建容器网络 name","formatEN":"create container network [name]"}
func (b *BaseApi) CreateNetwork(c *gin.Context) { func (b *BaseApi) CreateNetwork(c *gin.Context) {
@@ -569,13 +528,13 @@ func (b *BaseApi) CreateNetwork(c *gin.Context) {
} }
// @Tags Container Volume // @Tags Container Volume
// @Summary Page Container Volumes // @Summary Page volumes
// @Description 获取容器存储卷分页
// @Accept json // @Accept json
// @Param request body dto.SearchWithPage true "request" // @Param request body dto.SearchWithPage true "request"
// @Produce json // @Produce json
// @Success 200 {object} dto.PageResult // @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/volume/search [post] // @Router /containers/volume/search [post]
func (b *BaseApi) SearchVolume(c *gin.Context) { func (b *BaseApi) SearchVolume(c *gin.Context) {
var req dto.SearchWithPage var req dto.SearchWithPage
@@ -595,12 +554,12 @@ func (b *BaseApi) SearchVolume(c *gin.Context) {
} }
// @Tags Container Volume // @Tags Container Volume
// @Summary List Container Volumes // @Summary List volumes
// @Description 获取容器存储卷列表
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Success 200 {array} dto.Options // @Success 200 {array} dto.Options
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/volume [get] // @Router /containers/volume [get]
func (b *BaseApi) ListVolume(c *gin.Context) { func (b *BaseApi) ListVolume(c *gin.Context) {
list, err := containerService.ListVolume() list, err := containerService.ListVolume()
@@ -612,12 +571,12 @@ func (b *BaseApi) ListVolume(c *gin.Context) {
} }
// @Tags Container Volume // @Tags Container Volume
// @Summary Delete Container Volume // @Summary Delete volume
// @Description 删除容器存储卷
// @Accept json // @Accept json
// @Param request body dto.BatchDelete true "request" // @Param request body dto.BatchDelete true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/volume/del [post] // @Router /containers/volume/del [post]
// @x-panel-log {"bodyKeys":["names"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"删除容器存储卷 [names]","formatEN":"delete container volume [names]"} // @x-panel-log {"bodyKeys":["names"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"删除容器存储卷 [names]","formatEN":"delete container volume [names]"}
func (b *BaseApi) DeleteVolume(c *gin.Context) { func (b *BaseApi) DeleteVolume(c *gin.Context) {
@@ -634,12 +593,12 @@ func (b *BaseApi) DeleteVolume(c *gin.Context) {
} }
// @Tags Container Volume // @Tags Container Volume
// @Summary Create Container Volume // @Summary Create volume
// @Description 创建容器存储卷
// @Accept json // @Accept json
// @Param request body dto.VolumeCreate true "request" // @Param request body dto.VolumeCreate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/volume [post] // @Router /containers/volume [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建容器存储卷 [name]","formatEN":"create container volume [name]"} // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建容器存储卷 [name]","formatEN":"create container volume [name]"}
func (b *BaseApi) CreateVolume(c *gin.Context) { func (b *BaseApi) CreateVolume(c *gin.Context) {
@@ -656,12 +615,12 @@ func (b *BaseApi) CreateVolume(c *gin.Context) {
} }
// @Tags Container Compose // @Tags Container Compose
// @Summary Update Container Compose // @Summary Update compose
// @Description 更新容器编排
// @Accept json // @Accept json
// @Param request body dto.ComposeUpdate true "request" // @Param request body dto.ComposeUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/compose/update [post] // @Router /containers/compose/update [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 compose [name]","formatEN":"update compose information [name]"} // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 compose [name]","formatEN":"update compose information [name]"}
func (b *BaseApi) ComposeUpdate(c *gin.Context) { func (b *BaseApi) ComposeUpdate(c *gin.Context) {
@@ -679,13 +638,12 @@ func (b *BaseApi) ComposeUpdate(c *gin.Context) {
// @Tags Container Compose // @Tags Container Compose
// @Summary Container Compose logs // @Summary Container Compose logs
// @Param compose query string false "compose file address" // @Description docker-compose 日志
// @Param since query string false "date" // @Param compose query string false "compose 文件地址"
// @Param follow query string false "follow" // @Param since query string false "时间筛选"
// @Param tail query string false "tail" // @Param follow query string false "是否追踪"
// @Success 200 // @Param tail query string false "显示行号"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/compose/search/log [get] // @Router /containers/compose/search/log [get]
func (b *BaseApi) ComposeLogs(c *gin.Context) { func (b *BaseApi) ComposeLogs(c *gin.Context) {
wsConn, err := upGrader.Upgrade(c.Writer, c.Request, nil) wsConn, err := upGrader.Upgrade(c.Writer, c.Request, nil)
+20 -16
View File
@@ -12,11 +12,11 @@ import (
// @Tags Cronjob // @Tags Cronjob
// @Summary Create cronjob // @Summary Create cronjob
// @Description 创建计划任务
// @Accept json // @Accept json
// @Param request body dto.CronjobCreate true "request" // @Param request body dto.CronjobCreate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /cronjobs [post] // @Router /cronjobs [post]
// @x-panel-log {"bodyKeys":["type","name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建计划任务 [type][name]","formatEN":"create cronjob [type][name]"} // @x-panel-log {"bodyKeys":["type","name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建计划任务 [type][name]","formatEN":"create cronjob [type][name]"}
func (b *BaseApi) CreateCronjob(c *gin.Context) { func (b *BaseApi) CreateCronjob(c *gin.Context) {
@@ -34,14 +34,14 @@ func (b *BaseApi) CreateCronjob(c *gin.Context) {
// @Tags Cronjob // @Tags Cronjob
// @Summary Page cronjobs // @Summary Page cronjobs
// @Description 获取计划任务分页
// @Accept json // @Accept json
// @Param request body dto.PageCronjob true "request" // @Param request body dto.SearchWithPage true "request"
// @Success 200 {object} dto.PageResult // @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /cronjobs/search [post] // @Router /cronjobs/search [post]
func (b *BaseApi) SearchCronjob(c *gin.Context) { func (b *BaseApi) SearchCronjob(c *gin.Context) {
var req dto.PageCronjob var req dto.SearchWithPage
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }
@@ -60,11 +60,11 @@ func (b *BaseApi) SearchCronjob(c *gin.Context) {
// @Tags Cronjob // @Tags Cronjob
// @Summary Page job records // @Summary Page job records
// @Description 获取计划任务记录
// @Accept json // @Accept json
// @Param request body dto.SearchRecord true "request" // @Param request body dto.SearchRecord true "request"
// @Success 200 {object} dto.PageResult // @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /cronjobs/search/records [post] // @Router /cronjobs/search/records [post]
func (b *BaseApi) SearchJobRecords(c *gin.Context) { func (b *BaseApi) SearchJobRecords(c *gin.Context) {
var req dto.SearchRecord var req dto.SearchRecord
@@ -72,7 +72,7 @@ func (b *BaseApi) SearchJobRecords(c *gin.Context) {
return return
} }
loc, _ := time.LoadLocation(common.LoadTimeZoneByCmd()) loc, _ := time.LoadLocation(common.LoadTimeZone())
req.StartTime = req.StartTime.In(loc) req.StartTime = req.StartTime.In(loc)
req.EndTime = req.EndTime.In(loc) req.EndTime = req.EndTime.In(loc)
@@ -90,28 +90,32 @@ func (b *BaseApi) SearchJobRecords(c *gin.Context) {
// @Tags Cronjob // @Tags Cronjob
// @Summary Load Cronjob record log // @Summary Load Cronjob record log
// @Description 获取计划任务记录日志
// @Accept json // @Accept json
// @Param request body dto.OperateByID true "request" // @Param request body dto.OperateByID true "request"
// @Success 200 {string} content // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /cronjob/record/log [post]
// @Router /cronjobs/records/log [post]
func (b *BaseApi) LoadRecordLog(c *gin.Context) { func (b *BaseApi) LoadRecordLog(c *gin.Context) {
var req dto.OperateByID var req dto.OperateByID
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }
content := cronjobService.LoadRecordLog(req) content, err := cronjobService.LoadRecordLog(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, content) helper.SuccessWithData(c, content)
} }
// @Tags Cronjob // @Tags Cronjob
// @Summary Clean job records // @Summary Clean job records
// @Description 清空计划任务记录
// @Accept json // @Accept json
// @Param request body dto.CronjobClean true "request" // @Param request body dto.CronjobClean true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /cronjobs/records/clean [post] // @Router /cronjobs/records/clean [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"cronjobs","output_column":"name","output_value":"name"}],"formatZH":"清空计划任务记录 [name]","formatEN":"clean cronjob [name] records"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"cronjobs","output_column":"name","output_value":"name"}],"formatZH":"清空计划任务记录 [name]","formatEN":"clean cronjob [name] records"}
func (b *BaseApi) CleanRecord(c *gin.Context) { func (b *BaseApi) CleanRecord(c *gin.Context) {
@@ -130,11 +134,11 @@ func (b *BaseApi) CleanRecord(c *gin.Context) {
// @Tags Cronjob // @Tags Cronjob
// @Summary Delete cronjob // @Summary Delete cronjob
// @Description 删除计划任务
// @Accept json // @Accept json
// @Param request body dto.CronjobBatchDelete true "request" // @Param request body dto.CronjobBatchDelete true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /cronjobs/del [post] // @Router /cronjobs/del [post]
// @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"cronjobs","output_column":"name","output_value":"names"}],"formatZH":"删除计划任务 [names]","formatEN":"delete cronjob [names]"} // @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"cronjobs","output_column":"name","output_value":"names"}],"formatZH":"删除计划任务 [names]","formatEN":"delete cronjob [names]"}
func (b *BaseApi) DeleteCronjob(c *gin.Context) { func (b *BaseApi) DeleteCronjob(c *gin.Context) {
@@ -152,11 +156,11 @@ func (b *BaseApi) DeleteCronjob(c *gin.Context) {
// @Tags Cronjob // @Tags Cronjob
// @Summary Update cronjob // @Summary Update cronjob
// @Description 更新计划任务
// @Accept json // @Accept json
// @Param request body dto.CronjobUpdate true "request" // @Param request body dto.CronjobUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /cronjobs/update [post] // @Router /cronjobs/update [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"cronjobs","output_column":"name","output_value":"name"}],"formatZH":"更新计划任务 [name]","formatEN":"update cronjob [name]"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"cronjobs","output_column":"name","output_value":"name"}],"formatZH":"更新计划任务 [name]","formatEN":"update cronjob [name]"}
func (b *BaseApi) UpdateCronjob(c *gin.Context) { func (b *BaseApi) UpdateCronjob(c *gin.Context) {
@@ -174,11 +178,11 @@ func (b *BaseApi) UpdateCronjob(c *gin.Context) {
// @Tags Cronjob // @Tags Cronjob
// @Summary Update cronjob status // @Summary Update cronjob status
// @Description 更新计划任务状态
// @Accept json // @Accept json
// @Param request body dto.CronjobUpdateStatus true "request" // @Param request body dto.CronjobUpdateStatus true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /cronjobs/status [post] // @Router /cronjobs/status [post]
// @x-panel-log {"bodyKeys":["id","status"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"cronjobs","output_column":"name","output_value":"name"}],"formatZH":"修改计划任务 [name] 状态为 [status]","formatEN":"change the status of cronjob [name] to [status]."} // @x-panel-log {"bodyKeys":["id","status"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"cronjobs","output_column":"name","output_value":"name"}],"formatZH":"修改计划任务 [name] 状态为 [status]","formatEN":"change the status of cronjob [name] to [status]."}
func (b *BaseApi) UpdateCronjobStatus(c *gin.Context) { func (b *BaseApi) UpdateCronjobStatus(c *gin.Context) {
@@ -196,11 +200,11 @@ func (b *BaseApi) UpdateCronjobStatus(c *gin.Context) {
// @Tags Cronjob // @Tags Cronjob
// @Summary Download cronjob records // @Summary Download cronjob records
// @Description 下载计划任务记录
// @Accept json // @Accept json
// @Param request body dto.CronjobDownload true "request" // @Param request body dto.CronjobDownload true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /cronjobs/download [post] // @Router /cronjobs/download [post]
// @x-panel-log {"bodyKeys":["recordID"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"recordID","isList":false,"db":"job_records","output_column":"file","output_value":"file"}],"formatZH":"下载计划任务记录 [file]","formatEN":"download the cronjob record [file]"} // @x-panel-log {"bodyKeys":["recordID"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"recordID","isList":false,"db":"job_records","output_column":"file","output_value":"file"}],"formatZH":"下载计划任务记录 [file]","formatEN":"download the cronjob record [file]"}
func (b *BaseApi) TargetDownload(c *gin.Context) { func (b *BaseApi) TargetDownload(c *gin.Context) {
@@ -220,11 +224,11 @@ func (b *BaseApi) TargetDownload(c *gin.Context) {
// @Tags Cronjob // @Tags Cronjob
// @Summary Handle cronjob once // @Summary Handle cronjob once
// @Description 手动执行计划任务
// @Accept json // @Accept json
// @Param request body dto.OperateByID true "request" // @Param request body dto.OperateByID true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /cronjobs/handle [post] // @Router /cronjobs/handle [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"cronjobs","output_column":"name","output_value":"name"}],"formatZH":"手动执行计划任务 [name]","formatEN":"manually execute the cronjob [name]"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"cronjobs","output_column":"name","output_value":"name"}],"formatZH":"手动执行计划任务 [name]","formatEN":"manually execute the cronjob [name]"}
func (b *BaseApi) HandleOnce(c *gin.Context) { func (b *BaseApi) HandleOnce(c *gin.Context) {
+19 -29
View File
@@ -3,38 +3,20 @@ package v1
import ( import (
"errors" "errors"
"github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
// @Tags Dashboard
// @Summary Load os info
// @Accept json
// @Success 200 {object} dto.OsInfo
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /dashboard/base/os [get]
func (b *BaseApi) LoadDashboardOsInfo(c *gin.Context) {
data, err := dashboardService.LoadOsInfo()
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, data)
}
// @Tags Dashboard // @Tags Dashboard
// @Summary Load dashboard base info // @Summary Load dashboard base info
// @Description 获取首页基础数据
// @Accept json // @Accept json
// @Param ioOption path string true "request" // @Param ioOption path string true "request"
// @Param netOption path string true "request" // @Param netOption path string true "request"
// @Success 200 {object} dto.DashboardBase // @Success 200 {object} dto.DashboardBase
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /dashboard/base/:ioOption/:netOption [get]
// @Router /dashboard/base/{ioOption}/{netOption} [get]
func (b *BaseApi) LoadDashboardBaseInfo(c *gin.Context) { func (b *BaseApi) LoadDashboardBaseInfo(c *gin.Context) {
ioOption, ok := c.Params.Get("ioOption") ioOption, ok := c.Params.Get("ioOption")
if !ok { if !ok {
@@ -56,29 +38,37 @@ func (b *BaseApi) LoadDashboardBaseInfo(c *gin.Context) {
// @Tags Dashboard // @Tags Dashboard
// @Summary Load dashboard current info // @Summary Load dashboard current info
// @Description 获取首页实时数据
// @Accept json // @Accept json
// @Param request body dto.DashboardReq true "request" // @Param ioOption path string true "request"
// @Param netOption path string true "request"
// @Success 200 {object} dto.DashboardCurrent // @Success 200 {object} dto.DashboardCurrent
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /dashboard/current/:ioOption/:netOption [get]
// @Router /dashboard/current [post]
func (b *BaseApi) LoadDashboardCurrentInfo(c *gin.Context) { func (b *BaseApi) LoadDashboardCurrentInfo(c *gin.Context) {
var req dto.DashboardReq ioOption, ok := c.Params.Get("ioOption")
if err := helper.CheckBindAndValidate(&req, c); err != nil { if !ok {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, errors.New("error ioOption in path"))
return return
} }
data := dashboardService.LoadCurrentInfo(req) netOption, ok := c.Params.Get("netOption")
if !ok {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, errors.New("error netOption in path"))
return
}
data := dashboardService.LoadCurrentInfo(ioOption, netOption)
helper.SuccessWithData(c, data) helper.SuccessWithData(c, data)
} }
// @Tags Dashboard // @Tags Dashboard
// @Summary System restart panel // @Summary System restart
// @Description 重启服务器/面板
// @Accept json // @Accept json
// @Param operation path string true "request" // @Param operation path string true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /dashboard/system/restart/:operation [post]
// @Router /dashboard/system/restart/{operation} [post]
func (b *BaseApi) SystemRestart(c *gin.Context) { func (b *BaseApi) SystemRestart(c *gin.Context) {
operation, ok := c.Params.Get("operation") operation, ok := c.Params.Get("operation")
if !ok { if !ok {
+11 -61
View File
@@ -1,8 +1,6 @@
package v1 package v1
import ( import (
"encoding/base64"
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/backend/constant" "github.com/1Panel-dev/1Panel/backend/constant"
@@ -11,11 +9,11 @@ import (
// @Tags Database // @Tags Database
// @Summary Create database // @Summary Create database
// @Description 创建远程数据库
// @Accept json // @Accept json
// @Param request body dto.DatabaseCreate true "request" // @Param request body dto.DatabaseCreate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/db [post] // @Router /databases/db [post]
// @x-panel-log {"bodyKeys":["name", "type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建远程数据库 [name][type]","formatEN":"create database [name][type]"} // @x-panel-log {"bodyKeys":["name", "type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建远程数据库 [name][type]","formatEN":"create database [name][type]"}
func (b *BaseApi) CreateDatabase(c *gin.Context) { func (b *BaseApi) CreateDatabase(c *gin.Context) {
@@ -23,14 +21,6 @@ func (b *BaseApi) CreateDatabase(c *gin.Context) {
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }
if req.SSL {
key, _ := base64.StdEncoding.DecodeString(req.ClientKey)
req.ClientKey = string(key)
cert, _ := base64.StdEncoding.DecodeString(req.ClientCert)
req.ClientCert = string(cert)
ca, _ := base64.StdEncoding.DecodeString(req.RootCert)
req.RootCert = string(ca)
}
if err := databaseService.Create(req); err != nil { if err := databaseService.Create(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
@@ -41,11 +31,11 @@ func (b *BaseApi) CreateDatabase(c *gin.Context) {
// @Tags Database // @Tags Database
// @Summary Check database // @Summary Check database
// @Description 检测远程数据库连接性
// @Accept json // @Accept json
// @Param request body dto.DatabaseCreate true "request" // @Param request body dto.DatabaseCreate true "request"
// @Success 200 {boolean} isOk // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/db/check [post] // @Router /databases/db/check [post]
// @x-panel-log {"bodyKeys":["name", "type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"检测远程数据库 [name][type] 连接性","formatEN":"check if database [name][type] is connectable"} // @x-panel-log {"bodyKeys":["name", "type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"检测远程数据库 [name][type] 连接性","formatEN":"check if database [name][type] is connectable"}
func (b *BaseApi) CheckDatabase(c *gin.Context) { func (b *BaseApi) CheckDatabase(c *gin.Context) {
@@ -53,25 +43,17 @@ func (b *BaseApi) CheckDatabase(c *gin.Context) {
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }
if req.SSL {
clientKey, _ := base64.StdEncoding.DecodeString(req.ClientKey)
req.ClientKey = string(clientKey)
clientCert, _ := base64.StdEncoding.DecodeString(req.ClientCert)
req.ClientCert = string(clientCert)
rootCert, _ := base64.StdEncoding.DecodeString(req.RootCert)
req.RootCert = string(rootCert)
}
helper.SuccessWithData(c, databaseService.CheckDatabase(req)) helper.SuccessWithData(c, databaseService.CheckDatabase(req))
} }
// @Tags Database // @Tags Database
// @Summary Page databases // @Summary Page databases
// @Description 获取远程数据库列表分页
// @Accept json // @Accept json
// @Param request body dto.DatabaseSearch true "request" // @Param request body dto.DatabaseSearch true "request"
// @Success 200 {object} dto.PageResult // @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/db/search [post] // @Router /databases/db/search [post]
func (b *BaseApi) SearchDatabase(c *gin.Context) { func (b *BaseApi) SearchDatabase(c *gin.Context) {
var req dto.DatabaseSearch var req dto.DatabaseSearch
@@ -93,11 +75,10 @@ func (b *BaseApi) SearchDatabase(c *gin.Context) {
// @Tags Database // @Tags Database
// @Summary List databases // @Summary List databases
// @Param type path string true "type" // @Description 获取远程数据库列表
// @Success 200 {array} dto.DatabaseOption // @Success 200 {array} dto.DatabaseOption
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /databases/db/list/:type [get]
// @Router /databases/db/list/{type} [get]
func (b *BaseApi) ListDatabase(c *gin.Context) { func (b *BaseApi) ListDatabase(c *gin.Context) {
dbType, err := helper.GetStrParamByKey(c, "type") dbType, err := helper.GetStrParamByKey(c, "type")
if err != nil { if err != nil {
@@ -113,35 +94,12 @@ func (b *BaseApi) ListDatabase(c *gin.Context) {
helper.SuccessWithData(c, list) helper.SuccessWithData(c, list)
} }
// @Tags Database
// @Summary Retrieve database list based on type
// @Param type path string true "type"
// @Success 200 {array} dto.DatabaseItem
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/db/item/{type} [get]
func (b *BaseApi) LoadDatabaseItems(c *gin.Context) {
dbType, err := helper.GetStrParamByKey(c, "type")
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
return
}
list, err := databaseService.LoadItems(dbType)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, list)
}
// @Tags Database // @Tags Database
// @Summary Get databases // @Summary Get databases
// @Param name path string true "name" // @Description 获取远程数据库
// @Success 200 {object} dto.DatabaseInfo // @Success 200 {object} dto.DatabaseInfo
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /databases/db/:name [get]
// @Router /databases/db/{name} [get]
func (b *BaseApi) GetDatabase(c *gin.Context) { func (b *BaseApi) GetDatabase(c *gin.Context) {
name, err := helper.GetStrParamByKey(c, "name") name, err := helper.GetStrParamByKey(c, "name")
if err != nil { if err != nil {
@@ -159,11 +117,11 @@ func (b *BaseApi) GetDatabase(c *gin.Context) {
// @Tags Database // @Tags Database
// @Summary Check before delete remote database // @Summary Check before delete remote database
// @Description Mysql 远程数据库删除前检查
// @Accept json // @Accept json
// @Param request body dto.OperateByID true "request" // @Param request body dto.OperateByID true "request"
// @Success 200 {array} string // @Success 200 {array} string
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /db/remote/del/check [post] // @Router /db/remote/del/check [post]
func (b *BaseApi) DeleteCheckDatabase(c *gin.Context) { func (b *BaseApi) DeleteCheckDatabase(c *gin.Context) {
var req dto.OperateByID var req dto.OperateByID
@@ -181,11 +139,11 @@ func (b *BaseApi) DeleteCheckDatabase(c *gin.Context) {
// @Tags Database // @Tags Database
// @Summary Delete database // @Summary Delete database
// @Description 删除远程数据库
// @Accept json // @Accept json
// @Param request body dto.DatabaseDelete true "request" // @Param request body dto.DatabaseDelete true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/db/del [post] // @Router /databases/db/del [post]
// @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"databases","output_column":"name","output_value":"names"}],"formatZH":"删除远程数据库 [names]","formatEN":"delete database [names]"} // @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"databases","output_column":"name","output_value":"names"}],"formatZH":"删除远程数据库 [names]","formatEN":"delete database [names]"}
func (b *BaseApi) DeleteDatabase(c *gin.Context) { func (b *BaseApi) DeleteDatabase(c *gin.Context) {
@@ -203,11 +161,11 @@ func (b *BaseApi) DeleteDatabase(c *gin.Context) {
// @Tags Database // @Tags Database
// @Summary Update database // @Summary Update database
// @Description 更新远程数据库
// @Accept json // @Accept json
// @Param request body dto.DatabaseUpdate true "request" // @Param request body dto.DatabaseUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/db/update [post] // @Router /databases/db/update [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新远程数据库 [name]","formatEN":"update database [name]"} // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新远程数据库 [name]","formatEN":"update database [name]"}
func (b *BaseApi) UpdateDatabase(c *gin.Context) { func (b *BaseApi) UpdateDatabase(c *gin.Context) {
@@ -215,14 +173,6 @@ func (b *BaseApi) UpdateDatabase(c *gin.Context) {
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }
if req.SSL {
cKey, _ := base64.StdEncoding.DecodeString(req.ClientKey)
req.ClientKey = string(cKey)
cCert, _ := base64.StdEncoding.DecodeString(req.ClientCert)
req.ClientCert = string(cCert)
ca, _ := base64.StdEncoding.DecodeString(req.RootCert)
req.RootCert = string(ca)
}
if err := databaseService.Update(req); err != nil { if err := databaseService.Update(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
-75
View File
@@ -1,75 +0,0 @@
package v1
import (
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/backend/constant"
"github.com/gin-gonic/gin"
)
// @Tags Database Common
// @Summary Load base info
// @Accept json
// @Param request body dto.OperationWithNameAndType true "request"
// @Success 200 {object} dto.DBBaseInfo
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/common/info [post]
func (b *BaseApi) LoadDBBaseInfo(c *gin.Context) {
var req dto.OperationWithNameAndType
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
data, err := dbCommonService.LoadBaseInfo(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, data)
}
// @Tags Database Common
// @Summary Load Database conf
// @Accept json
// @Param request body dto.OperationWithNameAndType true "request"
// @Success 200 {string} content
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/common/load/file [post]
func (b *BaseApi) LoadDBFile(c *gin.Context) {
var req dto.OperationWithNameAndType
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
content, err := dbCommonService.LoadDatabaseFile(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, content)
}
// @Tags Database Common
// @Summary Update conf by upload file
// @Accept json
// @Param request body dto.DBConfUpdateByFile true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/common/update/conf [post]
// @x-panel-log {"bodyKeys":["type","database"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 [type] 数据库 [database] 配置信息","formatEN":"update the [type] [database] database configuration information"}
func (b *BaseApi) UpdateDBConfByFile(c *gin.Context) {
var req dto.DBConfUpdateByFile
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := dbCommonService.UpdateConfByFile(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
+82 -45
View File
@@ -12,11 +12,11 @@ import (
// @Tags Database Mysql // @Tags Database Mysql
// @Summary Create mysql database // @Summary Create mysql database
// @Description 创建 mysql 数据库
// @Accept json // @Accept json
// @Param request body dto.MysqlDBCreate true "request" // @Param request body dto.MysqlDBCreate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases [post] // @Router /databases [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建 mysql 数据库 [name]","formatEN":"create mysql database [name]"} // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建 mysql 数据库 [name]","formatEN":"create mysql database [name]"}
func (b *BaseApi) CreateMysql(c *gin.Context) { func (b *BaseApi) CreateMysql(c *gin.Context) {
@@ -41,44 +41,13 @@ func (b *BaseApi) CreateMysql(c *gin.Context) {
helper.SuccessWithData(c, nil) helper.SuccessWithData(c, nil)
} }
// @Tags Database Mysql
// @Summary Bind user of mysql database
// @Accept json
// @Param request body dto.BindUser true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/bind [post]
// @x-panel-log {"bodyKeys":["database", "username"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"绑定 mysql 数据库名 [database] [username]","formatEN":"bind mysql database [database] [username]"}
func (b *BaseApi) BindUser(c *gin.Context) {
var req dto.BindUser
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if len(req.Password) != 0 {
password, err := base64.StdEncoding.DecodeString(req.Password)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
return
}
req.Password = string(password)
}
if err := mysqlService.BindUser(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Database Mysql // @Tags Database Mysql
// @Summary Update mysql database description // @Summary Update mysql database description
// @Description 更新 mysql 数据库库描述信息
// @Accept json // @Accept json
// @Param request body dto.UpdateDescription true "request" // @Param request body dto.UpdateDescription true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/description/update [post] // @Router /databases/description/update [post]
// @x-panel-log {"bodyKeys":["id","description"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"database_mysqls","output_column":"name","output_value":"name"}],"formatZH":"mysql 数据库 [name] 描述信息修改 [description]","formatEN":"The description of the mysql database [name] is modified => [description]"} // @x-panel-log {"bodyKeys":["id","description"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"database_mysqls","output_column":"name","output_value":"name"}],"formatZH":"mysql 数据库 [name] 描述信息修改 [description]","formatEN":"The description of the mysql database [name] is modified => [description]"}
func (b *BaseApi) UpdateMysqlDescription(c *gin.Context) { func (b *BaseApi) UpdateMysqlDescription(c *gin.Context) {
@@ -96,11 +65,11 @@ func (b *BaseApi) UpdateMysqlDescription(c *gin.Context) {
// @Tags Database Mysql // @Tags Database Mysql
// @Summary Change mysql password // @Summary Change mysql password
// @Description 修改 mysql 密码
// @Accept json // @Accept json
// @Param request body dto.ChangeDBInfo true "request" // @Param request body dto.ChangeDBInfo true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/change/password [post] // @Router /databases/change/password [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"database_mysqls","output_column":"name","output_value":"name"}],"formatZH":"更新数据库 [name] 密码","formatEN":"Update database [name] password"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"database_mysqls","output_column":"name","output_value":"name"}],"formatZH":"更新数据库 [name] 密码","formatEN":"Update database [name] password"}
func (b *BaseApi) ChangeMysqlPassword(c *gin.Context) { func (b *BaseApi) ChangeMysqlPassword(c *gin.Context) {
@@ -127,11 +96,11 @@ func (b *BaseApi) ChangeMysqlPassword(c *gin.Context) {
// @Tags Database Mysql // @Tags Database Mysql
// @Summary Change mysql access // @Summary Change mysql access
// @Description 修改 mysql 访问权限
// @Accept json // @Accept json
// @Param request body dto.ChangeDBInfo true "request" // @Param request body dto.ChangeDBInfo true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/change/access [post] // @Router /databases/change/access [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"database_mysqls","output_column":"name","output_value":"name"}],"formatZH":"更新数据库 [name] 访问权限","formatEN":"Update database [name] access"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"database_mysqls","output_column":"name","output_value":"name"}],"formatZH":"更新数据库 [name] 访问权限","formatEN":"Update database [name] access"}
func (b *BaseApi) ChangeMysqlAccess(c *gin.Context) { func (b *BaseApi) ChangeMysqlAccess(c *gin.Context) {
@@ -149,11 +118,11 @@ func (b *BaseApi) ChangeMysqlAccess(c *gin.Context) {
// @Tags Database Mysql // @Tags Database Mysql
// @Summary Update mysql variables // @Summary Update mysql variables
// @Description mysql 性能调优
// @Accept json // @Accept json
// @Param request body dto.MysqlVariablesUpdate true "request" // @Param request body dto.MysqlVariablesUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/variables/update [post] // @Router /databases/variables/update [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"调整 mysql 数据库性能参数","formatEN":"adjust mysql database performance parameters"} // @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"调整 mysql 数据库性能参数","formatEN":"adjust mysql database performance parameters"}
func (b *BaseApi) UpdateMysqlVariables(c *gin.Context) { func (b *BaseApi) UpdateMysqlVariables(c *gin.Context) {
@@ -169,13 +138,36 @@ func (b *BaseApi) UpdateMysqlVariables(c *gin.Context) {
helper.SuccessWithData(c, nil) helper.SuccessWithData(c, nil)
} }
// @Tags Database Mysql
// @Summary Update mysql conf by upload file
// @Description 上传替换 mysql 配置文件
// @Accept json
// @Param request body dto.MysqlConfUpdateByFile true "request"
// @Success 200
// @Security ApiKeyAuth
// @Router /databases/conffile/update [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 mysql 数据库配置信息","formatEN":"update the mysql database configuration information"}
func (b *BaseApi) UpdateMysqlConfByFile(c *gin.Context) {
var req dto.MysqlConfUpdateByFile
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := mysqlService.UpdateConfByFile(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Database Mysql // @Tags Database Mysql
// @Summary Page mysql databases // @Summary Page mysql databases
// @Description 获取 mysql 数据库列表分页
// @Accept json // @Accept json
// @Param request body dto.MysqlDBSearch true "request" // @Param request body dto.MysqlDBSearch true "request"
// @Success 200 {object} dto.PageResult // @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/search [post] // @Router /databases/search [post]
func (b *BaseApi) SearchMysql(c *gin.Context) { func (b *BaseApi) SearchMysql(c *gin.Context) {
var req dto.MysqlDBSearch var req dto.MysqlDBSearch
@@ -197,11 +189,11 @@ func (b *BaseApi) SearchMysql(c *gin.Context) {
// @Tags Database Mysql // @Tags Database Mysql
// @Summary List mysql database names // @Summary List mysql database names
// @Description 获取 mysql 数据库列表
// @Accept json // @Accept json
// @Param request body dto.PageInfo true "request" // @Param request body dto.PageInfo true "request"
// @Success 200 {array} dto.MysqlOption // @Success 200 {array} dto.MysqlOption
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/options [get] // @Router /databases/options [get]
func (b *BaseApi) ListDBName(c *gin.Context) { func (b *BaseApi) ListDBName(c *gin.Context) {
list, err := mysqlService.ListDBOption() list, err := mysqlService.ListDBOption()
@@ -215,11 +207,10 @@ func (b *BaseApi) ListDBName(c *gin.Context) {
// @Tags Database Mysql // @Tags Database Mysql
// @Summary Load mysql database from remote // @Summary Load mysql database from remote
// @Description 从服务器获取
// @Accept json // @Accept json
// @Param request body dto.MysqlLoadDB true "request" // @Param request body dto.MysqlLoadDB true "request"
// @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/load [post] // @Router /databases/load [post]
func (b *BaseApi) LoadDBFromRemote(c *gin.Context) { func (b *BaseApi) LoadDBFromRemote(c *gin.Context) {
var req dto.MysqlLoadDB var req dto.MysqlLoadDB
@@ -237,11 +228,11 @@ func (b *BaseApi) LoadDBFromRemote(c *gin.Context) {
// @Tags Database Mysql // @Tags Database Mysql
// @Summary Check before delete mysql database // @Summary Check before delete mysql database
// @Description Mysql 数据库删除前检查
// @Accept json // @Accept json
// @Param request body dto.MysqlDBDeleteCheck true "request" // @Param request body dto.MysqlDBDeleteCheck true "request"
// @Success 200 {array} string // @Success 200 {array} string
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/del/check [post] // @Router /databases/del/check [post]
func (b *BaseApi) DeleteCheckMysql(c *gin.Context) { func (b *BaseApi) DeleteCheckMysql(c *gin.Context) {
var req dto.MysqlDBDeleteCheck var req dto.MysqlDBDeleteCheck
@@ -259,11 +250,11 @@ func (b *BaseApi) DeleteCheckMysql(c *gin.Context) {
// @Tags Database Mysql // @Tags Database Mysql
// @Summary Delete mysql database // @Summary Delete mysql database
// @Description 删除 mysql 数据库
// @Accept json // @Accept json
// @Param request body dto.MysqlDBDelete true "request" // @Param request body dto.MysqlDBDelete true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/del [post] // @Router /databases/del [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"database_mysqls","output_column":"name","output_value":"name"}],"formatZH":"删除 mysql 数据库 [name]","formatEN":"delete mysql database [name]"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"database_mysqls","output_column":"name","output_value":"name"}],"formatZH":"删除 mysql 数据库 [name]","formatEN":"delete mysql database [name]"}
func (b *BaseApi) DeleteMysql(c *gin.Context) { func (b *BaseApi) DeleteMysql(c *gin.Context) {
@@ -282,19 +273,65 @@ func (b *BaseApi) DeleteMysql(c *gin.Context) {
helper.SuccessWithData(c, nil) helper.SuccessWithData(c, nil)
} }
// @Tags Database Mysql
// @Summary Load mysql base info
// @Description 获取 mysql 基础信息
// @Accept json
// @Param request body dto.OperationWithNameAndType true "request"
// @Success 200 {object} dto.DBBaseInfo
// @Security ApiKeyAuth
// @Router /databases/baseinfo [post]
func (b *BaseApi) LoadBaseinfo(c *gin.Context) {
var req dto.OperationWithNameAndType
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
data, err := mysqlService.LoadBaseInfo(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, data)
}
// @Tags Database
// @Summary Load Database file
// @Description 获取数据库文件
// @Accept json
// @Param request body dto.OperationWithNameAndType true "request"
// @Success 200
// @Security ApiKeyAuth
// @Router /databases/load/file [post]
func (b *BaseApi) LoadDatabaseFile(c *gin.Context) {
var req dto.OperationWithNameAndType
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
content, err := mysqlService.LoadDatabaseFile(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, content)
}
// @Tags Database Mysql // @Tags Database Mysql
// @Summary Load mysql remote access // @Summary Load mysql remote access
// @Description 获取 mysql 远程访问权限
// @Accept json // @Accept json
// @Param request body dto.OperationWithNameAndType true "request" // @Param request body dto.OperationWithNameAndType true "request"
// @Success 200 {boolean} isRemote // @Success 200 {boolean} isRemote
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/remote [post] // @Router /databases/remote [post]
func (b *BaseApi) LoadRemoteAccess(c *gin.Context) { func (b *BaseApi) LoadRemoteAccess(c *gin.Context) {
var req dto.OperationWithNameAndType var req dto.OperationWithNameAndType
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }
isRemote, err := mysqlService.LoadRemoteAccess(req) isRemote, err := mysqlService.LoadRemoteAccess(req)
if err != nil { if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
@@ -306,11 +343,11 @@ func (b *BaseApi) LoadRemoteAccess(c *gin.Context) {
// @Tags Database Mysql // @Tags Database Mysql
// @Summary Load mysql status info // @Summary Load mysql status info
// @Description 获取 mysql 状态信息
// @Accept json // @Accept json
// @Param request body dto.OperationWithNameAndType true "request" // @Param request body dto.OperationWithNameAndType true "request"
// @Success 200 {object} dto.MysqlStatus // @Success 200 {object} dto.MysqlStatus
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/status [post] // @Router /databases/status [post]
func (b *BaseApi) LoadStatus(c *gin.Context) { func (b *BaseApi) LoadStatus(c *gin.Context) {
var req dto.OperationWithNameAndType var req dto.OperationWithNameAndType
@@ -329,11 +366,11 @@ func (b *BaseApi) LoadStatus(c *gin.Context) {
// @Tags Database Mysql // @Tags Database Mysql
// @Summary Load mysql variables info // @Summary Load mysql variables info
// @Description 获取 mysql 性能参数信息
// @Accept json // @Accept json
// @Param request body dto.OperationWithNameAndType true "request" // @Param request body dto.OperationWithNameAndType true "request"
// @Success 200 {object} dto.MysqlVariables // @Success 200 {object} dto.MysqlVariables
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/variables [post] // @Router /databases/variables [post]
func (b *BaseApi) LoadVariables(c *gin.Context) { func (b *BaseApi) LoadVariables(c *gin.Context) {
var req dto.OperationWithNameAndType var req dto.OperationWithNameAndType
-235
View File
@@ -1,235 +0,0 @@
package v1
import (
"context"
"encoding/base64"
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/backend/constant"
"github.com/gin-gonic/gin"
)
// @Tags Database Postgresql
// @Summary Create postgresql database
// @Accept json
// @Param request body dto.PostgresqlDBCreate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/pg [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建 postgresql 数据库 [name]","formatEN":"create postgresql database [name]"}
func (b *BaseApi) CreatePostgresql(c *gin.Context) {
var req dto.PostgresqlDBCreate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if len(req.Password) != 0 {
password, err := base64.StdEncoding.DecodeString(req.Password)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
return
}
req.Password = string(password)
}
if _, err := postgresqlService.Create(context.Background(), req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Database Postgresql
// @Summary Bind postgresql user
// @Accept json
// @Param request body dto.PostgresqlBindUser true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/pg/bind [post]
// @x-panel-log {"bodyKeys":["name", "username"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"绑定 postgresql 数据库 [name] 用户 [username]","formatEN":"bind postgresql database [name] user [username]"}
func (b *BaseApi) BindPostgresqlUser(c *gin.Context) {
var req dto.PostgresqlBindUser
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := postgresqlService.BindUser(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Database Postgresql
// @Summary Update postgresql database description
// @Accept json
// @Param request body dto.UpdateDescription true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/pg/description [post]
// @x-panel-log {"bodyKeys":["id","description"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"database_postgresqls","output_column":"name","output_value":"name"}],"formatZH":"postgresql 数据库 [name] 描述信息修改 [description]","formatEN":"The description of the postgresql database [name] is modified => [description]"}
func (b *BaseApi) UpdatePostgresqlDescription(c *gin.Context) {
var req dto.UpdateDescription
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := postgresqlService.UpdateDescription(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Database Postgresql
// @Summary Change postgresql privileges
// @Accept json
// @Param request body dto.ChangeDBInfo true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/pg/privileges [post]
// @x-panel-log {"bodyKeys":["database", "username"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新数据库 [database] 用户 [username] 权限","formatEN":"Update [user] privileges of database [database]"}
func (b *BaseApi) ChangePostgresqlPrivileges(c *gin.Context) {
var req dto.PostgresqlPrivileges
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := postgresqlService.ChangePrivileges(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Database Postgresql
// @Summary Change postgresql password
// @Accept json
// @Param request body dto.ChangeDBInfo true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/pg/password [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"database_postgresqls","output_column":"name","output_value":"name"}],"formatZH":"更新数据库 [name] 密码","formatEN":"Update database [name] password"}
func (b *BaseApi) ChangePostgresqlPassword(c *gin.Context) {
var req dto.ChangeDBInfo
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if len(req.Value) != 0 {
value, err := base64.StdEncoding.DecodeString(req.Value)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
return
}
req.Value = string(value)
}
if err := postgresqlService.ChangePassword(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Database Postgresql
// @Summary Page postgresql databases
// @Accept json
// @Param request body dto.PostgresqlDBSearch true "request"
// @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/pg/search [post]
func (b *BaseApi) SearchPostgresql(c *gin.Context) {
var req dto.PostgresqlDBSearch
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
total, list, err := postgresqlService.SearchWithPage(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, dto.PageResult{
Items: list,
Total: total,
})
}
// @Tags Database Postgresql
// @Summary Load postgresql database from remote
// @Accept json
// @Param request body dto.PostgresqlLoadDB true "request"
// @Param database path string true "database"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/pg/{database}/load [post]
func (b *BaseApi) LoadPostgresqlDBFromRemote(c *gin.Context) {
database, err := helper.GetStrParamByKey(c, "database")
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
return
}
if err := postgresqlService.LoadFromRemote(database); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Database Postgresql
// @Summary Check before delete postgresql database
// @Accept json
// @Param request body dto.PostgresqlDBDeleteCheck true "request"
// @Success 200 {array} string
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/pg/del/check [post]
func (b *BaseApi) DeleteCheckPostgresql(c *gin.Context) {
var req dto.PostgresqlDBDeleteCheck
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
apps, err := postgresqlService.DeleteCheck(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, apps)
}
// @Tags Database Postgresql
// @Summary Delete postgresql database
// @Accept json
// @Param request body dto.PostgresqlDBDelete true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/pg/del [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"database_postgresqls","output_column":"name","output_value":"name"}],"formatZH":"删除 postgresql 数据库 [name]","formatEN":"delete postgresql database [name]"}
func (b *BaseApi) DeletePostgresql(c *gin.Context) {
var req dto.PostgresqlDBDelete
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
tx, ctx := helper.GetTxAndContext()
if err := postgresqlService.Delete(ctx, req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
tx.Rollback()
return
}
tx.Commit()
helper.SuccessWithData(c, nil)
}
+84 -49
View File
@@ -1,28 +1,26 @@
package v1 package v1
import ( import (
"bufio"
"encoding/base64" "encoding/base64"
"fmt"
"os"
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/backend/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/backend/utils/compose"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
// @Tags Database Redis // @Tags Database Redis
// @Summary Load redis status info // @Summary Load redis status info
// @Accept json // @Description 获取 redis 状态信息
// @Param request body dto.OperationWithName true "request"
// @Success 200 {object} dto.RedisStatus // @Success 200 {object} dto.RedisStatus
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /databases/redis/status [get]
// @Router /databases/redis/status [post]
func (b *BaseApi) LoadRedisStatus(c *gin.Context) { func (b *BaseApi) LoadRedisStatus(c *gin.Context) {
var req dto.OperationWithName data, err := redisService.LoadStatus()
if err := helper.CheckBind(&req, c); err != nil {
return
}
data, err := redisService.LoadStatus(req)
if err != nil { if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
@@ -33,18 +31,12 @@ func (b *BaseApi) LoadRedisStatus(c *gin.Context) {
// @Tags Database Redis // @Tags Database Redis
// @Summary Load redis conf // @Summary Load redis conf
// @Accept json // @Description 获取 redis 配置信息
// @Param request body dto.OperationWithName true "request"
// @Success 200 {object} dto.RedisConf // @Success 200 {object} dto.RedisConf
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /databases/redis/conf [get]
// @Router /databases/redis/conf [post]
func (b *BaseApi) LoadRedisConf(c *gin.Context) { func (b *BaseApi) LoadRedisConf(c *gin.Context) {
var req dto.OperationWithName data, err := redisService.LoadConf()
if err := helper.CheckBind(&req, c); err != nil {
return
}
data, err := redisService.LoadConf(req)
if err != nil { if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
@@ -55,18 +47,12 @@ func (b *BaseApi) LoadRedisConf(c *gin.Context) {
// @Tags Database Redis // @Tags Database Redis
// @Summary Load redis persistence conf // @Summary Load redis persistence conf
// @Accept json // @Description 获取 redis 持久化配置
// @Param request body dto.OperationWithName true "request"
// @Success 200 {object} dto.RedisPersistence // @Success 200 {object} dto.RedisPersistence
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /databases/redis/persistence/conf [get]
// @Router /databases/redis/persistence/conf [post]
func (b *BaseApi) LoadPersistenceConf(c *gin.Context) { func (b *BaseApi) LoadPersistenceConf(c *gin.Context) {
var req dto.OperationWithName data, err := redisService.LoadPersistenceConf()
if err := helper.CheckBind(&req, c); err != nil {
return
}
data, err := redisService.LoadPersistenceConf(req)
if err != nil { if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
@@ -75,32 +61,13 @@ func (b *BaseApi) LoadPersistenceConf(c *gin.Context) {
helper.SuccessWithData(c, data) helper.SuccessWithData(c, data)
} }
func (b *BaseApi) CheckHasCli(c *gin.Context) {
helper.SuccessWithData(c, redisService.CheckHasCli())
}
// @Tags Database Redis
// @Summary Install redis-cli
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/redis/install/cli [post]
func (b *BaseApi) InstallCli(c *gin.Context) {
if err := redisService.InstallCli(); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
// @Tags Database Redis // @Tags Database Redis
// @Summary Update redis conf // @Summary Update redis conf
// @Description 更新 redis 配置信息
// @Accept json // @Accept json
// @Param request body dto.RedisConfUpdate true "request" // @Param request body dto.RedisConfUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/redis/conf/update [post] // @Router /databases/redis/conf/update [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 redis 数据库配置信息","formatEN":"update the redis database configuration information"} // @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 redis 数据库配置信息","formatEN":"update the redis database configuration information"}
func (b *BaseApi) UpdateRedisConf(c *gin.Context) { func (b *BaseApi) UpdateRedisConf(c *gin.Context) {
@@ -118,11 +85,11 @@ func (b *BaseApi) UpdateRedisConf(c *gin.Context) {
// @Tags Database Redis // @Tags Database Redis
// @Summary Change redis password // @Summary Change redis password
// @Description 更新 redis 密码
// @Accept json // @Accept json
// @Param request body dto.ChangeRedisPass true "request" // @Param request body dto.ChangeRedisPass true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/redis/password [post] // @Router /databases/redis/password [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改 redis 数据库密码","formatEN":"change the password of the redis database"} // @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改 redis 数据库密码","formatEN":"change the password of the redis database"}
func (b *BaseApi) ChangeRedisPassword(c *gin.Context) { func (b *BaseApi) ChangeRedisPassword(c *gin.Context) {
@@ -149,11 +116,11 @@ func (b *BaseApi) ChangeRedisPassword(c *gin.Context) {
// @Tags Database Redis // @Tags Database Redis
// @Summary Update redis persistence conf // @Summary Update redis persistence conf
// @Description 更新 redis 持久化配置
// @Accept json // @Accept json
// @Param request body dto.RedisConfPersistenceUpdate true "request" // @Param request body dto.RedisConfPersistenceUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/redis/persistence/update [post] // @Router /databases/redis/persistence/update [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"redis 数据库持久化配置更新","formatEN":"redis database persistence configuration update"} // @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"redis 数据库持久化配置更新","formatEN":"redis database persistence configuration update"}
func (b *BaseApi) UpdateRedisPersistenceConf(c *gin.Context) { func (b *BaseApi) UpdateRedisPersistenceConf(c *gin.Context) {
@@ -168,3 +135,71 @@ func (b *BaseApi) UpdateRedisPersistenceConf(c *gin.Context) {
} }
helper.SuccessWithData(c, nil) helper.SuccessWithData(c, nil)
} }
// @Tags Database Redis
// @Summary Page redis backups
// @Description 获取 redis 备份记录分页
// @Accept json
// @Param request body dto.PageInfo true "request"
// @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth
// @Router /databases/redis/backup/search [post]
func (b *BaseApi) RedisBackupList(c *gin.Context) {
var req dto.PageInfo
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
total, list, err := redisService.SearchBackupListWithPage(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, dto.PageResult{
Items: list,
Total: total,
})
}
// @Tags Database Redis
// @Summary Update redis conf by file
// @Description 上传更新 redis 配置信息
// @Accept json
// @Param request body dto.RedisConfUpdateByFile true "request"
// @Success 200
// @Security ApiKeyAuth
// @Router /databases/redis/conffile/update [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 redis 数据库配置信息","formatEN":"update the redis database configuration information"}
func (b *BaseApi) UpdateRedisConfByFile(c *gin.Context) {
var req dto.RedisConfUpdateByFile
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
redisInfo, err := redisService.LoadConf()
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
path := fmt.Sprintf("%s/redis/%s/conf/redis.conf", constant.AppInstallDir, redisInfo.Name)
file, err := os.OpenFile(path, os.O_WRONLY|os.O_TRUNC, 0640)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
defer file.Close()
write := bufio.NewWriter(file)
_, _ = write.WriteString(req.File)
write.Flush()
if req.RestartNow {
composeDir := fmt.Sprintf("%s/redis/%s/docker-compose.yml", constant.AppInstallDir, redisInfo.Name)
if _, err := compose.Restart(composeDir); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
}
helper.SuccessWithData(c, nil)
}
-236
View File
@@ -1,236 +0,0 @@
package v1
import (
"encoding/base64"
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/backend/constant"
"github.com/gin-gonic/gin"
)
// @Tags Device
// @Summary Load device base info
// @Success 200 {object} dto.DeviceBaseInfo
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/device/base [post]
func (b *BaseApi) LoadDeviceBaseInfo(c *gin.Context) {
data, err := deviceService.LoadBaseInfo()
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, data)
}
// @Tags Device
// @Summary list time zone options
// @Accept json
// @Success 200 {array} string
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/device/zone/options [get]
func (b *BaseApi) LoadTimeOption(c *gin.Context) {
list, err := deviceService.LoadTimeZone()
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, list)
}
// @Tags Device
// @Summary load conf
// @Accept json
// @Param request body dto.OperationWithName true "request"
// @Success 200 {array} string
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/device/conf [post]
func (b *BaseApi) LoadDeviceConf(c *gin.Context) {
var req dto.OperationWithName
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
list, err := deviceService.LoadConf(req.Name)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, list)
}
// @Tags Device
// @Summary Update device conf by file
// @Accept json
// @Param request body dto.UpdateByNameAndFile true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/device/update/byconf [post]
func (b *BaseApi) UpdateDeviceByFile(c *gin.Context) {
var req dto.UpdateByNameAndFile
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := deviceService.UpdateByConf(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Device
// @Summary Update device
// @Accept json
// @Param request body dto.SettingUpdate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/device/update/conf [post]
// @x-panel-log {"bodyKeys":["key","value"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改主机参数 [key] => [value]","formatEN":"update device conf [key] => [value]"}
func (b *BaseApi) UpdateDeviceConf(c *gin.Context) {
var req dto.SettingUpdate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := deviceService.Update(req.Key, req.Value); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Device
// @Summary Update device hosts
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/device/update/host [post]
// @x-panel-log {"bodyKeys":["key","value"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改主机 Host [key] => [value]","formatEN":"update device host [key] => [value]"}
func (b *BaseApi) UpdateDeviceHost(c *gin.Context) {
var req []dto.HostHelper
if err := helper.CheckBind(&req, c); err != nil {
return
}
if err := deviceService.UpdateHosts(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Device
// @Summary Update device passwd
// @Accept json
// @Param request body dto.ChangePasswd true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/device/update/passwd [post]
func (b *BaseApi) UpdateDevicePasswd(c *gin.Context) {
var req dto.ChangePasswd
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if len(req.Passwd) != 0 {
password, err := base64.StdEncoding.DecodeString(req.Passwd)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
return
}
req.Passwd = string(password)
}
if err := deviceService.UpdatePasswd(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Device
// @Summary Update device swap
// @Accept json
// @Param request body dto.SwapHelper true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/device/update/swap [post]
// @x-panel-log {"bodyKeys":["operate","path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"[operate] 主机 swap [path]","formatEN":"[operate] device swap [path]"}
func (b *BaseApi) UpdateDeviceSwap(c *gin.Context) {
var req dto.SwapHelper
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := deviceService.UpdateSwap(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Device
// @Summary Check device DNS conf
// @Accept json
// @Param request body dto.SettingUpdate true "request"
// @Success 200 {boolean} data
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/device/check/dns [post]
func (b *BaseApi) CheckDNS(c *gin.Context) {
var req dto.SettingUpdate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
data, err := deviceService.CheckDNS(req.Key, req.Value)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, data)
}
// @Tags Device
// @Summary Scan system
// @Success 200 {object} dto.CleanData
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/scan [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"扫描系统垃圾文件","formatEN":"scan System Junk Files"}
func (b *BaseApi) ScanSystem(c *gin.Context) {
helper.SuccessWithData(c, deviceService.Scan())
}
// @Tags Device
// @Summary Clean system
// @Accept json
// @Param request body []dto.Clean true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/clean [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清理系统垃圾文件","formatEN":"Clean system junk files"}
func (b *BaseApi) SystemClean(c *gin.Context) {
var req []dto.Clean
if err := helper.CheckBind(&req, c); err != nil {
return
}
deviceService.Clean(req)
helper.SuccessWithData(c, nil)
}
+11 -34
View File
@@ -11,10 +11,10 @@ import (
// @Tags Container Docker // @Tags Container Docker
// @Summary Load docker status // @Summary Load docker status
// @Description 获取 docker 服务状态
// @Produce json // @Produce json
// @Success 200 {string} status // @Success 200 {string} status
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/docker/status [get] // @Router /containers/docker/status [get]
func (b *BaseApi) LoadDockerStatus(c *gin.Context) { func (b *BaseApi) LoadDockerStatus(c *gin.Context) {
status := dockerService.LoadDockerStatus() status := dockerService.LoadDockerStatus()
@@ -23,10 +23,10 @@ func (b *BaseApi) LoadDockerStatus(c *gin.Context) {
// @Tags Container Docker // @Tags Container Docker
// @Summary Load docker daemon.json // @Summary Load docker daemon.json
// @Description 获取 docker 配置信息(表单)
// @Produce json // @Produce json
// @Success 200 {object} string // @Success 200 {object} string
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/daemonjson/file [get] // @Router /containers/daemonjson/file [get]
func (b *BaseApi) LoadDaemonJsonFile(c *gin.Context) { func (b *BaseApi) LoadDaemonJsonFile(c *gin.Context) {
if _, err := os.Stat(constant.DaemonJsonPath); err != nil { if _, err := os.Stat(constant.DaemonJsonPath); err != nil {
@@ -43,10 +43,10 @@ func (b *BaseApi) LoadDaemonJsonFile(c *gin.Context) {
// @Tags Container Docker // @Tags Container Docker
// @Summary Load docker daemon.json // @Summary Load docker daemon.json
// @Description 获取 docker 配置信息
// @Produce json // @Produce json
// @Success 200 {object} dto.DaemonJsonConf // @Success 200 {object} dto.DaemonJsonConf
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/daemonjson [get] // @Router /containers/daemonjson [get]
func (b *BaseApi) LoadDaemonJson(c *gin.Context) { func (b *BaseApi) LoadDaemonJson(c *gin.Context) {
conf := dockerService.LoadDockerConf() conf := dockerService.LoadDockerConf()
@@ -55,13 +55,13 @@ func (b *BaseApi) LoadDaemonJson(c *gin.Context) {
// @Tags Container Docker // @Tags Container Docker
// @Summary Update docker daemon.json // @Summary Update docker daemon.json
// @Description 修改 docker 配置信息
// @Accept json // @Accept json
// @Param request body dto.SettingUpdate true "request" // @Param request body dto.SettingUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/daemonjson/update [post] // @Router /containers/daemonjson/update [post]
// @x-panel-log {"bodyKeys":["key", "value"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新配置 [key]","formatEN":"Updated configuration [key]"} // @x-panel-log {"bodyKeys":["key", "value"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 docker daemon.json 配置 [key]=>[value]","formatEN":"Updated the docker daemon.json configuration [key]=>[value]"}
func (b *BaseApi) UpdateDaemonJson(c *gin.Context) { func (b *BaseApi) UpdateDaemonJson(c *gin.Context) {
var req dto.SettingUpdate var req dto.SettingUpdate
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
@@ -78,13 +78,13 @@ func (b *BaseApi) UpdateDaemonJson(c *gin.Context) {
// @Tags Container Docker // @Tags Container Docker
// @Summary Update docker daemon.json log option // @Summary Update docker daemon.json log option
// @Description 修改 docker 日志配置
// @Accept json // @Accept json
// @Param request body dto.LogOption true "request" // @Param request body dto.LogOption true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /containers/daemonjson/update [post]
// @Router /containers/logoption/update [post] // @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 docker daemon.json 日志配置","formatEN":"Updated the docker daemon.json log option"}
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新日志配置","formatEN":"Updated the log option"}
func (b *BaseApi) UpdateLogOption(c *gin.Context) { func (b *BaseApi) UpdateLogOption(c *gin.Context) {
var req dto.LogOption var req dto.LogOption
if err := helper.CheckBind(&req, c); err != nil { if err := helper.CheckBind(&req, c); err != nil {
@@ -99,38 +99,15 @@ func (b *BaseApi) UpdateLogOption(c *gin.Context) {
helper.SuccessWithData(c, nil) helper.SuccessWithData(c, nil)
} }
// @Tags Container Docker
// @Summary Update docker daemon.json ipv6 option
// @Accept json
// @Param request body dto.LogOption true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/ipv6option/update [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 ipv6 配置","formatEN":"Updated the ipv6 option"}
func (b *BaseApi) UpdateIpv6Option(c *gin.Context) {
var req dto.Ipv6Option
if err := helper.CheckBind(&req, c); err != nil {
return
}
if err := dockerService.UpdateIpv6Option(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Container Docker // @Tags Container Docker
// @Summary Update docker daemon.json by upload file // @Summary Update docker daemon.json by upload file
// @Description 上传替换 docker 配置文件
// @Accept json // @Accept json
// @Param request body dto.DaemonJsonUpdateByFile true "request" // @Param request body dto.DaemonJsonUpdateByFile true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/daemonjson/update/byfile [post] // @Router /containers/daemonjson/update/byfile [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新配置文件","formatEN":"Updated configuration file"} // @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 docker daemon.json 配置","formatEN":"Updated the docker daemon.json configuration"}
func (b *BaseApi) UpdateDaemonJsonByFile(c *gin.Context) { func (b *BaseApi) UpdateDaemonJsonByFile(c *gin.Context) {
var req dto.DaemonJsonUpdateByFile var req dto.DaemonJsonUpdateByFile
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
@@ -147,11 +124,11 @@ func (b *BaseApi) UpdateDaemonJsonByFile(c *gin.Context) {
// @Tags Container Docker // @Tags Container Docker
// @Summary Operate docker // @Summary Operate docker
// @Description Docker 操作
// @Accept json // @Accept json
// @Param request body dto.DockerOperation true "request" // @Param request body dto.DockerOperation true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/docker/operate [post] // @Router /containers/docker/operate [post]
// @x-panel-log {"bodyKeys":["operation"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"docker 服务 [operation]","formatEN":"[operation] docker service"} // @x-panel-log {"bodyKeys":["operation"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"docker 服务 [operation]","formatEN":"[operation] docker service"}
func (b *BaseApi) OperateDocker(c *gin.Context) { func (b *BaseApi) OperateDocker(c *gin.Context) {
+5 -19
View File
@@ -15,19 +15,15 @@ var (
appService = service.NewIAppService() appService = service.NewIAppService()
appInstallService = service.NewIAppInstalledService() appInstallService = service.NewIAppInstalledService()
AIToolService = service.NewIAIToolService()
containerService = service.NewIContainerService() containerService = service.NewIContainerService()
composeTemplateService = service.NewIComposeTemplateService() composeTemplateService = service.NewIComposeTemplateService()
imageRepoService = service.NewIImageRepoService() imageRepoService = service.NewIImageRepoService()
imageService = service.NewIImageService() imageService = service.NewIImageService()
dockerService = service.NewIDockerService() dockerService = service.NewIDockerService()
dbCommonService = service.NewIDBCommonService() mysqlService = service.NewIMysqlService()
mysqlService = service.NewIMysqlService() databaseService = service.NewIDatabaseService()
postgresqlService = service.NewIPostgresqlService() redisService = service.NewIRedisService()
databaseService = service.NewIDatabaseService()
redisService = service.NewIRedisService()
cronjobService = service.NewICronjobService() cronjobService = service.NewICronjobService()
@@ -37,11 +33,6 @@ var (
sshService = service.NewISSHService() sshService = service.NewISSHService()
firewallService = service.NewIFirewallService() firewallService = service.NewIFirewallService()
deviceService = service.NewIDeviceService()
fail2banService = service.NewIFail2BanService()
ftpService = service.NewIFtpService()
clamService = service.NewIClamService()
settingService = service.NewISettingService() settingService = service.NewISettingService()
backupService = service.NewIBackupService() backupService = service.NewIBackupService()
@@ -58,16 +49,11 @@ var (
snapshotService = service.NewISnapshotService() snapshotService = service.NewISnapshotService()
upgradeService = service.NewIUpgradeService() upgradeService = service.NewIUpgradeService()
runtimeService = service.NewRuntimeService() runtimeService = service.NewRuntimeService()
processService = service.NewIProcessService() processService = service.NewIProcessService()
phpExtensionsService = service.NewIPHPExtensionsService()
hostToolService = service.NewIHostToolService() hostToolService = service.NewIHostToolService()
recycleBinService = service.NewIRecycleBinService() recycleBinService = service.NewIRecycleBinService()
favoriteService = service.NewIFavoriteService() favoriteService = service.NewIFavoriteService()
websiteCAService = service.NewIWebsiteCAService()
mcpServerService = service.NewIMcpServerService()
) )
-155
View File
@@ -1,155 +0,0 @@
package v1
import (
"os"
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/backend/constant"
"github.com/gin-gonic/gin"
)
// @Tags Fail2ban
// @Summary Load fail2ban base info
// @Success 200 {object} dto.Fail2BanBaseInfo
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/fail2ban/base [get]
func (b *BaseApi) LoadFail2BanBaseInfo(c *gin.Context) {
data, err := fail2banService.LoadBaseInfo()
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, data)
}
// @Tags Fail2ban
// @Summary Page fail2ban ip list
// @Accept json
// @Param request body dto.Fail2BanSearch true "request"
// @Success 200 {array} string
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/fail2ban/search [post]
func (b *BaseApi) SearchFail2Ban(c *gin.Context) {
var req dto.Fail2BanSearch
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
list, err := fail2banService.Search(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, list)
}
// @Tags Fail2ban
// @Summary Operate fail2ban
// @Accept json
// @Param request body dto.Operate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/fail2ban/operate [post]
// @x-panel-log {"bodyKeys":["operation"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"[operation] Fail2ban","formatEN":"[operation] Fail2ban"}
func (b *BaseApi) OperateFail2Ban(c *gin.Context) {
var req dto.Operate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := fail2banService.Operate(req.Operation); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Fail2ban
// @Summary Operate sshd of fail2ban
// @Accept json
// @Param request body dto.Operate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/fail2ban/operate/sshd [post]
func (b *BaseApi) OperateSSHD(c *gin.Context) {
var req dto.Fail2BanSet
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := fail2banService.OperateSSHD(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Fail2ban
// @Summary Update fail2ban conf
// @Accept json
// @Param request body dto.Fail2BanUpdate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/fail2ban/update [post]
// @x-panel-log {"bodyKeys":["key","value"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改 Fail2ban 配置 [key] => [value]","formatEN":"update fail2ban conf [key] => [value]"}
func (b *BaseApi) UpdateFail2BanConf(c *gin.Context) {
var req dto.Fail2BanUpdate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := fail2banService.UpdateConf(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Fail2ban
// @Summary Load fail2ban conf
// @Accept json
// @Success 200 {string} file
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/fail2ban/load/conf [get]
func (b *BaseApi) LoadFail2BanConf(c *gin.Context) {
path := "/etc/fail2ban/jail.local"
file, err := os.ReadFile(path)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, string(file))
}
// @Tags Fail2ban
// @Summary Update fail2ban conf by file
// @Accept json
// @Param request body dto.UpdateByFile true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/fail2ban/update/byconf [post]
func (b *BaseApi) UpdateFail2BanConfByFile(c *gin.Context) {
var req dto.UpdateByFile
if err := helper.CheckBind(&req, c); err != nil {
return
}
if err := fail2banService.UpdateConfByFile(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
+5 -5
View File
@@ -10,11 +10,11 @@ import (
// @Tags File // @Tags File
// @Summary List favorites // @Summary List favorites
// @Description 获取收藏列表
// @Accept json // @Accept json
// @Param request body dto.PageInfo true "request" // @Param request body dto.PageInfo true "request"
// @Success 200 {object} dto.PageResult // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/favorite/search [post] // @Router /files/favorite/search [post]
func (b *BaseApi) SearchFavorite(c *gin.Context) { func (b *BaseApi) SearchFavorite(c *gin.Context) {
var req dto.PageInfo var req dto.PageInfo
@@ -34,11 +34,11 @@ func (b *BaseApi) SearchFavorite(c *gin.Context) {
// @Tags File // @Tags File
// @Summary Create favorite // @Summary Create favorite
// @Description 创建收藏
// @Accept json // @Accept json
// @Param request body request.FavoriteCreate true "request" // @Param request body request.FavoriteCreate true "request"
// @Success 200 {object} model.Favorite // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/favorite [post] // @Router /files/favorite [post]
// @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"收藏文件/文件夹 [path]","formatEN":"收藏文件/文件夹 [path]"} // @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"收藏文件/文件夹 [path]","formatEN":"收藏文件/文件夹 [path]"}
func (b *BaseApi) CreateFavorite(c *gin.Context) { func (b *BaseApi) CreateFavorite(c *gin.Context) {
@@ -56,11 +56,11 @@ func (b *BaseApi) CreateFavorite(c *gin.Context) {
// @Tags File // @Tags File
// @Summary Delete favorite // @Summary Delete favorite
// @Description 删除收藏
// @Accept json // @Accept json
// @Param request body request.FavoriteDelete true "request" // @Param request body request.FavoriteDelete true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/favorite/del [post] // @Router /files/favorite/del [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"favorites","output_column":"path","output_value":"path"}],"formatZH":"删除收藏 [path]","formatEN":"delete avorite [path]"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"favorites","output_column":"path","output_value":"path"}],"formatZH":"删除收藏 [path]","formatEN":"delete avorite [path]"}
func (b *BaseApi) DeleteFavorite(c *gin.Context) { func (b *BaseApi) DeleteFavorite(c *gin.Context) {
+56 -178
View File
@@ -11,7 +11,6 @@ import (
"path/filepath" "path/filepath"
"strconv" "strconv"
"strings" "strings"
"syscall"
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
@@ -28,32 +27,32 @@ import (
// @Tags File // @Tags File
// @Summary List files // @Summary List files
// @Description 获取文件列表
// @Accept json // @Accept json
// @Param request body request.FileOption true "request" // @Param request body request.FileOption true "request"
// @Success 200 {object} response.FileInfo // @Success 200 {object} response.FileInfo
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/search [post] // @Router /files/search [post]
func (b *BaseApi) ListFiles(c *gin.Context) { func (b *BaseApi) ListFiles(c *gin.Context) {
var req request.FileOption var req request.FileOption
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }
fileList, err := fileService.GetFileList(req) files, err := fileService.GetFileList(req)
if err != nil { if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
} }
helper.SuccessWithData(c, fileList) helper.SuccessWithData(c, files)
} }
// @Tags File // @Tags File
// @Summary Page file // @Summary Page file
// @Description 分页获取上传文件
// @Accept json // @Accept json
// @Param request body request.SearchUploadWithPage true "request" // @Param request body request.SearchUploadWithPage true "request"
// @Success 200 {object} dto.PageResult // @Success 200 {array} response.FileInfo
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/upload/search [post] // @Router /files/upload/search [post]
func (b *BaseApi) SearchUploadWithPage(c *gin.Context) { func (b *BaseApi) SearchUploadWithPage(c *gin.Context) {
var req request.SearchUploadWithPage var req request.SearchUploadWithPage
@@ -73,11 +72,11 @@ func (b *BaseApi) SearchUploadWithPage(c *gin.Context) {
// @Tags File // @Tags File
// @Summary Load files tree // @Summary Load files tree
// @Description 加载文件树
// @Accept json // @Accept json
// @Param request body request.FileOption true "request" // @Param request body request.FileOption true "request"
// @Success 200 {array} response.FileTree // @Success 200 {array} response.FileTree
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/tree [post] // @Router /files/tree [post]
func (b *BaseApi) GetFileTree(c *gin.Context) { func (b *BaseApi) GetFileTree(c *gin.Context) {
var req request.FileOption var req request.FileOption
@@ -94,11 +93,11 @@ func (b *BaseApi) GetFileTree(c *gin.Context) {
// @Tags File // @Tags File
// @Summary Create file // @Summary Create file
// @Description 创建文件/文件夹
// @Accept json // @Accept json
// @Param request body request.FileCreate true "request" // @Param request body request.FileCreate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files [post] // @Router /files [post]
// @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建文件/文件夹 [path]","formatEN":"Create dir or file [path]"} // @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建文件/文件夹 [path]","formatEN":"Create dir or file [path]"}
func (b *BaseApi) CreateFile(c *gin.Context) { func (b *BaseApi) CreateFile(c *gin.Context) {
@@ -116,11 +115,11 @@ func (b *BaseApi) CreateFile(c *gin.Context) {
// @Tags File // @Tags File
// @Summary Delete file // @Summary Delete file
// @Description 删除文件/文件夹
// @Accept json // @Accept json
// @Param request body request.FileDelete true "request" // @Param request body request.FileDelete true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/del [post] // @Router /files/del [post]
// @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"删除文件/文件夹 [path]","formatEN":"Delete dir or file [path]"} // @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"删除文件/文件夹 [path]","formatEN":"Delete dir or file [path]"}
func (b *BaseApi) DeleteFile(c *gin.Context) { func (b *BaseApi) DeleteFile(c *gin.Context) {
@@ -138,11 +137,11 @@ func (b *BaseApi) DeleteFile(c *gin.Context) {
// @Tags File // @Tags File
// @Summary Batch delete file // @Summary Batch delete file
// @Description 批量删除文件/文件夹
// @Accept json // @Accept json
// @Param request body request.FileBatchDelete true "request" // @Param request body request.FileBatchDelete true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/batch/del [post] // @Router /files/batch/del [post]
// @x-panel-log {"bodyKeys":["paths"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"批量删除文件/文件夹 [paths]","formatEN":"Batch delete dir or file [paths]"} // @x-panel-log {"bodyKeys":["paths"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"批量删除文件/文件夹 [paths]","formatEN":"Batch delete dir or file [paths]"}
func (b *BaseApi) BatchDeleteFile(c *gin.Context) { func (b *BaseApi) BatchDeleteFile(c *gin.Context) {
@@ -160,11 +159,11 @@ func (b *BaseApi) BatchDeleteFile(c *gin.Context) {
// @Tags File // @Tags File
// @Summary Change file mode // @Summary Change file mode
// @Description 修改文件权限
// @Accept json // @Accept json
// @Param request body request.FileCreate true "request" // @Param request body request.FileCreate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/mode [post] // @Router /files/mode [post]
// @x-panel-log {"bodyKeys":["path","mode"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改权限 [paths] => [mode]","formatEN":"Change mode [paths] => [mode]"} // @x-panel-log {"bodyKeys":["path","mode"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改权限 [paths] => [mode]","formatEN":"Change mode [paths] => [mode]"}
func (b *BaseApi) ChangeFileMode(c *gin.Context) { func (b *BaseApi) ChangeFileMode(c *gin.Context) {
@@ -182,11 +181,11 @@ func (b *BaseApi) ChangeFileMode(c *gin.Context) {
// @Tags File // @Tags File
// @Summary Change file owner // @Summary Change file owner
// @Description 修改文件用户/组
// @Accept json // @Accept json
// @Param request body request.FileRoleUpdate true "request" // @Param request body request.FileRoleUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/owner [post] // @Router /files/owner [post]
// @x-panel-log {"bodyKeys":["path","user","group"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改用户/组 [paths] => [user]/[group]","formatEN":"Change owner [paths] => [user]/[group]"} // @x-panel-log {"bodyKeys":["path","user","group"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改用户/组 [paths] => [user]/[group]","formatEN":"Change owner [paths] => [user]/[group]"}
func (b *BaseApi) ChangeFileOwner(c *gin.Context) { func (b *BaseApi) ChangeFileOwner(c *gin.Context) {
@@ -203,11 +202,11 @@ func (b *BaseApi) ChangeFileOwner(c *gin.Context) {
// @Tags File // @Tags File
// @Summary Compress file // @Summary Compress file
// @Description 压缩文件
// @Accept json // @Accept json
// @Param request body request.FileCompress true "request" // @Param request body request.FileCompress true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/compress [post] // @Router /files/compress [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"压缩文件 [name]","formatEN":"Compress file [name]"} // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"压缩文件 [name]","formatEN":"Compress file [name]"}
func (b *BaseApi) CompressFile(c *gin.Context) { func (b *BaseApi) CompressFile(c *gin.Context) {
@@ -225,11 +224,11 @@ func (b *BaseApi) CompressFile(c *gin.Context) {
// @Tags File // @Tags File
// @Summary Decompress file // @Summary Decompress file
// @Description 解压文件
// @Accept json // @Accept json
// @Param request body request.FileDeCompress true "request" // @Param request body request.FileDeCompress true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/decompress [post] // @Router /files/decompress [post]
// @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"解压 [path]","formatEN":"Decompress file [path]"} // @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"解压 [path]","formatEN":"Decompress file [path]"}
func (b *BaseApi) DeCompressFile(c *gin.Context) { func (b *BaseApi) DeCompressFile(c *gin.Context) {
@@ -247,11 +246,11 @@ func (b *BaseApi) DeCompressFile(c *gin.Context) {
// @Tags File // @Tags File
// @Summary Load file content // @Summary Load file content
// @Description 获取文件内容
// @Accept json // @Accept json
// @Param request body request.FileContentReq true "request" // @Param request body request.FileContentReq true "request"
// @Success 200 {object} response.FileInfo // @Success 200 {object} response.FileInfo
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/content [post] // @Router /files/content [post]
// @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"获取文件内容 [path]","formatEN":"Load file content [path]"} // @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"获取文件内容 [path]","formatEN":"Load file content [path]"}
func (b *BaseApi) GetContent(c *gin.Context) { func (b *BaseApi) GetContent(c *gin.Context) {
@@ -269,11 +268,11 @@ func (b *BaseApi) GetContent(c *gin.Context) {
// @Tags File // @Tags File
// @Summary Update file content // @Summary Update file content
// @Description 更新文件内容
// @Accept json // @Accept json
// @Param request body request.FileEdit true "request" // @Param request body request.FileEdit true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/save [post] // @Router /files/save [post]
// @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新文件内容 [path]","formatEN":"Update file content [path]"} // @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新文件内容 [path]","formatEN":"Update file content [path]"}
func (b *BaseApi) SaveContent(c *gin.Context) { func (b *BaseApi) SaveContent(c *gin.Context) {
@@ -290,11 +289,10 @@ func (b *BaseApi) SaveContent(c *gin.Context) {
// @Tags File // @Tags File
// @Summary Upload file // @Summary Upload file
// @Accept multipart/form-data // @Description 上传文件
// @Param file formData file true "request" // @Param file formData file true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/upload [post] // @Router /files/upload [post]
// @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"上传文件 [path]","formatEN":"Upload file [path]"} // @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"上传文件 [path]","formatEN":"Upload file [path]"}
func (b *BaseApi) UploadFiles(c *gin.Context) { func (b *BaseApi) UploadFiles(c *gin.Context) {
@@ -303,91 +301,28 @@ func (b *BaseApi) UploadFiles(c *gin.Context) {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err) helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
return return
} }
uploadFiles := form.File["file"] files := form.File["file"]
paths := form.Value["path"] paths := form.Value["path"]
overwrite := true
if ow, ok := form.Value["overwrite"]; ok {
if len(ow) != 0 {
parseBool, _ := strconv.ParseBool(ow[0])
overwrite = parseBool
}
}
if len(paths) == 0 || !strings.Contains(paths[0], "/") { if len(paths) == 0 || !strings.Contains(paths[0], "/") {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, errors.New("error paths in request")) helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, errors.New("error paths in request"))
return return
} }
dir := path.Dir(paths[0]) dir := path.Dir(paths[0])
if _, err := os.Stat(dir); err != nil && os.IsNotExist(err) {
_, err = os.Stat(dir) if err = os.MkdirAll(dir, os.ModePerm); err != nil {
if err != nil && os.IsNotExist(err) {
mode, err := files.GetParentMode(dir)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
if err = os.MkdirAll(dir, mode); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, fmt.Errorf("mkdir %s failed, err: %v", dir, err)) helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, fmt.Errorf("mkdir %s failed, err: %v", dir, err))
return return
} }
} }
info, err := os.Stat(dir)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
mode := info.Mode()
fileOp := files.NewFileOp()
stat, ok := info.Sys().(*syscall.Stat_t)
uid, gid := -1, -1
if ok {
uid, gid = int(stat.Uid), int(stat.Gid)
}
success := 0 success := 0
failures := make(buserr.MultiErr) failures := make(buserr.MultiErr)
for _, file := range uploadFiles { for _, file := range files {
dstFilename := path.Join(paths[0], file.Filename) if err := c.SaveUploadedFile(file, path.Join(paths[0], file.Filename)); err != nil {
dstDir := path.Dir(dstFilename)
if !fileOp.Stat(dstDir) {
if err = fileOp.CreateDir(dstDir, mode); err != nil {
e := fmt.Errorf("create dir [%s] failed, err: %v", path.Dir(dstFilename), err)
failures[file.Filename] = e
global.LOG.Error(e)
continue
}
_ = os.Chown(dstDir, uid, gid)
}
tmpFilename := dstFilename + ".tmp"
if err := c.SaveUploadedFile(file, tmpFilename); err != nil {
_ = os.Remove(tmpFilename)
e := fmt.Errorf("upload [%s] file failed, err: %v", file.Filename, err) e := fmt.Errorf("upload [%s] file failed, err: %v", file.Filename, err)
failures[file.Filename] = e failures[file.Filename] = e
global.LOG.Error(e) global.LOG.Error(e)
continue continue
} }
dstInfo, statErr := os.Stat(dstFilename)
if overwrite {
_ = os.Remove(dstFilename)
}
err = os.Rename(tmpFilename, dstFilename)
if err != nil {
_ = os.Remove(tmpFilename)
e := fmt.Errorf("upload [%s] file failed, err: %v", file.Filename, err)
failures[file.Filename] = e
global.LOG.Error(e)
continue
}
if statErr == nil {
_ = os.Chmod(dstFilename, dstInfo.Mode())
} else {
_ = os.Chmod(dstFilename, mode)
}
if uid != -1 && gid != -1 {
_ = os.Chown(dstFilename, uid, gid)
}
success++ success++
} }
if success == 0 { if success == 0 {
@@ -399,57 +334,31 @@ func (b *BaseApi) UploadFiles(c *gin.Context) {
// @Tags File // @Tags File
// @Summary Check file exist // @Summary Check file exist
// @Description 检测文件是否存在
// @Accept json // @Accept json
// @Param request body request.FilePathCheck true "request" // @Param request body request.FilePathCheck true "request"
// @Success 200 {boolean} isOk // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/check [post] // @Router /files/check [post]
func (b *BaseApi) CheckFile(c *gin.Context) { func (b *BaseApi) CheckFile(c *gin.Context) {
var req request.FilePathCheck var req request.FilePathCheck
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }
fileOp := files.NewFileOp() if _, err := os.Stat(req.Path); err != nil {
if fileOp.Stat(req.Path) { helper.SuccessWithData(c, false)
helper.SuccessWithData(c, true)
return return
} }
if req.WithInit { helper.SuccessWithData(c, true)
if err := fileOp.CreateDir(req.Path, 0644); err != nil {
helper.SuccessWithData(c, false)
return
}
helper.SuccessWithData(c, true)
return
}
helper.SuccessWithData(c, false)
}
// @Tags File
// @Summary Batch check file exist
// @Accept json
// @Param request body request.FilePathsCheck true "request"
// @Success 200 {array} response.ExistFileInfo
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/batch/check [post]
func (b *BaseApi) BatchCheckFiles(c *gin.Context) {
var req request.FilePathsCheck
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
fileList := fileService.BatchCheckFiles(req)
helper.SuccessWithData(c, fileList)
} }
// @Tags File // @Tags File
// @Summary Change file name // @Summary Change file name
// @Description 修改文件名称
// @Accept json // @Accept json
// @Param request body request.FileRename true "request" // @Param request body request.FileRename true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/rename [post] // @Router /files/rename [post]
// @x-panel-log {"bodyKeys":["oldName","newName"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"重命名 [oldName] => [newName]","formatEN":"Rename [oldName] => [newName]"} // @x-panel-log {"bodyKeys":["oldName","newName"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"重命名 [oldName] => [newName]","formatEN":"Rename [oldName] => [newName]"}
func (b *BaseApi) ChangeFileName(c *gin.Context) { func (b *BaseApi) ChangeFileName(c *gin.Context) {
@@ -466,11 +375,11 @@ func (b *BaseApi) ChangeFileName(c *gin.Context) {
// @Tags File // @Tags File
// @Summary Wget file // @Summary Wget file
// @Description 下载远端文件
// @Accept json // @Accept json
// @Param request body request.FileWget true "request" // @Param request body request.FileWget true "request"
// @Success 200 {object} response.FileWgetRes // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/wget [post] // @Router /files/wget [post]
// @x-panel-log {"bodyKeys":["url","path","name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"下载 url => [path]/[name]","formatEN":"Download url => [path]/[name]"} // @x-panel-log {"bodyKeys":["url","path","name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"下载 url => [path]/[name]","formatEN":"Download url => [path]/[name]"}
func (b *BaseApi) WgetFile(c *gin.Context) { func (b *BaseApi) WgetFile(c *gin.Context) {
@@ -490,11 +399,11 @@ func (b *BaseApi) WgetFile(c *gin.Context) {
// @Tags File // @Tags File
// @Summary Move file // @Summary Move file
// @Description 移动文件
// @Accept json // @Accept json
// @Param request body request.FileMove true "request" // @Param request body request.FileMove true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/move [post] // @Router /files/move [post]
// @x-panel-log {"bodyKeys":["oldPaths","newPath"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"移动文件 [oldPaths] => [newPath]","formatEN":"Move [oldPaths] => [newPath]"} // @x-panel-log {"bodyKeys":["oldPaths","newPath"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"移动文件 [oldPaths] => [newPath]","formatEN":"Move [oldPaths] => [newPath]"}
func (b *BaseApi) MoveFile(c *gin.Context) { func (b *BaseApi) MoveFile(c *gin.Context) {
@@ -511,18 +420,19 @@ func (b *BaseApi) MoveFile(c *gin.Context) {
// @Tags File // @Tags File
// @Summary Download file // @Summary Download file
// @Description 下载文件
// @Accept json // @Accept json
// @Param request body request.FileDownload true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /files/download [post]
// @Router /files/download [get] // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"下载文件 [name]","formatEN":"Download file [name]"}
func (b *BaseApi) Download(c *gin.Context) { func (b *BaseApi) Download(c *gin.Context) {
filePath := c.Query("path") filePath := c.Query("path")
file, err := os.Open(filePath) file, err := os.Open(filePath)
if err != nil { if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
} }
defer file.Close()
info, _ := file.Stat() info, _ := file.Stat()
c.Header("Content-Length", strconv.FormatInt(info.Size(), 10)) c.Header("Content-Length", strconv.FormatInt(info.Size(), 10))
c.Header("Content-Disposition", "attachment; filename*=utf-8''"+url.PathEscape(info.Name())) c.Header("Content-Disposition", "attachment; filename*=utf-8''"+url.PathEscape(info.Name()))
@@ -531,11 +441,11 @@ func (b *BaseApi) Download(c *gin.Context) {
// @Tags File // @Tags File
// @Summary Chunk Download file // @Summary Chunk Download file
// @Description 分片下载下载文件
// @Accept json // @Accept json
// @Param request body request.FileDownload true "request" // @Param request body request.FileDownload true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/chunkdownload [post] // @Router /files/chunkdownload [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"下载文件 [name]","formatEN":"Download file [name]"} // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"下载文件 [name]","formatEN":"Download file [name]"}
func (b *BaseApi) DownloadChunkFiles(c *gin.Context) { func (b *BaseApi) DownloadChunkFiles(c *gin.Context) {
@@ -608,11 +518,11 @@ func (b *BaseApi) DownloadChunkFiles(c *gin.Context) {
// @Tags File // @Tags File
// @Summary Load file size // @Summary Load file size
// @Description 获取文件夹大小
// @Accept json // @Accept json
// @Param request body request.DirSizeReq true "request" // @Param request body request.DirSizeReq true "request"
// @Success 200 {object} response.DirSizeRes // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/size [post] // @Router /files/size [post]
// @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"获取文件夹大小 [path]","formatEN":"Load file size [path]"} // @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"获取文件夹大小 [path]","formatEN":"Load file size [path]"}
func (b *BaseApi) Size(c *gin.Context) { func (b *BaseApi) Size(c *gin.Context) {
@@ -628,46 +538,20 @@ func (b *BaseApi) Size(c *gin.Context) {
helper.SuccessWithData(c, res) helper.SuccessWithData(c, res)
} }
func mergeChunks(fileName string, fileDir string, dstDir string, chunkCount int, overwrite bool) error { func mergeChunks(fileName string, fileDir string, dstDir string, chunkCount int) error {
defer func() {
_ = os.RemoveAll(fileDir)
}()
op := files.NewFileOp() op := files.NewFileOp()
dstDir = strings.TrimSpace(dstDir) dstDir = strings.TrimSpace(dstDir)
mode, _ := files.GetParentMode(dstDir) if _, err := os.Stat(dstDir); err != nil && os.IsNotExist(err) {
if mode == 0 { if err = op.CreateDir(dstDir, os.ModePerm); err != nil {
mode = 0755 return err
}
uid, gid := -1, -1
if info, err := os.Stat(dstDir); err != nil {
if os.IsNotExist(err) {
if err = op.CreateDir(dstDir, mode); err != nil {
return err
}
}
} else {
stat, ok := info.Sys().(*syscall.Stat_t)
if ok {
uid, gid = int(stat.Uid), int(stat.Gid)
} }
} }
dstFileName := filepath.Join(dstDir, fileName) targetFile, err := os.Create(filepath.Join(dstDir, fileName))
dstInfo, statErr := os.Stat(dstFileName)
if statErr == nil {
mode = dstInfo.Mode()
} else {
mode = 0644
}
if overwrite {
_ = os.Remove(dstFileName)
}
targetFile, err := os.OpenFile(dstFileName, os.O_RDWR|os.O_CREATE, mode)
if err != nil { if err != nil {
return err return err
} }
defer targetFile.Close() defer targetFile.Close()
for i := 0; i < chunkCount; i++ { for i := 0; i < chunkCount; i++ {
chunkPath := filepath.Join(fileDir, fmt.Sprintf("%s.%d", fileName, i)) chunkPath := filepath.Join(fileDir, fmt.Sprintf("%s.%d", fileName, i))
chunkData, err := os.ReadFile(chunkPath) chunkData, err := os.ReadFile(chunkPath)
@@ -678,22 +562,17 @@ func mergeChunks(fileName string, fileDir string, dstDir string, chunkCount int,
if err != nil { if err != nil {
return err return err
} }
_ = os.Remove(chunkPath)
}
if uid != -1 && gid != -1 {
_ = os.Chown(dstFileName, uid, gid)
} }
return nil return files.NewFileOp().DeleteDir(fileDir)
} }
// @Tags File // @Tags File
// @Summary Chunk upload file // @Summary ChunkUpload file
// @Accept multipart/form-data // @Description 分片上传文件
// @Param file formData file true "request" // @Param file formData file true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/chunkupload [post] // @Router /files/chunkupload [post]
func (b *BaseApi) UploadChunkFiles(c *gin.Context) { func (b *BaseApi) UploadChunkFiles(c *gin.Context) {
var err error var err error
@@ -707,7 +586,6 @@ func (b *BaseApi) UploadChunkFiles(c *gin.Context) {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err) helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
return return
} }
defer uploadFile.Close()
chunkIndex, err := strconv.Atoi(c.PostForm("chunkIndex")) chunkIndex, err := strconv.Atoi(c.PostForm("chunkIndex"))
if err != nil { if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err) helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
@@ -767,11 +645,7 @@ func (b *BaseApi) UploadChunkFiles(c *gin.Context) {
} }
if chunkIndex+1 == chunkCount { if chunkIndex+1 == chunkCount {
overwrite := true err = mergeChunks(filename, fileDir, c.PostForm("path"), chunkCount)
if ow := c.PostForm("overwrite"); ow != "" {
overwrite, _ = strconv.ParseBool(ow)
}
err = mergeChunks(filename, fileDir, c.PostForm("path"), chunkCount, overwrite)
if err != nil { if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, buserr.WithMap(constant.ErrFileUpload, map[string]interface{}{"name": filename, "detail": err.Error()}, err)) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, buserr.WithMap(constant.ErrFileUpload, map[string]interface{}{"name": filename, "detail": err.Error()}, err))
return return
@@ -811,31 +685,35 @@ func (b *BaseApi) Keys(c *gin.Context) {
// @Tags File // @Tags File
// @Summary Read file by Line // @Summary Read file by Line
// @Description 按行读取文件
// @Param request body request.FileReadByLineReq true "request" // @Param request body request.FileReadByLineReq true "request"
// @Success 200 {object} response.FileLineContent // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/read [post] // @Router /files/read [post]
func (b *BaseApi) ReadFileByLine(c *gin.Context) { func (b *BaseApi) ReadFileByLine(c *gin.Context) {
var req request.FileReadByLineReq var req request.FileReadByLineReq
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }
res, err := fileService.ReadLogByLine(req) lines, end, err := files.ReadFileByLine(req.Path, req.Page, req.PageSize)
if err != nil { if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
} }
res := response.FileLineContent{
End: end,
}
res.Path = req.Path
res.Content = strings.Join(lines, "\n")
helper.SuccessWithData(c, res) helper.SuccessWithData(c, res)
} }
// @Tags File // @Tags File
// @Summary Batch change file mode and owner // @Summary Batch change file mode and owner
// @Description 批量修改文件权限和用户/组
// @Accept json // @Accept json
// @Param request body request.FileRoleReq true "request" // @Param request body request.FileRoleReq true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/batch/role [post] // @Router /files/batch/role [post]
// @x-panel-log {"bodyKeys":["paths","mode","user","group"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"批量修改文件权限和用户/组 [paths] => [mode]/[user]/[group]","formatEN":"Batch change file mode and owner [paths] => [mode]/[user]/[group]"} // @x-panel-log {"bodyKeys":["paths","mode","user","group"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"批量修改文件权限和用户/组 [paths] => [mode]/[user]/[group]","formatEN":"Batch change file mode and owner [paths] => [mode]/[user]/[group]"}
func (b *BaseApi) BatchChangeModeAndOwner(c *gin.Context) { func (b *BaseApi) BatchChangeModeAndOwner(c *gin.Context) {
+15 -38
View File
@@ -9,9 +9,9 @@ import (
// @Tags Firewall // @Tags Firewall
// @Summary Load firewall base info // @Summary Load firewall base info
// @Description 获取防火墙基础信息
// @Success 200 {object} dto.FirewallBaseInfo // @Success 200 {object} dto.FirewallBaseInfo
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/firewall/base [get] // @Router /hosts/firewall/base [get]
func (b *BaseApi) LoadFirewallBaseInfo(c *gin.Context) { func (b *BaseApi) LoadFirewallBaseInfo(c *gin.Context) {
data, err := firewallService.LoadBaseInfo() data, err := firewallService.LoadBaseInfo()
@@ -25,11 +25,11 @@ func (b *BaseApi) LoadFirewallBaseInfo(c *gin.Context) {
// @Tags Firewall // @Tags Firewall
// @Summary Page firewall rules // @Summary Page firewall rules
// @Description 获取防火墙规则列表分页
// @Accept json // @Accept json
// @Param request body dto.RuleSearch true "request" // @Param request body dto.RuleSearch true "request"
// @Success 200 {object} dto.PageResult // @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/firewall/search [post] // @Router /hosts/firewall/search [post]
func (b *BaseApi) SearchFirewallRule(c *gin.Context) { func (b *BaseApi) SearchFirewallRule(c *gin.Context) {
var req dto.RuleSearch var req dto.RuleSearch
@@ -51,11 +51,11 @@ func (b *BaseApi) SearchFirewallRule(c *gin.Context) {
// @Tags Firewall // @Tags Firewall
// @Summary Page firewall status // @Summary Page firewall status
// @Description 修改防火墙状态
// @Accept json // @Accept json
// @Param request body dto.FirewallOperation true "request" // @Param request body dto.FirewallOperation true "request"
// @Success 200 // @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/firewall/operate [post] // @Router /hosts/firewall/operate [post]
// @x-panel-log {"bodyKeys":["operation"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"[operation] 防火墙","formatEN":"[operation] firewall"} // @x-panel-log {"bodyKeys":["operation"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"[operation] 防火墙","formatEN":"[operation] firewall"}
func (b *BaseApi) OperateFirewall(c *gin.Context) { func (b *BaseApi) OperateFirewall(c *gin.Context) {
@@ -73,12 +73,12 @@ func (b *BaseApi) OperateFirewall(c *gin.Context) {
} }
// @Tags Firewall // @Tags Firewall
// @Summary Create firewall port group // @Summary Create group
// @Description 创建防火墙端口规则
// @Accept json // @Accept json
// @Param request body dto.PortRuleOperate true "request" // @Param request body dto.PortRuleOperate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/firewall/port [post] // @Router /hosts/firewall/port [post]
// @x-panel-log {"bodyKeys":["port","strategy"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"添加端口规则 [strategy] [port]","formatEN":"create port rules [strategy][port]"} // @x-panel-log {"bodyKeys":["port","strategy"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"添加端口规则 [strategy] [port]","formatEN":"create port rules [strategy][port]"}
func (b *BaseApi) OperatePortRule(c *gin.Context) { func (b *BaseApi) OperatePortRule(c *gin.Context) {
@@ -94,36 +94,13 @@ func (b *BaseApi) OperatePortRule(c *gin.Context) {
helper.SuccessWithData(c, nil) helper.SuccessWithData(c, nil)
} }
// OperateForwardRule
// @Tags Firewall // @Tags Firewall
// @Summary Update firewall port group // @Summary Create group
// @Accept json // @Description 创建防火墙 IP 规则
// @Param request body dto.ForwardRuleOperate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/firewall/forward [post]
// @x-panel-log {"bodyKeys":["source_port"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新端口转发规则 [source_port]","formatEN":"update port forward rules [source_port]"}
func (b *BaseApi) OperateForwardRule(c *gin.Context) {
var req dto.ForwardRuleOperate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := firewallService.OperateForwardRule(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Firewall
// @Summary Create firewall group
// @Accept json // @Accept json
// @Param request body dto.AddrRuleOperate true "request" // @Param request body dto.AddrRuleOperate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/firewall/ip [post] // @Router /hosts/firewall/ip [post]
// @x-panel-log {"bodyKeys":["strategy","address"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"添加 ip 规则 [strategy] [address]","formatEN":"create address rules [strategy][address]"} // @x-panel-log {"bodyKeys":["strategy","address"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"添加 ip 规则 [strategy] [address]","formatEN":"create address rules [strategy][address]"}
func (b *BaseApi) OperateIPRule(c *gin.Context) { func (b *BaseApi) OperateIPRule(c *gin.Context) {
@@ -140,12 +117,12 @@ func (b *BaseApi) OperateIPRule(c *gin.Context) {
} }
// @Tags Firewall // @Tags Firewall
// @Summary Batch create group // @Summary Create group
// @Description 批量删除防火墙规则
// @Accept json // @Accept json
// @Param request body dto.BatchRuleOperate true "request" // @Param request body dto.BatchRuleOperate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/firewall/batch [post] // @Router /hosts/firewall/batch [post]
func (b *BaseApi) BatchOperateRule(c *gin.Context) { func (b *BaseApi) BatchOperateRule(c *gin.Context) {
var req dto.BatchRuleOperate var req dto.BatchRuleOperate
@@ -162,11 +139,11 @@ func (b *BaseApi) BatchOperateRule(c *gin.Context) {
// @Tags Firewall // @Tags Firewall
// @Summary Update rule description // @Summary Update rule description
// @Description 更新防火墙描述
// @Accept json // @Accept json
// @Param request body dto.UpdateFirewallDescription true "request" // @Param request body dto.UpdateFirewallDescription true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/firewall/update/description [post] // @Router /hosts/firewall/update/description [post]
func (b *BaseApi) UpdateFirewallDescription(c *gin.Context) { func (b *BaseApi) UpdateFirewallDescription(c *gin.Context) {
var req dto.UpdateFirewallDescription var req dto.UpdateFirewallDescription
@@ -182,12 +159,12 @@ func (b *BaseApi) UpdateFirewallDescription(c *gin.Context) {
} }
// @Tags Firewall // @Tags Firewall
// @Summary Update firewall group // @Summary Create group
// @Description 更新端口防火墙规则
// @Accept json // @Accept json
// @Param request body dto.PortRuleUpdate true "request" // @Param request body dto.PortRuleUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/firewall/update/port [post] // @Router /hosts/firewall/update/port [post]
func (b *BaseApi) UpdatePortRule(c *gin.Context) { func (b *BaseApi) UpdatePortRule(c *gin.Context) {
var req dto.PortRuleUpdate var req dto.PortRuleUpdate
@@ -203,12 +180,12 @@ func (b *BaseApi) UpdatePortRule(c *gin.Context) {
} }
// @Tags Firewall // @Tags Firewall
// @Summary Update address group // @Summary Create group
// @Description 更新 ip 防火墙规则
// @Accept json // @Accept json
// @Param request body dto.AddrRuleUpdate true "request" // @Param request body dto.AddrRuleUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/firewall/update/addr [post] // @Router /hosts/firewall/update/addr [post]
func (b *BaseApi) UpdateAddrRule(c *gin.Context) { func (b *BaseApi) UpdateAddrRule(c *gin.Context) {
var req dto.AddrRuleUpdate var req dto.AddrRuleUpdate
-200
View File
@@ -1,200 +0,0 @@
package v1
import (
"encoding/base64"
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/backend/constant"
"github.com/gin-gonic/gin"
)
// @Tags FTP
// @Summary Load FTP base info
// @Success 200 {object} dto.FtpBaseInfo
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/ftp/base [get]
func (b *BaseApi) LoadFtpBaseInfo(c *gin.Context) {
data, err := ftpService.LoadBaseInfo()
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, data)
}
// @Tags FTP
// @Summary Load FTP operation log
// @Accept json
// @Param request body dto.FtpLogSearch true "request"
// @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/ftp/log/search [post]
func (b *BaseApi) LoadFtpLogInfo(c *gin.Context) {
var req dto.FtpLogSearch
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
total, list, err := ftpService.LoadLog(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, dto.PageResult{
Items: list,
Total: total,
})
}
// @Tags FTP
// @Summary Operate FTP
// @Accept json
// @Param request body dto.Operate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/ftp/operate [post]
// @x-panel-log {"bodyKeys":["operation"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"[operation] FTP","formatEN":"[operation] FTP"}
func (b *BaseApi) OperateFtp(c *gin.Context) {
var req dto.Operate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := ftpService.Operate(req.Operation); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags FTP
// @Summary Page FTP user
// @Accept json
// @Param request body dto.SearchWithPage true "request"
// @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/ftp/search [post]
func (b *BaseApi) SearchFtp(c *gin.Context) {
var req dto.SearchWithPage
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
total, list, err := ftpService.SearchWithPage(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, dto.PageResult{
Items: list,
Total: total,
})
}
// @Tags FTP
// @Summary Create FTP user
// @Accept json
// @Param request body dto.FtpCreate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/ftp [post]
// @x-panel-log {"bodyKeys":["user", "path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建 FTP 账户 [user][path]","formatEN":"create FTP [user][path]"}
func (b *BaseApi) CreateFtp(c *gin.Context) {
var req dto.FtpCreate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if len(req.Password) != 0 {
pass, err := base64.StdEncoding.DecodeString(req.Password)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
return
}
req.Password = string(pass)
}
if _, err := ftpService.Create(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
// @Tags FTP
// @Summary Delete FTP user
// @Accept json
// @Param request body dto.BatchDeleteReq true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/ftp/del [post]
// @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"ftps","output_column":"user","output_value":"users"}],"formatZH":"删除 FTP 账户 [users]","formatEN":"delete FTP users [users]"}
func (b *BaseApi) DeleteFtp(c *gin.Context) {
var req dto.BatchDeleteReq
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := ftpService.Delete(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
// @Tags FTP
// @Summary Sync FTP user
// @Accept json
// @Param request body dto.BatchDeleteReq true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/ftp/sync [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"同步 FTP 账户","formatEN":"sync FTP users"}
func (b *BaseApi) SyncFtp(c *gin.Context) {
if err := ftpService.Sync(); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
// @Tags FTP
// @Summary Update FTP user
// @Accept json
// @Param request body dto.FtpUpdate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /toolbox/ftp/update [post]
// @x-panel-log {"bodyKeys":["user", "path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改 FTP 账户 [user][path]","formatEN":"update FTP [user][path]"}
func (b *BaseApi) UpdateFtp(c *gin.Context) {
var req dto.FtpUpdate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if len(req.Password) != 0 {
pass, err := base64.StdEncoding.DecodeString(req.Password)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
return
}
req.Password = string(pass)
}
if err := ftpService.Update(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
+8 -8
View File
@@ -8,12 +8,12 @@ import (
) )
// @Tags System Group // @Tags System Group
// @Summary Create system group // @Summary Create group
// @Description 创建系统组
// @Accept json // @Accept json
// @Param request body dto.GroupCreate true "request" // @Param request body dto.GroupCreate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /groups [post] // @Router /groups [post]
// @x-panel-log {"bodyKeys":["name","type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建组 [name][type]","formatEN":"create group [name][type]"} // @x-panel-log {"bodyKeys":["name","type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建组 [name][type]","formatEN":"create group [name][type]"}
func (b *BaseApi) CreateGroup(c *gin.Context) { func (b *BaseApi) CreateGroup(c *gin.Context) {
@@ -30,12 +30,12 @@ func (b *BaseApi) CreateGroup(c *gin.Context) {
} }
// @Tags System Group // @Tags System Group
// @Summary Delete system group // @Summary Delete group
// @Description 删除系统组
// @Accept json // @Accept json
// @Param request body dto.OperateByID true "request" // @Param request body dto.OperateByID true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /groups/del [post] // @Router /groups/del [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"groups","output_column":"name","output_value":"name"},{"input_column":"id","input_value":"id","isList":false,"db":"groups","output_column":"type","output_value":"type"}],"formatZH":"删除组 [type][name]","formatEN":"delete group [type][name]"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"groups","output_column":"name","output_value":"name"},{"input_column":"id","input_value":"id","isList":false,"db":"groups","output_column":"type","output_value":"type"}],"formatZH":"删除组 [type][name]","formatEN":"delete group [type][name]"}
func (b *BaseApi) DeleteGroup(c *gin.Context) { func (b *BaseApi) DeleteGroup(c *gin.Context) {
@@ -52,12 +52,12 @@ func (b *BaseApi) DeleteGroup(c *gin.Context) {
} }
// @Tags System Group // @Tags System Group
// @Summary Update system group // @Summary Update group
// @Description 更新系统组
// @Accept json // @Accept json
// @Param request body dto.GroupUpdate true "request" // @Param request body dto.GroupUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /groups/update [post] // @Router /groups/update [post]
// @x-panel-log {"bodyKeys":["name","type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新组 [name][type]","formatEN":"update group [name][type]"} // @x-panel-log {"bodyKeys":["name","type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新组 [name][type]","formatEN":"update group [name][type]"}
func (b *BaseApi) UpdateGroup(c *gin.Context) { func (b *BaseApi) UpdateGroup(c *gin.Context) {
@@ -74,12 +74,12 @@ func (b *BaseApi) UpdateGroup(c *gin.Context) {
} }
// @Tags System Group // @Tags System Group
// @Summary List system groups // @Summary List groups
// @Description 查询系统组
// @Accept json // @Accept json
// @Param request body dto.GroupSearch true "request" // @Param request body dto.GroupSearch true "request"
// @Success 200 {array} dto.GroupInfo // @Success 200 {array} dto.GroupInfo
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /groups/search [post] // @Router /groups/search [post]
func (b *BaseApi) ListGroup(c *gin.Context) { func (b *BaseApi) ListGroup(c *gin.Context) {
var req dto.GroupSearch var req dto.GroupSearch
-21
View File
@@ -3,7 +3,6 @@ package helper
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/1Panel-dev/1Panel/cmd/server/res"
"net/http" "net/http"
"strconv" "strconv"
@@ -134,23 +133,3 @@ func CheckBind(req interface{}, c *gin.Context) error {
} }
return nil return nil
} }
func ErrWithHtml(ctx *gin.Context, code int, scope string) {
if code == 444 {
ctx.String(444, "")
ctx.Abort()
return
}
file := fmt.Sprintf("html/%d.html", code)
if code == 200 && scope != "" {
file = fmt.Sprintf("html/200_%s.html", scope)
}
data, err := res.ErrorMsg.ReadFile(file)
if err != nil {
ctx.String(http.StatusInternalServerError, "Internal Server Error")
ctx.Abort()
return
}
ctx.Data(code, "text/html; charset=utf-8", data)
ctx.Abort()
}
+12 -12
View File
@@ -10,11 +10,11 @@ import (
// @Tags Host // @Tags Host
// @Summary Create host // @Summary Create host
// @Description 创建主机
// @Accept json // @Accept json
// @Param request body dto.HostOperate true "request" // @Param request body dto.HostOperate true "request"
// @Success 200 {object} dto.HostInfo // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts [post] // @Router /hosts [post]
// @x-panel-log {"bodyKeys":["name","addr"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建主机 [name][addr]","formatEN":"create host [name][addr]"} // @x-panel-log {"bodyKeys":["name","addr"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建主机 [name][addr]","formatEN":"create host [name][addr]"}
func (b *BaseApi) CreateHost(c *gin.Context) { func (b *BaseApi) CreateHost(c *gin.Context) {
@@ -33,11 +33,11 @@ func (b *BaseApi) CreateHost(c *gin.Context) {
// @Tags Host // @Tags Host
// @Summary Test host conn by info // @Summary Test host conn by info
// @Description 测试主机连接
// @Accept json // @Accept json
// @Param request body dto.HostConnTest true "request" // @Param request body dto.HostConnTest true "request"
// @Success 200 {boolean} connStatus // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/test/byinfo [post] // @Router /hosts/test/byinfo [post]
func (b *BaseApi) TestByInfo(c *gin.Context) { func (b *BaseApi) TestByInfo(c *gin.Context) {
var req dto.HostConnTest var req dto.HostConnTest
@@ -51,12 +51,12 @@ func (b *BaseApi) TestByInfo(c *gin.Context) {
// @Tags Host // @Tags Host
// @Summary Test host conn by host id // @Summary Test host conn by host id
// @Description 测试主机连接
// @Accept json // @Accept json
// @Param id path integer true "request" // @Param id path integer true "request"
// @Success 200 {boolean} connStatus // @Success 200 {boolean} connStatus
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /hosts/test/byid/:id [post]
// @Router /hosts/test/byid/{id} [post]
func (b *BaseApi) TestByID(c *gin.Context) { func (b *BaseApi) TestByID(c *gin.Context) {
id, err := helper.GetParamID(c) id, err := helper.GetParamID(c)
if err != nil { if err != nil {
@@ -70,11 +70,11 @@ func (b *BaseApi) TestByID(c *gin.Context) {
// @Tags Host // @Tags Host
// @Summary Load host tree // @Summary Load host tree
// @Description 加载主机树
// @Accept json // @Accept json
// @Param request body dto.SearchForTree true "request" // @Param request body dto.SearchForTree true "request"
// @Success 200 {array} dto.HostTree // @Success 200 {array} dto.HostTree
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/tree [post] // @Router /hosts/tree [post]
func (b *BaseApi) HostTree(c *gin.Context) { func (b *BaseApi) HostTree(c *gin.Context) {
var req dto.SearchForTree var req dto.SearchForTree
@@ -93,11 +93,11 @@ func (b *BaseApi) HostTree(c *gin.Context) {
// @Tags Host // @Tags Host
// @Summary Page host // @Summary Page host
// @Description 获取主机列表分页
// @Accept json // @Accept json
// @Param request body dto.SearchHostWithPage true "request" // @Param request body dto.SearchHostWithPage true "request"
// @Success 200 {object} dto.PageResult // @Success 200 {array} dto.HostTree
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/search [post] // @Router /hosts/search [post]
func (b *BaseApi) SearchHost(c *gin.Context) { func (b *BaseApi) SearchHost(c *gin.Context) {
var req dto.SearchHostWithPage var req dto.SearchHostWithPage
@@ -119,11 +119,11 @@ func (b *BaseApi) SearchHost(c *gin.Context) {
// @Tags Host // @Tags Host
// @Summary Delete host // @Summary Delete host
// @Description 删除主机
// @Accept json // @Accept json
// @Param request body dto.BatchDeleteReq true "request" // @Param request body dto.BatchDeleteReq true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/del [post] // @Router /hosts/del [post]
// @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"hosts","output_column":"addr","output_value":"addrs"}],"formatZH":"删除主机 [addrs]","formatEN":"delete host [addrs]"} // @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"hosts","output_column":"addr","output_value":"addrs"}],"formatZH":"删除主机 [addrs]","formatEN":"delete host [addrs]"}
func (b *BaseApi) DeleteHost(c *gin.Context) { func (b *BaseApi) DeleteHost(c *gin.Context) {
@@ -141,11 +141,11 @@ func (b *BaseApi) DeleteHost(c *gin.Context) {
// @Tags Host // @Tags Host
// @Summary Update host // @Summary Update host
// @Description 更新主机
// @Accept json // @Accept json
// @Param request body dto.HostOperate true "request" // @Param request body dto.HostOperate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/update [post] // @Router /hosts/update [post]
// @x-panel-log {"bodyKeys":["name","addr"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新主机信息 [name][addr]","formatEN":"update host [name][addr]"} // @x-panel-log {"bodyKeys":["name","addr"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新主机信息 [name][addr]","formatEN":"update host [name][addr]"}
func (b *BaseApi) UpdateHost(c *gin.Context) { func (b *BaseApi) UpdateHost(c *gin.Context) {
@@ -207,11 +207,11 @@ func (b *BaseApi) UpdateHost(c *gin.Context) {
// @Tags Host // @Tags Host
// @Summary Update host group // @Summary Update host group
// @Description 切换分组
// @Accept json // @Accept json
// @Param request body dto.ChangeHostGroup true "request" // @Param request body dto.ChangeHostGroup true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/update/group [post] // @Router /hosts/update/group [post]
// @x-panel-log {"bodyKeys":["id","group"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"hosts","output_column":"addr","output_value":"addr"}],"formatZH":"切换主机[addr]分组 => [group]","formatEN":"change host [addr] group => [group]"} // @x-panel-log {"bodyKeys":["id","group"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"hosts","output_column":"addr","output_value":"addr"}],"formatZH":"切换主机[addr]分组 => [group]","formatEN":"change host [addr] group => [group]"}
func (b *BaseApi) UpdateHostGroup(c *gin.Context) { func (b *BaseApi) UpdateHostGroup(c *gin.Context) {
+23 -23
View File
@@ -8,13 +8,13 @@ import (
) )
// @Tags Host tool // @Tags Host tool
// @Summary Get tool status // @Summary Get tool
// @Description 获取主机工具状态
// @Accept json // @Accept json
// @Param request body request.HostToolReq true "request" // @Param request body request.HostToolReq true "request"
// @Success 200 {object} response.HostToolRes // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /host/tool [post]
// @Router /hosts/tool [post]
func (b *BaseApi) GetToolStatus(c *gin.Context) { func (b *BaseApi) GetToolStatus(c *gin.Context) {
var req request.HostToolReq var req request.HostToolReq
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
@@ -31,12 +31,12 @@ func (b *BaseApi) GetToolStatus(c *gin.Context) {
// @Tags Host tool // @Tags Host tool
// @Summary Create Host tool Config // @Summary Create Host tool Config
// @Description 创建主机工具配置
// @Accept json // @Accept json
// @Param request body request.HostToolCreate true "request" // @Param request body request.HostToolCreate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /host/tool/create [post]
// @Router /hosts/tool/create [post]
// @x-panel-log {"bodyKeys":["type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建 [type] 配置","formatEN":"create [type] config"} // @x-panel-log {"bodyKeys":["type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建 [type] 配置","formatEN":"create [type] config"}
func (b *BaseApi) InitToolConfig(c *gin.Context) { func (b *BaseApi) InitToolConfig(c *gin.Context) {
var req request.HostToolCreate var req request.HostToolCreate
@@ -53,12 +53,12 @@ func (b *BaseApi) InitToolConfig(c *gin.Context) {
// @Tags Host tool // @Tags Host tool
// @Summary Operate tool // @Summary Operate tool
// @Description 操作主机工具
// @Accept json // @Accept json
// @Param request body request.HostToolReq true "request" // @Param request body request.HostToolReq true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /host/tool/operate [post]
// @Router /hosts/tool/operate [post]
// @x-panel-log {"bodyKeys":["operate","type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"[operate] [type] ","formatEN":"[operate] [type]"} // @x-panel-log {"bodyKeys":["operate","type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"[operate] [type] ","formatEN":"[operate] [type]"}
func (b *BaseApi) OperateTool(c *gin.Context) { func (b *BaseApi) OperateTool(c *gin.Context) {
var req request.HostToolReq var req request.HostToolReq
@@ -75,12 +75,12 @@ func (b *BaseApi) OperateTool(c *gin.Context) {
// @Tags Host tool // @Tags Host tool
// @Summary Get tool config // @Summary Get tool config
// @Description 操作主机工具配置文件
// @Accept json // @Accept json
// @Param request body request.HostToolConfig true "request" // @Param request body request.HostToolConfig true "request"
// @Success 200 {object} response.HostToolConfig // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /host/tool/config [post]
// @Router /hosts/tool/config [post]
// @x-panel-log {"bodyKeys":["operate"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"[operate] 主机工具配置文件 ","formatEN":"[operate] tool config"} // @x-panel-log {"bodyKeys":["operate"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"[operate] 主机工具配置文件 ","formatEN":"[operate] tool config"}
func (b *BaseApi) OperateToolConfig(c *gin.Context) { func (b *BaseApi) OperateToolConfig(c *gin.Context) {
var req request.HostToolConfig var req request.HostToolConfig
@@ -97,13 +97,13 @@ func (b *BaseApi) OperateToolConfig(c *gin.Context) {
} }
// @Tags Host tool // @Tags Host tool
// @Summary Get tool logs // @Summary Get tool
// @Description 获取主机工具日志
// @Accept json // @Accept json
// @Param request body request.HostToolLogReq true "request" // @Param request body request.HostToolLogReq true "request"
// @Success 200 {string} logContent // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /host/tool/log [post]
// @Router /hosts/tool/log [post]
func (b *BaseApi) GetToolLog(c *gin.Context) { func (b *BaseApi) GetToolLog(c *gin.Context) {
var req request.HostToolLogReq var req request.HostToolLogReq
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
@@ -120,12 +120,12 @@ func (b *BaseApi) GetToolLog(c *gin.Context) {
// @Tags Host tool // @Tags Host tool
// @Summary Create Supervisor process // @Summary Create Supervisor process
// @Description 操作守护进程
// @Accept json // @Accept json
// @Param request body request.SupervisorProcessConfig true "request" // @Param request body request.SupervisorProcessConfig true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /host/tool/supervisor/process [post]
// @Router /hosts/tool/supervisor/process [post]
// @x-panel-log {"bodyKeys":["operate"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"[operate] 守护进程 ","formatEN":"[operate] process"} // @x-panel-log {"bodyKeys":["operate"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"[operate] 守护进程 ","formatEN":"[operate] process"}
func (b *BaseApi) OperateProcess(c *gin.Context) { func (b *BaseApi) OperateProcess(c *gin.Context) {
var req request.SupervisorProcessConfig var req request.SupervisorProcessConfig
@@ -143,11 +143,11 @@ func (b *BaseApi) OperateProcess(c *gin.Context) {
// @Tags Host tool // @Tags Host tool
// @Summary Get Supervisor process config // @Summary Get Supervisor process config
// @Description 获取 Supervisor 进程配置
// @Accept json // @Accept json
// @Success 200 {object} response.SupervisorProcessConfig // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /host/tool/supervisor/process [get]
// @Router /hosts/tool/supervisor/process [get]
func (b *BaseApi) GetProcess(c *gin.Context) { func (b *BaseApi) GetProcess(c *gin.Context) {
configs, err := hostToolService.GetSupervisorProcessConfig() configs, err := hostToolService.GetSupervisorProcessConfig()
if err != nil { if err != nil {
@@ -159,12 +159,12 @@ func (b *BaseApi) GetProcess(c *gin.Context) {
// @Tags Host tool // @Tags Host tool
// @Summary Get Supervisor process config // @Summary Get Supervisor process config
// @Description 操作 Supervisor 进程文件
// @Accept json // @Accept json
// @Param request body request.SupervisorProcessFileReq true "request" // @Param request body request.SupervisorProcessFileReq true "request"
// @Success 200 {string} content // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /host/tool/supervisor/process/file [post]
// @Router /hosts/tool/supervisor/process/file [post]
// @x-panel-log {"bodyKeys":["operate"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"[operate] Supervisor 进程文件 ","formatEN":"[operate] Supervisor Process Config file"} // @x-panel-log {"bodyKeys":["operate"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"[operate] Supervisor 进程文件 ","formatEN":"[operate] Supervisor Process Config file"}
func (b *BaseApi) GetProcessFile(c *gin.Context) { func (b *BaseApi) GetProcessFile(c *gin.Context) {
var req request.SupervisorProcessFileReq var req request.SupervisorProcessFileReq
+12 -28
View File
@@ -9,12 +9,12 @@ import (
// @Tags Container Image // @Tags Container Image
// @Summary Page images // @Summary Page images
// @Description 获取镜像列表分页
// @Accept json // @Accept json
// @Param request body dto.SearchWithPage true "request" // @Param request body dto.SearchWithPage true "request"
// @Produce json // @Produce json
// @Success 200 {object} dto.PageResult // @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/image/search [post] // @Router /containers/image/search [post]
func (b *BaseApi) SearchImage(c *gin.Context) { func (b *BaseApi) SearchImage(c *gin.Context) {
var req dto.SearchWithPage var req dto.SearchWithPage
@@ -35,27 +35,11 @@ func (b *BaseApi) SearchImage(c *gin.Context) {
} }
// @Tags Container Image // @Tags Container Image
// @Summary List all images // @Summary List images
// @Produce json // @Description 获取镜像列表
// @Success 200 {array} dto.ImageInfo
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/image/all [get]
func (b *BaseApi) ListAllImage(c *gin.Context) {
list, err := imageService.ListAll()
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, list)
}
// @Tags Container Image
// @Summary load images options
// @Produce json // @Produce json
// @Success 200 {array} dto.Options // @Success 200 {array} dto.Options
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/image [get] // @Router /containers/image [get]
func (b *BaseApi) ListImage(c *gin.Context) { func (b *BaseApi) ListImage(c *gin.Context) {
list, err := imageService.List() list, err := imageService.List()
@@ -68,11 +52,11 @@ func (b *BaseApi) ListImage(c *gin.Context) {
// @Tags Container Image // @Tags Container Image
// @Summary Build image // @Summary Build image
// @Description 构建镜像
// @Accept json // @Accept json
// @Param request body dto.ImageBuild true "request" // @Param request body dto.ImageBuild true "request"
// @Success 200 {string} log // @Success 200 {string} log
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/image/build [post] // @Router /containers/image/build [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"构建镜像 [name]","formatEN":"build image [name]"} // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"构建镜像 [name]","formatEN":"build image [name]"}
func (b *BaseApi) ImageBuild(c *gin.Context) { func (b *BaseApi) ImageBuild(c *gin.Context) {
@@ -92,11 +76,11 @@ func (b *BaseApi) ImageBuild(c *gin.Context) {
// @Tags Container Image // @Tags Container Image
// @Summary Pull image // @Summary Pull image
// @Description 拉取镜像
// @Accept json // @Accept json
// @Param request body dto.ImagePull true "request" // @Param request body dto.ImagePull true "request"
// @Success 200 {string} logPath // @Success 200 {string} log
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/image/pull [post] // @Router /containers/image/pull [post]
// @x-panel-log {"bodyKeys":["repoID","imageName"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"repoID","isList":false,"db":"image_repos","output_column":"name","output_value":"reponame"}],"formatZH":"镜像拉取 [reponame][imageName]","formatEN":"image pull [reponame][imageName]"} // @x-panel-log {"bodyKeys":["repoID","imageName"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"repoID","isList":false,"db":"image_repos","output_column":"name","output_value":"reponame"}],"formatZH":"镜像拉取 [reponame][imageName]","formatEN":"image pull [reponame][imageName]"}
func (b *BaseApi) ImagePull(c *gin.Context) { func (b *BaseApi) ImagePull(c *gin.Context) {
@@ -116,11 +100,11 @@ func (b *BaseApi) ImagePull(c *gin.Context) {
// @Tags Container Image // @Tags Container Image
// @Summary Push image // @Summary Push image
// @Description 推送镜像
// @Accept json // @Accept json
// @Param request body dto.ImagePush true "request" // @Param request body dto.ImagePush true "request"
// @Success 200 {string} logPath // @Success 200 {string} log
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/image/push [post] // @Router /containers/image/push [post]
// @x-panel-log {"bodyKeys":["repoID","tagName","name"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"repoID","isList":false,"db":"image_repos","output_column":"name","output_value":"reponame"}],"formatZH":"[tagName] 推送到 [reponame][name]","formatEN":"push [tagName] to [reponame][name]"} // @x-panel-log {"bodyKeys":["repoID","tagName","name"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"repoID","isList":false,"db":"image_repos","output_column":"name","output_value":"reponame"}],"formatZH":"[tagName] 推送到 [reponame][name]","formatEN":"push [tagName] to [reponame][name]"}
func (b *BaseApi) ImagePush(c *gin.Context) { func (b *BaseApi) ImagePush(c *gin.Context) {
@@ -140,11 +124,11 @@ func (b *BaseApi) ImagePush(c *gin.Context) {
// @Tags Container Image // @Tags Container Image
// @Summary Delete image // @Summary Delete image
// @Description 删除镜像
// @Accept json // @Accept json
// @Param request body dto.BatchDelete true "request" // @Param request body dto.BatchDelete true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/image/remove [post] // @Router /containers/image/remove [post]
// @x-panel-log {"bodyKeys":["names"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"移除镜像 [names]","formatEN":"remove image [names]"} // @x-panel-log {"bodyKeys":["names"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"移除镜像 [names]","formatEN":"remove image [names]"}
func (b *BaseApi) ImageRemove(c *gin.Context) { func (b *BaseApi) ImageRemove(c *gin.Context) {
@@ -163,11 +147,11 @@ func (b *BaseApi) ImageRemove(c *gin.Context) {
// @Tags Container Image // @Tags Container Image
// @Summary Save image // @Summary Save image
// @Description 导出镜像
// @Accept json // @Accept json
// @Param request body dto.ImageSave true "request" // @Param request body dto.ImageSave true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/image/save [post] // @Router /containers/image/save [post]
// @x-panel-log {"bodyKeys":["tagName","path","name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"保留 [tagName] 为 [path]/[name]","formatEN":"save [tagName] as [path]/[name]"} // @x-panel-log {"bodyKeys":["tagName","path","name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"保留 [tagName] 为 [path]/[name]","formatEN":"save [tagName] as [path]/[name]"}
func (b *BaseApi) ImageSave(c *gin.Context) { func (b *BaseApi) ImageSave(c *gin.Context) {
@@ -186,11 +170,11 @@ func (b *BaseApi) ImageSave(c *gin.Context) {
// @Tags Container Image // @Tags Container Image
// @Summary Tag image // @Summary Tag image
// @Description Tag 镜像
// @Accept json // @Accept json
// @Param request body dto.ImageTag true "request" // @Param request body dto.ImageTag true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/image/tag [post] // @Router /containers/image/tag [post]
// @x-panel-log {"bodyKeys":["repoID","targetName"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"repoID","isList":false,"db":"image_repos","output_column":"name","output_value":"reponame"}],"formatZH":"tag 镜像 [reponame][targetName]","formatEN":"tag image [reponame][targetName]"} // @x-panel-log {"bodyKeys":["repoID","targetName"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"repoID","isList":false,"db":"image_repos","output_column":"name","output_value":"reponame"}],"formatZH":"tag 镜像 [reponame][targetName]","formatEN":"tag image [reponame][targetName]"}
func (b *BaseApi) ImageTag(c *gin.Context) { func (b *BaseApi) ImageTag(c *gin.Context) {
@@ -209,11 +193,11 @@ func (b *BaseApi) ImageTag(c *gin.Context) {
// @Tags Container Image // @Tags Container Image
// @Summary Load image // @Summary Load image
// @Description 导入镜像
// @Accept json // @Accept json
// @Param request body dto.ImageLoad true "request" // @Param request body dto.ImageLoad true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/image/load [post] // @Router /containers/image/load [post]
// @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"从 [path] 加载镜像","formatEN":"load image from [path]"} // @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"从 [path] 加载镜像","formatEN":"load image from [path]"}
func (b *BaseApi) ImageLoad(c *gin.Context) { func (b *BaseApi) ImageLoad(c *gin.Context) {
+11 -11
View File
@@ -9,12 +9,12 @@ import (
// @Tags Container Image-repo // @Tags Container Image-repo
// @Summary Page image repos // @Summary Page image repos
// @Description 获取镜像仓库列表分页
// @Accept json // @Accept json
// @Param request body dto.SearchWithPage true "request" // @Param request body dto.SearchWithPage true "request"
// @Produce json // @Produce json
// @Success 200 {object} dto.PageResult // @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/repo/search [post] // @Router /containers/repo/search [post]
func (b *BaseApi) SearchRepo(c *gin.Context) { func (b *BaseApi) SearchRepo(c *gin.Context) {
var req dto.SearchWithPage var req dto.SearchWithPage
@@ -36,10 +36,10 @@ func (b *BaseApi) SearchRepo(c *gin.Context) {
// @Tags Container Image-repo // @Tags Container Image-repo
// @Summary List image repos // @Summary List image repos
// @Description 获取镜像仓库列表
// @Produce json // @Produce json
// @Success 200 {array} dto.ImageRepoOption // @Success 200 {array} dto.ImageRepoOption
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/repo [get] // @Router /containers/repo [get]
func (b *BaseApi) ListRepo(c *gin.Context) { func (b *BaseApi) ListRepo(c *gin.Context) {
list, err := imageRepoService.List() list, err := imageRepoService.List()
@@ -53,12 +53,12 @@ func (b *BaseApi) ListRepo(c *gin.Context) {
// @Tags Container Image-repo // @Tags Container Image-repo
// @Summary Load repo status // @Summary Load repo status
// @Description 获取 docker 仓库状态
// @Accept json // @Accept json
// @Param request body dto.OperateByID true "request" // @Param request body dto.OperateByID true "request"
// @Produce json // @Produce json
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/repo/status [get] // @Router /containers/repo/status [get]
func (b *BaseApi) CheckRepoStatus(c *gin.Context) { func (b *BaseApi) CheckRepoStatus(c *gin.Context) {
var req dto.OperateByID var req dto.OperateByID
@@ -75,12 +75,12 @@ func (b *BaseApi) CheckRepoStatus(c *gin.Context) {
// @Tags Container Image-repo // @Tags Container Image-repo
// @Summary Create image repo // @Summary Create image repo
// @Description 创建镜像仓库
// @Accept json // @Accept json
// @Param request body dto.ImageRepoCreate true "request" // @Param request body dto.ImageRepoDelete true "request"
// @Produce json // @Produce json
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/repo [post] // @Router /containers/repo [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建镜像仓库 [name]","formatEN":"create image repo [name]"} // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建镜像仓库 [name]","formatEN":"create image repo [name]"}
func (b *BaseApi) CreateRepo(c *gin.Context) { func (b *BaseApi) CreateRepo(c *gin.Context) {
@@ -98,21 +98,21 @@ func (b *BaseApi) CreateRepo(c *gin.Context) {
// @Tags Container Image-repo // @Tags Container Image-repo
// @Summary Delete image repo // @Summary Delete image repo
// @Description 删除镜像仓库
// @Accept json // @Accept json
// @Param request body dto.OperateByID true "request" // @Param request body dto.ImageRepoDelete true "request"
// @Produce json // @Produce json
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/repo/del [post] // @Router /containers/repo/del [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"image_repos","output_column":"name","output_value":"name"}],"formatZH":"删除镜像仓库 [name]","formatEN":"delete image repo [name]"} // @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"image_repos","output_column":"name","output_value":"names"}],"formatZH":"删除镜像仓库 [names]","formatEN":"delete image repo [names]"}
func (b *BaseApi) DeleteRepo(c *gin.Context) { func (b *BaseApi) DeleteRepo(c *gin.Context) {
var req dto.OperateByID var req dto.ImageRepoDelete
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }
if err := imageRepoService.Delete(req); err != nil { if err := imageRepoService.BatchDelete(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
} }
@@ -121,12 +121,12 @@ func (b *BaseApi) DeleteRepo(c *gin.Context) {
// @Tags Container Image-repo // @Tags Container Image-repo
// @Summary Update image repo // @Summary Update image repo
// @Description 更新镜像仓库
// @Accept json // @Accept json
// @Param request body dto.ImageRepoUpdate true "request" // @Param request body dto.ImageRepoUpdate true "request"
// @Produce json // @Produce json
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /containers/repo/update [post] // @Router /containers/repo/update [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"image_repos","output_column":"name","output_value":"name"}],"formatZH":"更新镜像仓库 [name]","formatEN":"update image repo information [name]"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"image_repos","output_column":"name","output_value":"name"}],"formatZH":"更新镜像仓库 [name]","formatEN":"update image repo information [name]"}
func (b *BaseApi) UpdateRepo(c *gin.Context) { func (b *BaseApi) UpdateRepo(c *gin.Context) {
+9 -9
View File
@@ -9,11 +9,11 @@ import (
// @Tags Logs // @Tags Logs
// @Summary Page login logs // @Summary Page login logs
// @Description 获取系统登录日志列表分页
// @Accept json // @Accept json
// @Param request body dto.SearchLgLogWithPage true "request" // @Param request body dto.SearchLgLogWithPage true "request"
// @Success 200 {object} dto.PageResult // @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /logs/login [post] // @Router /logs/login [post]
func (b *BaseApi) GetLoginLogs(c *gin.Context) { func (b *BaseApi) GetLoginLogs(c *gin.Context) {
var req dto.SearchLgLogWithPage var req dto.SearchLgLogWithPage
@@ -21,7 +21,7 @@ func (b *BaseApi) GetLoginLogs(c *gin.Context) {
return return
} }
total, list, err := logService.PageLoginLog(c, req) total, list, err := logService.PageLoginLog(req)
if err != nil { if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
@@ -35,11 +35,11 @@ func (b *BaseApi) GetLoginLogs(c *gin.Context) {
// @Tags Logs // @Tags Logs
// @Summary Page operation logs // @Summary Page operation logs
// @Description 获取系统操作日志列表分页
// @Accept json // @Accept json
// @Param request body dto.SearchOpLogWithPage true "request" // @Param request body dto.SearchOpLogWithPage true "request"
// @Success 200 {object} dto.PageResult // @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /logs/operation [post] // @Router /logs/operation [post]
func (b *BaseApi) GetOperationLogs(c *gin.Context) { func (b *BaseApi) GetOperationLogs(c *gin.Context) {
var req dto.SearchOpLogWithPage var req dto.SearchOpLogWithPage
@@ -61,11 +61,11 @@ func (b *BaseApi) GetOperationLogs(c *gin.Context) {
// @Tags Logs // @Tags Logs
// @Summary Clean operation logs // @Summary Clean operation logs
// @Description 清空操作日志
// @Accept json // @Accept json
// @Param request body dto.CleanLog true "request" // @Param request body dto.CleanLog true "request"
// @Success 200 // @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /logs/clean [post] // @Router /logs/clean [post]
// @x-panel-log {"bodyKeys":["logType"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清空 [logType] 日志信息","formatEN":"Clean the [logType] log information"} // @x-panel-log {"bodyKeys":["logType"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清空 [logType] 日志信息","formatEN":"Clean the [logType] log information"}
func (b *BaseApi) CleanLogs(c *gin.Context) { func (b *BaseApi) CleanLogs(c *gin.Context) {
@@ -84,9 +84,9 @@ func (b *BaseApi) CleanLogs(c *gin.Context) {
// @Tags Logs // @Tags Logs
// @Summary Load system log files // @Summary Load system log files
// @Success 200 {array} string // @Description 获取系统日志文件列表
// @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /logs/system/files [get] // @Router /logs/system/files [get]
func (b *BaseApi) GetSystemFiles(c *gin.Context) { func (b *BaseApi) GetSystemFiles(c *gin.Context) {
data, err := logService.ListSystemLogFile() data, err := logService.ListSystemLogFile()
@@ -100,9 +100,9 @@ func (b *BaseApi) GetSystemFiles(c *gin.Context) {
// @Tags Logs // @Tags Logs
// @Summary Load system logs // @Summary Load system logs
// @Success 200 {string} data // @Description 获取系统日志
// @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /logs/system [post] // @Router /logs/system [post]
func (b *BaseApi) GetSystemLogs(c *gin.Context) { func (b *BaseApi) GetSystemLogs(c *gin.Context) {
var req dto.OperationWithName var req dto.OperationWithName
-167
View File
@@ -1,167 +0,0 @@
package v1
import (
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
"github.com/1Panel-dev/1Panel/backend/constant"
"github.com/gin-gonic/gin"
)
// @Tags McpServer
// @Summary List mcp servers
// @Accept json
// @Param request body request.McpServerSearch true "request"
// @Success 200 {object} response.McpServersRes
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /mcp/search [post]
func (b *BaseApi) PageMcpServers(c *gin.Context) {
var req request.McpServerSearch
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
list := mcpServerService.Page(req)
helper.SuccessWithData(c, list)
}
// @Tags McpServer
// @Summary Create mcp server
// @Accept json
// @Param request body request.McpServerCreate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /mcp/server [post]
func (b *BaseApi) CreateMcpServer(c *gin.Context) {
var req request.McpServerCreate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
err := mcpServerService.Create(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
// @Tags McpServer
// @Summary Update mcp server
// @Accept json
// @Param request body request.McpServerUpdate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /mcp/server/update [post]
func (b *BaseApi) UpdateMcpServer(c *gin.Context) {
var req request.McpServerUpdate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
err := mcpServerService.Update(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
// @Tags McpServer
// @Summary Delete mcp server
// @Accept json
// @Param request body request.McpServerDelete true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /mcp/server/del [post]
func (b *BaseApi) DeleteMcpServer(c *gin.Context) {
var req request.McpServerDelete
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
err := mcpServerService.Delete(req.ID)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
// @Tags McpServer
// @Summary Operate mcp server
// @Accept json
// @Param request body request.McpServerOperate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /mcp/server/op [post]
func (b *BaseApi) OperateMcpServer(c *gin.Context) {
var req request.McpServerOperate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
err := mcpServerService.Operate(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
// @Tags McpServer
// @Summary Bind Domain for mcp server
// @Accept json
// @Param request body request.McpBindDomain true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /mcp/domain/bind [post]
func (b *BaseApi) BindMcpDomain(c *gin.Context) {
var req request.McpBindDomain
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
err := mcpServerService.BindDomain(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
// @Tags McpServer
// @Summary Update bind Domain for mcp server
// @Accept json
// @Param request body request.McpBindDomainUpdate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /mcp/domain/update [post]
func (b *BaseApi) UpdateMcpBindDomain(c *gin.Context) {
var req request.McpBindDomainUpdate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
err := mcpServerService.UpdateBindDomain(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
// @Tags McpServer
// @Summary Get bin Domain for mcp server
// @Accept json
// @Success 200 {object} response.McpBindDomainRes
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /mcp/domain/get [get]
func (b *BaseApi) GetMcpBindDomain(c *gin.Context) {
res, err := mcpServerService.GetBindDomain()
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, res)
}
+4 -35
View File
@@ -15,27 +15,20 @@ import (
"github.com/shirou/gopsutil/v3/net" "github.com/shirou/gopsutil/v3/net"
) )
// @Tags Monitor
// @Summary Load monitor datas
// @Param request body dto.MonitorSearch true "request"
// @Success 200 {array} dto.MonitorData
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/monitor/search [post]
func (b *BaseApi) LoadMonitor(c *gin.Context) { func (b *BaseApi) LoadMonitor(c *gin.Context) {
var req dto.MonitorSearch var req dto.MonitorSearch
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }
loc, _ := time.LoadLocation(common.LoadTimeZoneByCmd()) loc, _ := time.LoadLocation(common.LoadTimeZone())
req.StartTime = req.StartTime.In(loc) req.StartTime = req.StartTime.In(loc)
req.EndTime = req.EndTime.In(loc) req.EndTime = req.EndTime.In(loc)
var backdatas []dto.MonitorData var backdatas []dto.MonitorData
if req.Param == "all" || req.Param == "cpu" || req.Param == "memory" || req.Param == "load" { if req.Param == "all" || req.Param == "cpu" || req.Param == "memory" || req.Param == "load" {
var bases []model.MonitorBase var bases []model.MonitorBase
if err := global.MonitorDB. if err := global.DB.
Where("created_at > ? AND created_at < ?", req.StartTime, req.EndTime). Where("created_at > ? AND created_at < ?", req.StartTime, req.EndTime).
Find(&bases).Error; err != nil { Find(&bases).Error; err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
@@ -52,7 +45,7 @@ func (b *BaseApi) LoadMonitor(c *gin.Context) {
} }
if req.Param == "all" || req.Param == "io" { if req.Param == "all" || req.Param == "io" {
var bases []model.MonitorIO var bases []model.MonitorIO
if err := global.MonitorDB. if err := global.DB.
Where("created_at > ? AND created_at < ?", req.StartTime, req.EndTime). Where("created_at > ? AND created_at < ?", req.StartTime, req.EndTime).
Find(&bases).Error; err != nil { Find(&bases).Error; err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
@@ -69,7 +62,7 @@ func (b *BaseApi) LoadMonitor(c *gin.Context) {
} }
if req.Param == "all" || req.Param == "network" { if req.Param == "all" || req.Param == "network" {
var bases []model.MonitorNetwork var bases []model.MonitorNetwork
if err := global.MonitorDB. if err := global.DB.
Where("name = ? AND created_at > ? AND created_at < ?", req.Info, req.StartTime, req.EndTime). Where("name = ? AND created_at > ? AND created_at < ?", req.Info, req.StartTime, req.EndTime).
Find(&bases).Error; err != nil { Find(&bases).Error; err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
@@ -87,30 +80,6 @@ func (b *BaseApi) LoadMonitor(c *gin.Context) {
helper.SuccessWithData(c, backdatas) helper.SuccessWithData(c, backdatas)
} }
// @Tags Monitor
// @Summary Clean monitor datas
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /hosts/monitor/clean [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清空监控数据","formatEN":"clean monitor datas"}
func (b *BaseApi) CleanMonitor(c *gin.Context) {
if err := global.MonitorDB.Exec("DELETE FROM monitor_bases").Error; err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
if err := global.MonitorDB.Exec("DELETE FROM monitor_ios").Error; err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
if err := global.MonitorDB.Exec("DELETE FROM monitor_networks").Error; err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
func (b *BaseApi) GetNetworkOptions(c *gin.Context) { func (b *BaseApi) GetNetworkOptions(c *gin.Context) {
netStat, _ := net.IOCounters(true) netStat, _ := net.IOCounters(true)
var options []string var options []string
+11 -26
View File
@@ -9,10 +9,10 @@ import (
// @Tags OpenResty // @Tags OpenResty
// @Summary Load OpenResty conf // @Summary Load OpenResty conf
// @Success 200 {object} response.NginxFile // @Description 获取 OpenResty 配置信息
// @Success 200 {object} response.FileInfo
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /openResty [get]
// @Router /openresty [get]
func (b *BaseApi) GetNginx(c *gin.Context) { func (b *BaseApi) GetNginx(c *gin.Context) {
fileInfo, err := nginxService.GetNginxConfig() fileInfo, err := nginxService.GetNginxConfig()
if err != nil { if err != nil {
@@ -24,12 +24,12 @@ func (b *BaseApi) GetNginx(c *gin.Context) {
// @Tags OpenResty // @Tags OpenResty
// @Summary Load partial OpenResty conf // @Summary Load partial OpenResty conf
// @Description 获取部分 OpenResty 配置信息
// @Accept json // @Accept json
// @Param request body request.NginxScopeReq true "request" // @Param request body request.NginxScopeReq true "request"
// @Success 200 {array} response.NginxParam // @Success 200 {array} response.NginxParam
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /openResty/scope [post]
// @Router /openresty/scope [post]
func (b *BaseApi) GetNginxConfigByScope(c *gin.Context) { func (b *BaseApi) GetNginxConfigByScope(c *gin.Context) {
var req request.NginxScopeReq var req request.NginxScopeReq
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
@@ -46,12 +46,12 @@ func (b *BaseApi) GetNginxConfigByScope(c *gin.Context) {
// @Tags OpenResty // @Tags OpenResty
// @Summary Update OpenResty conf // @Summary Update OpenResty conf
// @Description 更新 OpenResty 配置信息
// @Accept json // @Accept json
// @Param request body request.NginxConfigUpdate true "request" // @Param request body request.NginxConfigUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /openResty/update [post]
// @Router /openresty/update [post]
// @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新 nginx 配置 [domain]","formatEN":"Update nginx conf [domain]"} // @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新 nginx 配置 [domain]","formatEN":"Update nginx conf [domain]"}
func (b *BaseApi) UpdateNginxConfigByScope(c *gin.Context) { func (b *BaseApi) UpdateNginxConfigByScope(c *gin.Context) {
var req request.NginxConfigUpdate var req request.NginxConfigUpdate
@@ -67,10 +67,10 @@ func (b *BaseApi) UpdateNginxConfigByScope(c *gin.Context) {
// @Tags OpenResty // @Tags OpenResty
// @Summary Load OpenResty status info // @Summary Load OpenResty status info
// @Description 获取 OpenResty 状态信息
// @Success 200 {object} response.NginxStatus // @Success 200 {object} response.NginxStatus
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /openResty/status [get]
// @Router /openresty/status [get]
func (b *BaseApi) GetNginxStatus(c *gin.Context) { func (b *BaseApi) GetNginxStatus(c *gin.Context) {
res, err := nginxService.GetStatus() res, err := nginxService.GetStatus()
if err != nil { if err != nil {
@@ -82,12 +82,12 @@ func (b *BaseApi) GetNginxStatus(c *gin.Context) {
// @Tags OpenResty // @Tags OpenResty
// @Summary Update OpenResty conf by upload file // @Summary Update OpenResty conf by upload file
// @Description 上传更新 OpenResty 配置文件
// @Accept json // @Accept json
// @Param request body request.NginxConfigFileUpdate true "request" // @Param request body request.NginxConfigFileUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /openResty/file [post]
// @Router /openresty/file [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 nginx 配置","formatEN":"Update nginx conf"} // @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 nginx 配置","formatEN":"Update nginx conf"}
func (b *BaseApi) UpdateNginxFile(c *gin.Context) { func (b *BaseApi) UpdateNginxFile(c *gin.Context) {
var req request.NginxConfigFileUpdate var req request.NginxConfigFileUpdate
@@ -101,18 +101,3 @@ func (b *BaseApi) UpdateNginxFile(c *gin.Context) {
} }
helper.SuccessWithData(c, nil) helper.SuccessWithData(c, nil)
} }
// @Tags OpenResty
// @Summary Clear OpenResty proxy cache
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /openresty/clear [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清理 Openresty 代理缓存","formatEN":"Clear nginx proxy cache"}
func (b *BaseApi) ClearNginxProxyCache(c *gin.Context) {
if err := nginxService.ClearProxyCache(); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
-106
View File
@@ -1,106 +0,0 @@
package v1
import (
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
"github.com/1Panel-dev/1Panel/backend/constant"
"github.com/gin-gonic/gin"
)
// @Tags PHP Extensions
// @Summary Page Extensions
// @Accept json
// @Param request body request.PHPExtensionsSearch true "request"
// @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /runtimes/php/extensions/search [post]
func (b *BaseApi) PagePHPExtensions(c *gin.Context) {
var req request.PHPExtensionsSearch
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if req.All {
list, err := phpExtensionsService.List()
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, dto.PageResult{
Total: int64(len(list)),
Items: list,
})
} else {
total, list, err := phpExtensionsService.Page(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, dto.PageResult{
Total: total,
Items: list,
})
}
}
// @Tags PHP Extensions
// @Summary Create Extensions
// @Accept json
// @Param request body request.PHPExtensionsCreate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /runtimes/php/extensions [post]
func (b *BaseApi) CreatePHPExtensions(c *gin.Context) {
var req request.PHPExtensionsCreate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := phpExtensionsService.Create(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
// @Tags PHP Extensions
// @Summary Update Extensions
// @Accept json
// @Param request body request.PHPExtensionsUpdate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /runtimes/php/extensions/update [post]
func (b *BaseApi) UpdatePHPExtensions(c *gin.Context) {
var req request.PHPExtensionsUpdate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := phpExtensionsService.Update(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
// @Tags PHP Extensions
// @Summary Delete Extensions
// @Accept json
// @Param request body request.PHPExtensionsDelete true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /runtimes/php/extensions/del [post]
func (b *BaseApi) DeletePHPExtensions(c *gin.Context) {
var req request.PHPExtensionsDelete
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := phpExtensionsService.Delete(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
+1 -1
View File
@@ -20,10 +20,10 @@ func (b *BaseApi) ProcessWs(c *gin.Context) {
// @Tags Process // @Tags Process
// @Summary Stop Process // @Summary Stop Process
// @Description 停止进程
// @Param request body request.ProcessReq true "request" // @Param request body request.ProcessReq true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /process/stop [post] // @Router /process/stop [post]
// @x-panel-log {"bodyKeys":["PID"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"结束进程 [PID]","formatEN":"结束进程 [PID]"} // @x-panel-log {"bodyKeys":["PID"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"结束进程 [PID]","formatEN":"结束进程 [PID]"}
func (b *BaseApi) StopProcess(c *gin.Context) { func (b *BaseApi) StopProcess(c *gin.Context) {
+7 -23
View File
@@ -9,12 +9,12 @@ import (
) )
// @Tags File // @Tags File
// @Summary List Recycle Bin files // @Summary List RecycleBin files
// @Description 获取回收站文件列表
// @Accept json // @Accept json
// @Param request body dto.PageInfo true "request" // @Param request body dto.PageInfo true "request"
// @Success 200 {object} dto.PageResult // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/recycle/search [post] // @Router /files/recycle/search [post]
func (b *BaseApi) SearchRecycleBinFile(c *gin.Context) { func (b *BaseApi) SearchRecycleBinFile(c *gin.Context) {
var req dto.PageInfo var req dto.PageInfo
@@ -33,12 +33,12 @@ func (b *BaseApi) SearchRecycleBinFile(c *gin.Context) {
} }
// @Tags File // @Tags File
// @Summary Reduce Recycle Bin files // @Summary Reduce RecycleBin files
// @Description 还原回收站文件
// @Accept json // @Accept json
// @Param request body request.RecycleBinReduce true "request" // @Param request body request.RecycleBinReduce true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/recycle/reduce [post] // @Router /files/recycle/reduce [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"还原回收站文件 [name]","formatEN":"Reduce RecycleBin file [name]"} // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"还原回收站文件 [name]","formatEN":"Reduce RecycleBin file [name]"}
func (b *BaseApi) ReduceRecycleBinFile(c *gin.Context) { func (b *BaseApi) ReduceRecycleBinFile(c *gin.Context) {
@@ -54,11 +54,11 @@ func (b *BaseApi) ReduceRecycleBinFile(c *gin.Context) {
} }
// @Tags File // @Tags File
// @Summary Clear Recycle Bin files // @Summary Clear RecycleBin files
// @Description 清空回收站文件
// @Accept json // @Accept json
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/recycle/clear [post] // @Router /files/recycle/clear [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清空回收站","formatEN":"清空回收站"} // @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清空回收站","formatEN":"清空回收站"}
func (b *BaseApi) ClearRecycleBinFile(c *gin.Context) { func (b *BaseApi) ClearRecycleBinFile(c *gin.Context) {
@@ -68,19 +68,3 @@ func (b *BaseApi) ClearRecycleBinFile(c *gin.Context) {
} }
helper.SuccessWithOutData(c) helper.SuccessWithOutData(c)
} }
// @Tags File
// @Summary Get Recycle Bin status
// @Accept json
// @Success 200 {string} content
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /files/recycle/status [get]
func (b *BaseApi) GetRecycleStatus(c *gin.Context) {
settingInfo, err := settingService.GetSettingInfo()
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, settingInfo.FileRecycleBin)
}
+18 -49
View File
@@ -10,11 +10,11 @@ import (
// @Tags Runtime // @Tags Runtime
// @Summary List runtimes // @Summary List runtimes
// @Description 获取运行环境列表
// @Accept json // @Accept json
// @Param request body request.RuntimeSearch true "request" // @Param request body request.RuntimeSearch true "request"
// @Success 200 {object} dto.PageResult // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /runtimes/search [post] // @Router /runtimes/search [post]
func (b *BaseApi) SearchRuntimes(c *gin.Context) { func (b *BaseApi) SearchRuntimes(c *gin.Context) {
var req request.RuntimeSearch var req request.RuntimeSearch
@@ -34,11 +34,11 @@ func (b *BaseApi) SearchRuntimes(c *gin.Context) {
// @Tags Runtime // @Tags Runtime
// @Summary Create runtime // @Summary Create runtime
// @Description 创建运行环境
// @Accept json // @Accept json
// @Param request body request.RuntimeCreate true "request" // @Param request body request.RuntimeCreate true "request"
// @Success 200 {object} model.Runtime // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /runtimes [post] // @Router /runtimes [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建运行环境 [name]","formatEN":"Create runtime [name]"} // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建运行环境 [name]","formatEN":"Create runtime [name]"}
func (b *BaseApi) CreateRuntime(c *gin.Context) { func (b *BaseApi) CreateRuntime(c *gin.Context) {
@@ -46,23 +46,22 @@ func (b *BaseApi) CreateRuntime(c *gin.Context) {
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }
ssl, err := runtimeService.Create(req) if err := runtimeService.Create(req); err != nil {
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
} }
helper.SuccessWithData(c, ssl) helper.SuccessWithOutData(c)
} }
// @Tags Website // @Tags Website
// @Summary Delete runtime // @Summary Delete runtime
// @Description 删除运行环境
// @Accept json // @Accept json
// @Param request body request.RuntimeDelete true "request" // @Param request body request.RuntimeDelete true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /runtimes/del [post] // @Router /runtimes/del [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"删除运行环境 [name]","formatEN":"Delete runtime [name]"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"删除网站 [name]","formatEN":"Delete website [name]"}
func (b *BaseApi) DeleteRuntime(c *gin.Context) { func (b *BaseApi) DeleteRuntime(c *gin.Context) {
var req request.RuntimeDelete var req request.RuntimeDelete
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
@@ -76,27 +75,13 @@ func (b *BaseApi) DeleteRuntime(c *gin.Context) {
helper.SuccessWithOutData(c) helper.SuccessWithOutData(c)
} }
func (b *BaseApi) DeleteRuntimeCheck(c *gin.Context) {
runTimeId, err := helper.GetIntParamByKey(c, "runTimeId")
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
return
}
checkData, err := runtimeService.DeleteCheck(runTimeId)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, checkData)
}
// @Tags Runtime // @Tags Runtime
// @Summary Update runtime // @Summary Update runtime
// @Description 更新运行环境
// @Accept json // @Accept json
// @Param request body request.RuntimeUpdate true "request" // @Param request body request.RuntimeUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /runtimes/update [post] // @Router /runtimes/update [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新运行环境 [name]","formatEN":"Update runtime [name]"} // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新运行环境 [name]","formatEN":"Update runtime [name]"}
func (b *BaseApi) UpdateRuntime(c *gin.Context) { func (b *BaseApi) UpdateRuntime(c *gin.Context) {
@@ -113,12 +98,12 @@ func (b *BaseApi) UpdateRuntime(c *gin.Context) {
// @Tags Runtime // @Tags Runtime
// @Summary Get runtime // @Summary Get runtime
// @Description 获取运行环境
// @Accept json // @Accept json
// @Param id path string true "request" // @Param id path string true "request"
// @Success 200 {object} response.RuntimeDTO // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /runtimes/:id [get]
// @Router /runtimes/{id} [get]
func (b *BaseApi) GetRuntime(c *gin.Context) { func (b *BaseApi) GetRuntime(c *gin.Context) {
id, err := helper.GetIntParamByKey(c, "id") id, err := helper.GetIntParamByKey(c, "id")
if err != nil { if err != nil {
@@ -135,11 +120,11 @@ func (b *BaseApi) GetRuntime(c *gin.Context) {
// @Tags Runtime // @Tags Runtime
// @Summary Get Node package scripts // @Summary Get Node package scripts
// @Description 获取 Node 项目的 scripts
// @Accept json // @Accept json
// @Param request body request.NodePackageReq true "request" // @Param request body request.NodePackageReq true "request"
// @Success 200 {array} response.PackageScripts // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /runtimes/node/package [post] // @Router /runtimes/node/package [post]
func (b *BaseApi) GetNodePackageRunScript(c *gin.Context) { func (b *BaseApi) GetNodePackageRunScript(c *gin.Context) {
var req request.NodePackageReq var req request.NodePackageReq
@@ -156,11 +141,11 @@ func (b *BaseApi) GetNodePackageRunScript(c *gin.Context) {
// @Tags Runtime // @Tags Runtime
// @Summary Operate runtime // @Summary Operate runtime
// @Description 操作运行环境
// @Accept json // @Accept json
// @Param request body request.RuntimeOperate true "request" // @Param request body request.RuntimeOperate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /runtimes/operate [post] // @Router /runtimes/operate [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"操作运行环境 [name]","formatEN":"Operate runtime [name]"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"操作运行环境 [name]","formatEN":"Operate runtime [name]"}
func (b *BaseApi) OperateRuntime(c *gin.Context) { func (b *BaseApi) OperateRuntime(c *gin.Context) {
@@ -178,11 +163,11 @@ func (b *BaseApi) OperateRuntime(c *gin.Context) {
// @Tags Runtime // @Tags Runtime
// @Summary Get Node modules // @Summary Get Node modules
// @Description 获取 Node 项目的 modules
// @Accept json // @Accept json
// @Param request body request.NodeModuleReq true "request" // @Param request body request.NodeModuleReq true "request"
// @Success 200 {array} response.NodeModule // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /runtimes/node/modules [post] // @Router /runtimes/node/modules [post]
func (b *BaseApi) GetNodeModules(c *gin.Context) { func (b *BaseApi) GetNodeModules(c *gin.Context) {
var req request.NodeModuleReq var req request.NodeModuleReq
@@ -199,11 +184,11 @@ func (b *BaseApi) GetNodeModules(c *gin.Context) {
// @Tags Runtime // @Tags Runtime
// @Summary Operate Node modules // @Summary Operate Node modules
// @Description 操作 Node 项目 modules
// @Accept json // @Accept json
// @Param request body request.NodeModuleReq true "request" // @Param request body request.NodeModuleReq true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /runtimes/node/modules/operate [post] // @Router /runtimes/node/modules/operate [post]
func (b *BaseApi) OperateNodeModules(c *gin.Context) { func (b *BaseApi) OperateNodeModules(c *gin.Context) {
var req request.NodeModuleOperateReq var req request.NodeModuleOperateReq
@@ -217,19 +202,3 @@ func (b *BaseApi) OperateNodeModules(c *gin.Context) {
} }
helper.SuccessWithOutData(c) helper.SuccessWithOutData(c)
} }
// @Tags Runtime
// @Summary Sync runtime status
// @Accept json
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /runtimes/sync [post]
func (b *BaseApi) SyncStatus(c *gin.Context) {
err := runtimeService.SyncRuntimeStatus()
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
+109 -140
View File
@@ -1,12 +1,9 @@
package v1 package v1
import ( import (
"encoding/base64"
"errors" "errors"
"fmt"
"os" "os"
"path" "path"
"regexp"
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
@@ -18,9 +15,9 @@ import (
// @Tags System Setting // @Tags System Setting
// @Summary Load system setting info // @Summary Load system setting info
// @Description 加载系统配置信息
// @Success 200 {object} dto.SettingInfo // @Success 200 {object} dto.SettingInfo
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/search [post] // @Router /settings/search [post]
func (b *BaseApi) GetSettingInfo(c *gin.Context) { func (b *BaseApi) GetSettingInfo(c *gin.Context) {
setting, err := settingService.GetSettingInfo() setting, err := settingService.GetSettingInfo()
@@ -33,9 +30,9 @@ func (b *BaseApi) GetSettingInfo(c *gin.Context) {
// @Tags System Setting // @Tags System Setting
// @Summary Load system available status // @Summary Load system available status
// @Description 获取系统可用状态
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/search/available [get] // @Router /settings/search/available [get]
func (b *BaseApi) GetSystemAvailable(c *gin.Context) { func (b *BaseApi) GetSystemAvailable(c *gin.Context) {
helper.SuccessWithData(c, nil) helper.SuccessWithData(c, nil)
@@ -43,11 +40,11 @@ func (b *BaseApi) GetSystemAvailable(c *gin.Context) {
// @Tags System Setting // @Tags System Setting
// @Summary Update system setting // @Summary Update system setting
// @Description 更新系统配置
// @Accept json // @Accept json
// @Param request body dto.SettingUpdate true "request" // @Param request body dto.SettingUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/update [post] // @Router /settings/update [post]
// @x-panel-log {"bodyKeys":["key","value"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改系统配置 [key] => [value]","formatEN":"update system setting [key] => [value]"} // @x-panel-log {"bodyKeys":["key","value"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改系统配置 [key] => [value]","formatEN":"update system setting [key] => [value]"}
func (b *BaseApi) UpdateSetting(c *gin.Context) { func (b *BaseApi) UpdateSetting(c *gin.Context) {
@@ -55,69 +52,6 @@ func (b *BaseApi) UpdateSetting(c *gin.Context) {
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }
if req.Key == "SecurityEntrance" {
if !checkEntrancePattern(req.Value) {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, fmt.Errorf("the format of the security entrance %s is incorrect.", req.Value))
return
}
}
if err := settingService.Update(req.Key, req.Value); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
if req.Key == "SecurityEntrance" {
entranceValue := base64.StdEncoding.EncodeToString([]byte(req.Value))
c.SetCookie("SecurityEntrance", entranceValue, 0, "", "", false, true)
}
helper.SuccessWithData(c, nil)
}
// @Tags System Setting
// @Summary Update proxy setting
// @Accept json
// @Param request body dto.ProxyUpdate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/proxy/update [post]
// @x-panel-log {"bodyKeys":["proxyUrl","proxyPort"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"服务器代理配置 [proxyPort]:[proxyPort]","formatEN":"set proxy [proxyPort]:[proxyPort]."}
func (b *BaseApi) UpdateProxy(c *gin.Context) {
var req dto.ProxyUpdate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if len(req.ProxyPasswd) != 0 && len(req.ProxyType) != 0 {
pass, err := base64.StdEncoding.DecodeString(req.ProxyPasswd)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
return
}
req.ProxyPasswd = string(pass)
}
if err := settingService.UpdateProxy(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags System Setting
// @Summary Update system setting
// @Accept json
// @Param request body dto.SettingUpdate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/menu/update [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"隐藏高级功能菜单","formatEN":"Hide advanced feature menu."}
func (b *BaseApi) UpdateMenu(c *gin.Context) {
var req dto.SettingUpdate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := settingService.Update(req.Key, req.Value); err != nil { if err := settingService.Update(req.Key, req.Value); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
@@ -128,11 +62,11 @@ func (b *BaseApi) UpdateMenu(c *gin.Context) {
// @Tags System Setting // @Tags System Setting
// @Summary Update system password // @Summary Update system password
// @Description 更新系统登录密码
// @Accept json // @Accept json
// @Param request body dto.PasswordUpdate true "request" // @Param request body dto.PasswordUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/password/update [post] // @Router /settings/password/update [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改系统密码","formatEN":"update system password"} // @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改系统密码","formatEN":"update system password"}
func (b *BaseApi) UpdatePassword(c *gin.Context) { func (b *BaseApi) UpdatePassword(c *gin.Context) {
@@ -150,11 +84,11 @@ func (b *BaseApi) UpdatePassword(c *gin.Context) {
// @Tags System Setting // @Tags System Setting
// @Summary Update system ssl // @Summary Update system ssl
// @Description 修改系统 ssl 登录
// @Accept json // @Accept json
// @Param request body dto.SSLUpdate true "request" // @Param request body dto.SSLUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/ssl/update [post] // @Router /settings/ssl/update [post]
// @x-panel-log {"bodyKeys":["ssl"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改系统 ssl => [ssl]","formatEN":"update system ssl => [ssl]"} // @x-panel-log {"bodyKeys":["ssl"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改系统 ssl => [ssl]","formatEN":"update system ssl => [ssl]"}
func (b *BaseApi) UpdateSSL(c *gin.Context) { func (b *BaseApi) UpdateSSL(c *gin.Context) {
@@ -172,9 +106,9 @@ func (b *BaseApi) UpdateSSL(c *gin.Context) {
// @Tags System Setting // @Tags System Setting
// @Summary Load system cert info // @Summary Load system cert info
// @Success 200 {object} dto.SSLInfo // @Description 获取证书信息
// @Success 200 {object} dto.SettingInfo
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/ssl/info [get] // @Router /settings/ssl/info [get]
func (b *BaseApi) LoadFromCert(c *gin.Context) { func (b *BaseApi) LoadFromCert(c *gin.Context) {
info, err := settingService.LoadFromCert() info, err := settingService.LoadFromCert()
@@ -187,9 +121,9 @@ func (b *BaseApi) LoadFromCert(c *gin.Context) {
// @Tags System Setting // @Tags System Setting
// @Summary Download system cert // @Summary Download system cert
// @Description 下载证书
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/ssl/download [post] // @Router /settings/ssl/download [post]
func (b *BaseApi) DownloadSSL(c *gin.Context) { func (b *BaseApi) DownloadSSL(c *gin.Context) {
pathItem := path.Join(global.CONF.System.BaseDir, "1panel/secret/server.crt") pathItem := path.Join(global.CONF.System.BaseDir, "1panel/secret/server.crt")
@@ -203,10 +137,10 @@ func (b *BaseApi) DownloadSSL(c *gin.Context) {
// @Tags System Setting // @Tags System Setting
// @Summary Load system address // @Summary Load system address
// @Description 获取系统地址信息
// @Accept json // @Accept json
// @Success 200 {array} string // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/interface [get] // @Router /settings/interface [get]
func (b *BaseApi) LoadInterfaceAddr(c *gin.Context) { func (b *BaseApi) LoadInterfaceAddr(c *gin.Context) {
data, err := settingService.LoadInterfaceAddr() data, err := settingService.LoadInterfaceAddr()
@@ -219,11 +153,11 @@ func (b *BaseApi) LoadInterfaceAddr(c *gin.Context) {
// @Tags System Setting // @Tags System Setting
// @Summary Update system bind info // @Summary Update system bind info
// @Description 更新系统监听信息
// @Accept json // @Accept json
// @Param request body dto.BindInfo true "request" // @Param request body dto.BindInfo true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/bind/update [post] // @Router /settings/bind/update [post]
// @x-panel-log {"bodyKeys":["ipv6", "bindAddress"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改系统监听信息 => ipv6: [ipv6], 监听 IP: [bindAddress]","formatEN":"update system bind info => ipv6: [ipv6], 监听 IP: [bindAddress]"} // @x-panel-log {"bodyKeys":["ipv6", "bindAddress"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改系统监听信息 => ipv6: [ipv6], 监听 IP: [bindAddress]","formatEN":"update system bind info => ipv6: [ipv6], 监听 IP: [bindAddress]"}
func (b *BaseApi) UpdateBindInfo(c *gin.Context) { func (b *BaseApi) UpdateBindInfo(c *gin.Context) {
@@ -241,11 +175,11 @@ func (b *BaseApi) UpdateBindInfo(c *gin.Context) {
// @Tags System Setting // @Tags System Setting
// @Summary Update system port // @Summary Update system port
// @Description 更新系统端口
// @Accept json // @Accept json
// @Param request body dto.PortUpdate true "request" // @Param request body dto.PortUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/port/update [post] // @Router /settings/port/update [post]
// @x-panel-log {"bodyKeys":["serverPort"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改系统端口 => [serverPort]","formatEN":"update system port => [serverPort]"} // @x-panel-log {"bodyKeys":["serverPort"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改系统端口 => [serverPort]","formatEN":"update system port => [serverPort]"}
func (b *BaseApi) UpdatePort(c *gin.Context) { func (b *BaseApi) UpdatePort(c *gin.Context) {
@@ -263,11 +197,11 @@ func (b *BaseApi) UpdatePort(c *gin.Context) {
// @Tags System Setting // @Tags System Setting
// @Summary Reset system password expired // @Summary Reset system password expired
// @Description 重置过期系统登录密码
// @Accept json // @Accept json
// @Param request body dto.PasswordUpdate true "request" // @Param request body dto.PasswordUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/expired/handle [post] // @Router /settings/expired/handle [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"重置过期密码","formatEN":"reset an expired Password"} // @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"重置过期密码","formatEN":"reset an expired Password"}
func (b *BaseApi) HandlePasswordExpired(c *gin.Context) { func (b *BaseApi) HandlePasswordExpired(c *gin.Context) {
@@ -284,22 +218,114 @@ func (b *BaseApi) HandlePasswordExpired(c *gin.Context) {
} }
// @Tags System Setting // @Tags System Setting
// @Summary Load local base dir // @Summary Load time zone options
// @Description 加载系统可用时区
// @Success 200
// @Security ApiKeyAuth
// @Router /settings/time/option [get]
func (b *BaseApi) LoadTimeZone(c *gin.Context) {
zones, err := settingService.LoadTimeZone()
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, zones)
}
// @Tags System Setting
// @Summary Sync system time
// @Description 系统时间同步
// @Accept json
// @Param request body dto.SyncTime true "request"
// @Success 200 {string} ntime
// @Security ApiKeyAuth
// @Router /settings/time/sync [post]
// @x-panel-log {"bodyKeys":["ntpSite"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"系统时间同步[ntpSite]","formatEN":"sync system time [ntpSite]"}
func (b *BaseApi) SyncTime(c *gin.Context) {
var req dto.SyncTime
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := settingService.SyncTime(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags System Setting
// @Summary Load local backup dir
// @Description 获取安装根目录
// @Success 200 {string} path // @Success 200 {string} path
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/basedir [get] // @Router /settings/basedir [get]
func (b *BaseApi) LoadBaseDir(c *gin.Context) { func (b *BaseApi) LoadBaseDir(c *gin.Context) {
helper.SuccessWithData(c, global.CONF.System.DataDir) helper.SuccessWithData(c, global.CONF.System.DataDir)
} }
// @Tags System Setting
// @Summary Clean monitor datas
// @Description 清空监控数据
// @Success 200
// @Security ApiKeyAuth
// @Router /settings/monitor/clean [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清空监控数据","formatEN":"clean monitor datas"}
func (b *BaseApi) CleanMonitor(c *gin.Context) {
if err := global.DB.Exec("DELETE FROM monitor_bases").Error; err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
if err := global.DB.Exec("DELETE FROM monitor_ios").Error; err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
if err := global.DB.Exec("DELETE FROM monitor_networks").Error; err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags System Setting
// @Summary Scan system
// @Description 扫描系统垃圾文件
// @Success 200
// @Security ApiKeyAuth
// @Router /settings/scan [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"扫描系统垃圾文件","formatEN":"scan System Junk Files"}
func (b *BaseApi) ScanSystem(c *gin.Context) {
helper.SuccessWithData(c, settingService.SystemScan())
}
// @Tags System Setting
// @Summary System clean
// @Description 清理系统垃圾文件
// @Accept json
// @Param request body []dto.Clean true "request"
// @Success 200
// @Security ApiKeyAuth
// @Router /settings/clean [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清理系统垃圾文件","formatEN":"Clean system junk files"}
func (b *BaseApi) SystemClean(c *gin.Context) {
var req []dto.Clean
if err := helper.CheckBind(&req, c); err != nil {
return
}
settingService.SystemClean(req)
helper.SuccessWithData(c, nil)
}
// @Tags System Setting // @Tags System Setting
// @Summary Load mfa info // @Summary Load mfa info
// @Description 获取 mfa 信息
// @Accept json // @Accept json
// @Param request body dto.MfaCredential true "request" // @Param request body dto.MfaCredential true "request"
// @Success 200 {object} mfa.Otp // @Success 200 {object} mfa.Otp
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/mfa [post] // @Router /settings/mfa [post]
func (b *BaseApi) LoadMFA(c *gin.Context) { func (b *BaseApi) LoadMFA(c *gin.Context) {
var req dto.MfaRequest var req dto.MfaRequest
@@ -318,11 +344,11 @@ func (b *BaseApi) LoadMFA(c *gin.Context) {
// @Tags System Setting // @Tags System Setting
// @Summary Bind mfa // @Summary Bind mfa
// @Description Mfa 绑定
// @Accept json // @Accept json
// @Param request body dto.MfaCredential true "request" // @Param request body dto.MfaCredential true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/mfa/bind [post] // @Router /settings/mfa/bind [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"mfa 绑定","formatEN":"bind mfa"} // @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"mfa 绑定","formatEN":"bind mfa"}
func (b *BaseApi) MFABind(c *gin.Context) { func (b *BaseApi) MFABind(c *gin.Context) {
@@ -354,60 +380,3 @@ func (b *BaseApi) MFABind(c *gin.Context) {
helper.SuccessWithData(c, nil) helper.SuccessWithData(c, nil)
} }
// @Tags System Setting
// @Summary Generate api key
// @Accept json
// @Success 200 {string} apiKey
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/api/config/generate/key [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"生成 API 接口密钥","formatEN":"generate api key"}
func (b *BaseApi) GenerateApiKey(c *gin.Context) {
panelToken := c.GetHeader("1Panel-Token")
if panelToken != "" {
helper.ErrorWithDetail(c, constant.CodeErrUnauthorized, constant.ErrApiConfigDisable, nil)
return
}
apiKey, err := settingService.GenerateApiKey()
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, apiKey)
}
// @Tags System Setting
// @Summary Update api config
// @Accept json
// @Param request body dto.ApiInterfaceConfig true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/api/config/update [post]
// @x-panel-log {"bodyKeys":["ipWhiteList"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 API 接口配置 => IP 白名单: [ipWhiteList]","formatEN":"update api config => IP White List: [ipWhiteList]"}
func (b *BaseApi) UpdateApiConfig(c *gin.Context) {
panelToken := c.GetHeader("1Panel-Token")
if panelToken != "" {
helper.ErrorWithDetail(c, constant.CodeErrUnauthorized, constant.ErrApiConfigDisable, nil)
return
}
var req dto.ApiInterfaceConfig
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := settingService.UpdateApiConfig(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
func checkEntrancePattern(val string) bool {
if len(val) == 0 {
return true
}
result, _ := regexp.MatchString("^[a-zA-Z0-9]{5,116}$", val)
return result
}
+13 -35
View File
@@ -9,11 +9,11 @@ import (
// @Tags System Setting // @Tags System Setting
// @Summary Create system snapshot // @Summary Create system snapshot
// @Description 创建系统快照
// @Accept json // @Accept json
// @Param request body dto.SnapshotCreate true "request" // @Param request body dto.SnapshotCreate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/snapshot [post] // @Router /settings/snapshot [post]
// @x-panel-log {"bodyKeys":["from", "description"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建系统快照 [description] 到 [from]","formatEN":"Create system backup [description] to [from]"} // @x-panel-log {"bodyKeys":["from", "description"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建系统快照 [description] 到 [from]","formatEN":"Create system backup [description] to [from]"}
func (b *BaseApi) CreateSnapshot(c *gin.Context) { func (b *BaseApi) CreateSnapshot(c *gin.Context) {
@@ -31,11 +31,11 @@ func (b *BaseApi) CreateSnapshot(c *gin.Context) {
// @Tags System Setting // @Tags System Setting
// @Summary Import system snapshot // @Summary Import system snapshot
// @Description 导入已有快照
// @Accept json // @Accept json
// @Param request body dto.SnapshotImport true "request" // @Param request body dto.SnapshotImport true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/snapshot/import [post] // @Router /settings/snapshot/import [post]
// @x-panel-log {"bodyKeys":["from", "names"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"从 [from] 同步系统快照 [names]","formatEN":"Sync system snapshots [names] from [from]"} // @x-panel-log {"bodyKeys":["from", "names"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"从 [from] 同步系统快照 [names]","formatEN":"Sync system snapshots [names] from [from]"}
func (b *BaseApi) ImportSnapshot(c *gin.Context) { func (b *BaseApi) ImportSnapshot(c *gin.Context) {
@@ -53,11 +53,11 @@ func (b *BaseApi) ImportSnapshot(c *gin.Context) {
// @Tags System Setting // @Tags System Setting
// @Summary Load Snapshot status // @Summary Load Snapshot status
// @Description 获取快照状态
// @Accept json // @Accept json
// @Param request body dto.OperateByID true "request" // @Param request body dto.OperateByID true "request"
// @Success 200 {object} dto.SnapshotStatus // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/snapshot/status [post] // @Router /settings/snapshot/status [post]
func (b *BaseApi) LoadSnapShotStatus(c *gin.Context) { func (b *BaseApi) LoadSnapShotStatus(c *gin.Context) {
var req dto.OperateByID var req dto.OperateByID
@@ -75,11 +75,11 @@ func (b *BaseApi) LoadSnapShotStatus(c *gin.Context) {
// @Tags System Setting // @Tags System Setting
// @Summary Update snapshot description // @Summary Update snapshot description
// @Description 更新快照描述信息
// @Accept json // @Accept json
// @Param request body dto.UpdateDescription true "request" // @Param request body dto.UpdateDescription true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/snapshot/description/update [post] // @Router /settings/snapshot/description/update [post]
// @x-panel-log {"bodyKeys":["id","description"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"snapshots","output_column":"name","output_value":"name"}],"formatZH":"快照 [name] 描述信息修改 [description]","formatEN":"The description of the snapshot [name] is modified => [description]"} // @x-panel-log {"bodyKeys":["id","description"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"snapshots","output_column":"name","output_value":"name"}],"formatZH":"快照 [name] 描述信息修改 [description]","formatEN":"The description of the snapshot [name] is modified => [description]"}
func (b *BaseApi) UpdateSnapDescription(c *gin.Context) { func (b *BaseApi) UpdateSnapDescription(c *gin.Context) {
@@ -97,14 +97,14 @@ func (b *BaseApi) UpdateSnapDescription(c *gin.Context) {
// @Tags System Setting // @Tags System Setting
// @Summary Page system snapshot // @Summary Page system snapshot
// @Description 获取系统快照列表分页
// @Accept json // @Accept json
// @Param request body dto.PageSnapshot true "request" // @Param request body dto.SearchWithPage true "request"
// @Success 200 {object} dto.PageResult // @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/snapshot/search [post] // @Router /settings/snapshot/search [post]
func (b *BaseApi) SearchSnapshot(c *gin.Context) { func (b *BaseApi) SearchSnapshot(c *gin.Context) {
var req dto.PageSnapshot var req dto.SearchWithPage
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }
@@ -120,35 +120,13 @@ func (b *BaseApi) SearchSnapshot(c *gin.Context) {
}) })
} }
// @Tags System Setting
// @Summary Load system snapshot size
// @Accept json
// @Param request body dto.PageSnapshot true "request"
// @Success 200 {array} dto.SnapshotFile
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/snapshot/size [post]
func (b *BaseApi) LoadSnapshotSize(c *gin.Context) {
var req dto.PageSnapshot
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
data, err := snapshotService.LoadSize(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, data)
}
// @Tags System Setting // @Tags System Setting
// @Summary Recover system backup // @Summary Recover system backup
// @Description 从系统快照恢复
// @Accept json // @Accept json
// @Param request body dto.SnapshotRecover true "request" // @Param request body dto.SnapshotRecover true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/snapshot/recover [post] // @Router /settings/snapshot/recover [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"snapshots","output_column":"name","output_value":"name"}],"formatZH":"从系统快照 [name] 恢复","formatEN":"Recover from system backup [name]"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"snapshots","output_column":"name","output_value":"name"}],"formatZH":"从系统快照 [name] 恢复","formatEN":"Recover from system backup [name]"}
func (b *BaseApi) RecoverSnapshot(c *gin.Context) { func (b *BaseApi) RecoverSnapshot(c *gin.Context) {
@@ -166,11 +144,11 @@ func (b *BaseApi) RecoverSnapshot(c *gin.Context) {
// @Tags System Setting // @Tags System Setting
// @Summary Rollback system backup // @Summary Rollback system backup
// @Description 从系统快照回滚
// @Accept json // @Accept json
// @Param request body dto.SnapshotRecover true "request" // @Param request body dto.SnapshotRecover true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/snapshot/rollback [post] // @Router /settings/snapshot/rollback [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"snapshots","output_column":"name","output_value":"name"}],"formatZH":"从系统快照 [name] 回滚","formatEN":"Rollback from system backup [name]"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"snapshots","output_column":"name","output_value":"name"}],"formatZH":"从系统快照 [name] 回滚","formatEN":"Rollback from system backup [name]"}
func (b *BaseApi) RollbackSnapshot(c *gin.Context) { func (b *BaseApi) RollbackSnapshot(c *gin.Context) {
@@ -188,15 +166,15 @@ func (b *BaseApi) RollbackSnapshot(c *gin.Context) {
// @Tags System Setting // @Tags System Setting
// @Summary Delete system backup // @Summary Delete system backup
// @Description 删除系统快照
// @Accept json // @Accept json
// @Param request body dto.SnapshotBatchDelete true "request" // @Param request body dto.BatchDeleteReq true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/snapshot/del [post] // @Router /settings/snapshot/del [post]
// @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"snapshots","output_column":"name","output_value":"name"}],"formatZH":"删除系统快照 [name]","formatEN":"Delete system backup [name]"} // @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"snapshots","output_column":"name","output_value":"name"}],"formatZH":"删除系统快照 [name]","formatEN":"Delete system backup [name]"}
func (b *BaseApi) DeleteSnapshot(c *gin.Context) { func (b *BaseApi) DeleteSnapshot(c *gin.Context) {
var req dto.SnapshotBatchDelete var req dto.BatchDeleteReq
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }
+41 -20
View File
@@ -9,10 +9,10 @@ import (
// @Tags SSH // @Tags SSH
// @Summary Load host SSH setting info // @Summary Load host SSH setting info
// @Description 加载 SSH 配置信息
// @Success 200 {object} dto.SSHInfo // @Success 200 {object} dto.SSHInfo
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /host/ssh/search [post]
// @Router /hosts/ssh/search [post]
func (b *BaseApi) GetSSHInfo(c *gin.Context) { func (b *BaseApi) GetSSHInfo(c *gin.Context) {
info, err := sshService.GetSSHInfo() info, err := sshService.GetSSHInfo()
if err != nil { if err != nil {
@@ -24,12 +24,11 @@ func (b *BaseApi) GetSSHInfo(c *gin.Context) {
// @Tags SSH // @Tags SSH
// @Summary Operate SSH // @Summary Operate SSH
// @Description 修改 SSH 服务状态
// @Accept json // @Accept json
// @Param request body dto.Operate true "request" // @Param request body dto.Operate true "request"
// @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /host/ssh/operate [post]
// @Router /hosts/ssh/operate [post]
// @x-panel-log {"bodyKeys":["operation"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"[operation] SSH ","formatEN":"[operation] SSH"} // @x-panel-log {"bodyKeys":["operation"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"[operation] SSH ","formatEN":"[operation] SSH"}
func (b *BaseApi) OperateSSH(c *gin.Context) { func (b *BaseApi) OperateSSH(c *gin.Context) {
var req dto.Operate var req dto.Operate
@@ -46,12 +45,12 @@ func (b *BaseApi) OperateSSH(c *gin.Context) {
// @Tags SSH // @Tags SSH
// @Summary Update host SSH setting // @Summary Update host SSH setting
// @Description 更新 SSH 配置
// @Accept json // @Accept json
// @Param request body dto.SSHUpdate true "request" // @Param request body dto.SSHUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /host/ssh/update [post]
// @Router /hosts/ssh/update [post]
// @x-panel-log {"bodyKeys":["key","value"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改 SSH 配置 [key] => [value]","formatEN":"update SSH setting [key] => [value]"} // @x-panel-log {"bodyKeys":["key","value"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改 SSH 配置 [key] => [value]","formatEN":"update SSH setting [key] => [value]"}
func (b *BaseApi) UpdateSSH(c *gin.Context) { func (b *BaseApi) UpdateSSH(c *gin.Context) {
var req dto.SSHUpdate var req dto.SSHUpdate
@@ -68,12 +67,12 @@ func (b *BaseApi) UpdateSSH(c *gin.Context) {
// @Tags SSH // @Tags SSH
// @Summary Update host SSH setting by file // @Summary Update host SSH setting by file
// @Description 上传文件更新 SSH 配置
// @Accept json // @Accept json
// @Param request body dto.SSHConf true "request" // @Param request body dto.SSHConf true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /host/conffile/update [post]
// @Router /hosts/conffile/update [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改 SSH 配置文件","formatEN":"update SSH conf"} // @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改 SSH 配置文件","formatEN":"update SSH conf"}
func (b *BaseApi) UpdateSSHByfile(c *gin.Context) { func (b *BaseApi) UpdateSSHByfile(c *gin.Context) {
var req dto.SSHConf var req dto.SSHConf
@@ -90,12 +89,12 @@ func (b *BaseApi) UpdateSSHByfile(c *gin.Context) {
// @Tags SSH // @Tags SSH
// @Summary Generate host SSH secret // @Summary Generate host SSH secret
// @Description 生成 SSH 密钥
// @Accept json // @Accept json
// @Param request body dto.GenerateSSH true "request" // @Param request body dto.GenerateSSH true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /host/ssh/generate [post]
// @Router /hosts/ssh/generate [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"生成 SSH 密钥 ","formatEN":"generate SSH secret"} // @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"生成 SSH 密钥 ","formatEN":"generate SSH secret"}
func (b *BaseApi) GenerateSSH(c *gin.Context) { func (b *BaseApi) GenerateSSH(c *gin.Context) {
var req dto.GenerateSSH var req dto.GenerateSSH
@@ -112,12 +111,12 @@ func (b *BaseApi) GenerateSSH(c *gin.Context) {
// @Tags SSH // @Tags SSH
// @Summary Load host SSH secret // @Summary Load host SSH secret
// @Description 获取 SSH 密钥
// @Accept json // @Accept json
// @Param request body dto.GenerateLoad true "request" // @Param request body dto.GenerateLoad true "request"
// @Success 200 {string} data // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /host/ssh/secret [post]
// @Router /hosts/ssh/secret [post]
func (b *BaseApi) LoadSSHSecret(c *gin.Context) { func (b *BaseApi) LoadSSHSecret(c *gin.Context) {
var req dto.GenerateLoad var req dto.GenerateLoad
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
@@ -132,21 +131,43 @@ func (b *BaseApi) LoadSSHSecret(c *gin.Context) {
helper.SuccessWithData(c, data) helper.SuccessWithData(c, data)
} }
// @Tags SSH
// @Summary Analysis host SSH logs
// @Description 分析 SSH 登录日志
// @Accept json
// @Param request body dto.SearchForAnalysis true "request"
// @Success 200 {array} dto.SSHLogAnalysis
// @Security ApiKeyAuth
// @Router /host/ssh/log/analysis [post]
func (b *BaseApi) AnalysisLog(c *gin.Context) {
var req dto.SearchForAnalysis
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
data, err := sshService.AnalysisLog(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, data)
}
// @Tags SSH // @Tags SSH
// @Summary Load host SSH logs // @Summary Load host SSH logs
// @Description 获取 SSH 登录日志
// @Accept json // @Accept json
// @Param request body dto.SearchSSHLog true "request" // @Param request body dto.SearchSSHLog true "request"
// @Success 200 {object} dto.SSHLog // @Success 200 {object} dto.SSHLog
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /host/ssh/log [post]
// @Router /hosts/ssh/log [post]
func (b *BaseApi) LoadSSHLogs(c *gin.Context) { func (b *BaseApi) LoadSSHLogs(c *gin.Context) {
var req dto.SearchSSHLog var req dto.SearchSSHLog
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }
data, err := sshService.LoadLog(c, req) data, err := sshService.LoadLog(req)
if err != nil { if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
@@ -156,10 +177,10 @@ func (b *BaseApi) LoadSSHLogs(c *gin.Context) {
// @Tags SSH // @Tags SSH
// @Summary Load host SSH conf // @Summary Load host SSH conf
// @Success 200 {string} data // @Description 获取 SSH 配置文件
// @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /host/ssh/conf [get]
// @Router /hosts/ssh/conf [get]
func (b *BaseApi) LoadSSHConf(c *gin.Context) { func (b *BaseApi) LoadSSHConf(c *gin.Context) {
data, err := sshService.LoadSSHConf() data, err := sshService.LoadSSHConf()
if err != nil { if err != nil {
+79 -84
View File
@@ -9,7 +9,6 @@ import (
"strings" "strings"
"time" "time"
"github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/backend/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/1Panel-dev/1Panel/backend/utils/cmd" "github.com/1Panel-dev/1Panel/backend/utils/cmd"
"github.com/1Panel-dev/1Panel/backend/utils/copier" "github.com/1Panel-dev/1Panel/backend/utils/copier"
@@ -56,6 +55,7 @@ func (b *BaseApi) WsSsh(c *gin.Context) {
return return
} }
defer client.Close() defer client.Close()
sws, err := terminal.NewLogicSshWsSession(cols, rows, true, connInfo.Client, wsConn) sws, err := terminal.NewLogicSshWsSession(cols, rows, true, connInfo.Client, wsConn)
if wshandleError(wsConn, err) { if wshandleError(wsConn, err) {
return return
@@ -68,23 +68,17 @@ func (b *BaseApi) WsSsh(c *gin.Context) {
<-quitChan <-quitChan
dt := time.Now().Add(time.Second) if wshandleError(wsConn, err) {
_ = wsConn.WriteControl(websocket.CloseMessage, nil, dt) return
}
} }
func (b *BaseApi) ContainerWsSSH(c *gin.Context) { func (b *BaseApi) RedisWsSsh(c *gin.Context) {
wsConn, err := upGrader.Upgrade(c.Writer, c.Request, nil) wsConn, err := upGrader.Upgrade(c.Writer, c.Request, nil)
if err != nil { if err != nil {
global.LOG.Errorf("gin context http handler failed, err: %v", err) global.LOG.Errorf("gin context http handler failed, err: %v", err)
return return
} }
defer wsConn.Close()
if global.CONF.System.IsDemo {
if wshandleError(wsConn, errors.New(" demo server, prohibit this operation!")) {
return
}
}
cols, err := strconv.Atoi(c.DefaultQuery("cols", "80")) cols, err := strconv.Atoi(c.DefaultQuery("cols", "80"))
if wshandleError(wsConn, errors.WithMessage(err, "invalid param cols in request")) { if wshandleError(wsConn, errors.WithMessage(err, "invalid param cols in request")) {
@@ -94,33 +88,25 @@ func (b *BaseApi) ContainerWsSSH(c *gin.Context) {
if wshandleError(wsConn, errors.WithMessage(err, "invalid param rows in request")) { if wshandleError(wsConn, errors.WithMessage(err, "invalid param rows in request")) {
return return
} }
source := c.Query("source") redisConf, err := redisService.LoadConf()
var containerID string if wshandleError(wsConn, errors.WithMessage(err, "load redis container failed")) {
var initCmd []string return
switch source {
case "redis":
containerID, initCmd, err = loadRedisInitCmd(c)
case "ollama":
containerID, initCmd, err = loadOllamaInitCmd(c)
case "container":
containerID, initCmd, err = loadContainerInitCmd(c)
default:
if wshandleError(wsConn, fmt.Errorf("not support such source %s", source)) {
return
}
} }
defer wsConn.Close()
commands := "redis-cli"
if len(redisConf.Requirepass) != 0 {
commands = fmt.Sprintf("redis-cli -a %s --no-auth-warning", redisConf.Requirepass)
}
pidMap := loadMapFromDockerTop(redisConf.ContainerName)
slave, err := terminal.NewCommand(fmt.Sprintf("docker exec -it %s %s", redisConf.ContainerName, commands))
if wshandleError(wsConn, err) { if wshandleError(wsConn, err) {
return return
} }
pidMap := loadMapFromDockerTop(containerID) defer killBash(redisConf.ContainerName, commands, pidMap)
slave, err := terminal.NewCommand(initCmd)
if wshandleError(wsConn, err) {
return
}
defer killBash(containerID, strings.ReplaceAll(strings.Join(initCmd, " "), fmt.Sprintf("exec -it %s ", containerID), ""), pidMap)
defer slave.Close() defer slave.Close()
tty, err := terminal.NewLocalWsSession(cols, rows, wsConn, slave, false) tty, err := terminal.NewLocalWsSession(cols, rows, wsConn, slave)
if wshandleError(wsConn, err) { if wshandleError(wsConn, err) {
return return
} }
@@ -132,68 +118,77 @@ func (b *BaseApi) ContainerWsSSH(c *gin.Context) {
<-quitChan <-quitChan
global.LOG.Info("websocket finished") global.LOG.Info("websocket finished")
dt := time.Now().Add(time.Second) if wshandleError(wsConn, err) {
_ = wsConn.WriteControl(websocket.CloseMessage, nil, dt) return
}
} }
func loadRedisInitCmd(c *gin.Context) (string, []string, error) { func (b *BaseApi) ContainerWsSsh(c *gin.Context) {
name := c.Query("name") wsConn, err := upGrader.Upgrade(c.Writer, c.Request, nil)
from := c.Query("from")
commands := []string{"exec", "-it"}
database, err := databaseService.Get(name)
if err != nil { if err != nil {
return "", nil, fmt.Errorf("no such database in db, err: %v", err) global.LOG.Errorf("gin context http handler failed, err: %v", err)
return
} }
if from == "local" { defer wsConn.Close()
redisInfo, err := appInstallService.LoadConnInfo(dto.OperationWithNameAndType{Name: name, Type: "redis"})
if err != nil {
return "", nil, fmt.Errorf("no such app in db, err: %v", err)
}
name = redisInfo.ContainerName
commands = append(commands, []string{name, "redis-cli"}...)
if len(database.Password) != 0 {
commands = append(commands, []string{"-a", database.Password, "--no-auth-warning"}...)
}
} else {
name = "1Panel-redis-cli-tools"
commands = append(commands, []string{name, "redis-cli", "-h", database.Address, "-p", fmt.Sprintf("%v", database.Port)}...)
if len(database.Password) != 0 {
commands = append(commands, []string{"-a", database.Password, "--no-auth-warning"}...)
}
}
return name, commands, nil
}
func loadOllamaInitCmd(c *gin.Context) (string, []string, error) {
name := c.Query("name")
if cmd.CheckIllegal(name) {
return "", nil, fmt.Errorf("ollama model %s contains illegal characters", name)
}
ollamaInfo, err := appInstallService.LoadConnInfo(dto.OperationWithNameAndType{Name: "", Type: "ollama"})
if err != nil {
return "", nil, fmt.Errorf("no such app in db, err: %v", err)
}
containerName := ollamaInfo.ContainerName
return containerName, []string{"exec", "-it", containerName, "ollama", "run", name}, nil
}
func loadContainerInitCmd(c *gin.Context) (string, []string, error) {
containerID := c.Query("containerid") containerID := c.Query("containerid")
command := c.Query("command") command := c.Query("command")
user := c.Query("user") user := c.Query("user")
if cmd.CheckIllegal(user, containerID, command) {
return "", nil, fmt.Errorf("the command contains illegal characters. command: %s, user: %s, containerID: %s", command, user, containerID)
}
if len(command) == 0 || len(containerID) == 0 { if len(command) == 0 || len(containerID) == 0 {
return "", nil, fmt.Errorf("error param of command: %s or containerID: %s", command, containerID) if wshandleError(wsConn, errors.New("error param of command or containerID")) {
return
}
} }
commands := []string{"exec", "-it", containerID, command} cols, err := strconv.Atoi(c.DefaultQuery("cols", "80"))
if len(user) != 0 { if wshandleError(wsConn, errors.WithMessage(err, "invalid param cols in request")) {
commands = []string{"exec", "-it", "-u", user, containerID, command} return
}
rows, err := strconv.Atoi(c.DefaultQuery("rows", "40"))
if wshandleError(wsConn, errors.WithMessage(err, "invalid param rows in request")) {
return
} }
return containerID, commands, nil cmds := []string{"exec", containerID, command}
if len(user) != 0 {
cmds = []string{"exec", "-u", user, containerID, command}
}
if cmd.CheckIllegal(user, containerID, command) {
if wshandleError(wsConn, errors.New(" The command contains illegal characters.")) {
return
}
}
stdout, err := cmd.ExecWithCheck("docker", cmds...)
if wshandleError(wsConn, errors.WithMessage(err, stdout)) {
return
}
commands := fmt.Sprintf("docker exec -it %s %s", containerID, command)
if len(user) != 0 {
commands = fmt.Sprintf("docker exec -it -u %s %s %s", user, containerID, command)
}
pidMap := loadMapFromDockerTop(containerID)
slave, err := terminal.NewCommand(commands)
if wshandleError(wsConn, err) {
return
}
defer killBash(containerID, command, pidMap)
defer slave.Close()
tty, err := terminal.NewLocalWsSession(cols, rows, wsConn, slave)
if wshandleError(wsConn, err) {
return
}
quitChan := make(chan bool, 3)
tty.Start(quitChan)
go slave.Wait(quitChan)
<-quitChan
global.LOG.Info("websocket finished")
if wshandleError(wsConn, err) {
return
}
} }
func wshandleError(ws *websocket.Conn, err error) bool { func wshandleError(ws *websocket.Conn, err error) bool {
@@ -227,10 +222,10 @@ func loadMapFromDockerTop(containerID string) map[string]string {
lines := strings.Split(stdout, "\n") lines := strings.Split(stdout, "\n")
for _, line := range lines { for _, line := range lines {
parts := strings.Fields(line) parts := strings.Fields(line)
if len(parts) < 2 { if len(parts) != 2 {
continue continue
} }
pidMap[parts[0]] = strings.Join(parts[1:], " ") pidMap[parts[0]] = parts[1]
} }
return pidMap return pidMap
} }
+5 -5
View File
@@ -9,9 +9,9 @@ import (
// @Tags System Setting // @Tags System Setting
// @Summary Load upgrade info // @Summary Load upgrade info
// @Description 系统更新信息
// @Success 200 {object} dto.UpgradeInfo // @Success 200 {object} dto.UpgradeInfo
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/upgrade [get] // @Router /settings/upgrade [get]
func (b *BaseApi) GetUpgradeInfo(c *gin.Context) { func (b *BaseApi) GetUpgradeInfo(c *gin.Context) {
info, err := upgradeService.SearchUpgrade() info, err := upgradeService.SearchUpgrade()
@@ -24,11 +24,11 @@ func (b *BaseApi) GetUpgradeInfo(c *gin.Context) {
// @Tags System Setting // @Tags System Setting
// @Summary Load release notes by version // @Summary Load release notes by version
// @Description 获取版本 release notes
// @Accept json // @Accept json
// @Param request body dto.Upgrade true "request" // @Param request body dto.Upgrade true "request"
// @Success 200 {string} notes // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/upgrade [get] // @Router /settings/upgrade [get]
func (b *BaseApi) GetNotesByVersion(c *gin.Context) { func (b *BaseApi) GetNotesByVersion(c *gin.Context) {
var req dto.Upgrade var req dto.Upgrade
@@ -46,13 +46,13 @@ func (b *BaseApi) GetNotesByVersion(c *gin.Context) {
// @Tags System Setting // @Tags System Setting
// @Summary Upgrade // @Summary Upgrade
// @Description 系统更新
// @Accept json // @Accept json
// @Param request body dto.Upgrade true "request" // @Param request body dto.Upgrade true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /settings/upgrade [post] // @Router /settings/upgrade [post]
// @x-panel-log {"bodyKeys":["version"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新系统 => [version]","formatEN":"upgrade system => [version]"} // @x-panel-log {"bodyKeys":["version"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新系统 => [version]","formatEN":"upgrade service => [version]"}
func (b *BaseApi) Upgrade(c *gin.Context) { func (b *BaseApi) Upgrade(c *gin.Context) {
var req dto.Upgrade var req dto.Upgrade
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
+113 -127
View File
@@ -1,8 +1,6 @@
package v1 package v1
import ( import (
"encoding/base64"
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/backend/app/dto/request" "github.com/1Panel-dev/1Panel/backend/app/dto/request"
@@ -12,11 +10,11 @@ import (
// @Tags Website // @Tags Website
// @Summary Page websites // @Summary Page websites
// @Description 获取网站列表分页
// @Accept json // @Accept json
// @Param request body request.WebsiteSearch true "request" // @Param request body request.WebsiteSearch true "request"
// @Success 200 {object} dto.PageResult // @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/search [post] // @Router /websites/search [post]
func (b *BaseApi) PageWebsite(c *gin.Context) { func (b *BaseApi) PageWebsite(c *gin.Context) {
var req request.WebsiteSearch var req request.WebsiteSearch
@@ -36,9 +34,9 @@ func (b *BaseApi) PageWebsite(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary List websites // @Summary List websites
// @Description 获取网站列表
// @Success 200 {array} response.WebsiteDTO // @Success 200 {array} response.WebsiteDTO
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/list [get] // @Router /websites/list [get]
func (b *BaseApi) GetWebsites(c *gin.Context) { func (b *BaseApi) GetWebsites(c *gin.Context) {
websites, err := websiteService.GetWebsites() websites, err := websiteService.GetWebsites()
@@ -51,9 +49,9 @@ func (b *BaseApi) GetWebsites(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary List website names // @Summary List website names
// @Success 200 {array} response.WebsiteOption // @Description 获取网站列表
// @Success 200 {array} string
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/options [get] // @Router /websites/options [get]
func (b *BaseApi) GetWebsiteOptions(c *gin.Context) { func (b *BaseApi) GetWebsiteOptions(c *gin.Context) {
websites, err := websiteService.GetWebsiteOptions() websites, err := websiteService.GetWebsiteOptions()
@@ -66,11 +64,11 @@ func (b *BaseApi) GetWebsiteOptions(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary Create website // @Summary Create website
// @Description 创建网站
// @Accept json // @Accept json
// @Param request body request.WebsiteCreate true "request" // @Param request body request.WebsiteCreate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites [post] // @Router /websites [post]
// @x-panel-log {"bodyKeys":["primaryDomain"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建网站 [primaryDomain]","formatEN":"Create website [primaryDomain]"} // @x-panel-log {"bodyKeys":["primaryDomain"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建网站 [primaryDomain]","formatEN":"Create website [primaryDomain]"}
func (b *BaseApi) CreateWebsite(c *gin.Context) { func (b *BaseApi) CreateWebsite(c *gin.Context) {
@@ -78,14 +76,6 @@ func (b *BaseApi) CreateWebsite(c *gin.Context) {
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }
if len(req.FtpPassword) != 0 {
pass, err := base64.StdEncoding.DecodeString(req.FtpPassword)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
return
}
req.FtpPassword = string(pass)
}
err := websiteService.CreateWebsite(req) err := websiteService.CreateWebsite(req)
if err != nil { if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
@@ -96,11 +86,11 @@ func (b *BaseApi) CreateWebsite(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary Operate website // @Summary Operate website
// @Description 操作网站
// @Accept json // @Accept json
// @Param request body request.WebsiteOp true "request" // @Param request body request.WebsiteOp true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/operate [post] // @Router /websites/operate [post]
// @x-panel-log {"bodyKeys":["id", "operate"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"[operate] 网站 [domain]","formatEN":"[operate] website [domain]"} // @x-panel-log {"bodyKeys":["id", "operate"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"[operate] 网站 [domain]","formatEN":"[operate] website [domain]"}
func (b *BaseApi) OpWebsite(c *gin.Context) { func (b *BaseApi) OpWebsite(c *gin.Context) {
@@ -118,11 +108,11 @@ func (b *BaseApi) OpWebsite(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary Delete website // @Summary Delete website
// @Description 删除网站
// @Accept json // @Accept json
// @Param request body request.WebsiteDelete true "request" // @Param request body request.WebsiteDelete true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/del [post] // @Router /websites/del [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"删除网站 [domain]","formatEN":"Delete website [domain]"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"删除网站 [domain]","formatEN":"Delete website [domain]"}
func (b *BaseApi) DeleteWebsite(c *gin.Context) { func (b *BaseApi) DeleteWebsite(c *gin.Context) {
@@ -140,11 +130,11 @@ func (b *BaseApi) DeleteWebsite(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary Update website // @Summary Update website
// @Description 更新网站
// @Accept json // @Accept json
// @Param request body request.WebsiteUpdate true "request" // @Param request body request.WebsiteUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/update [post] // @Router /websites/update [post]
// @x-panel-log {"bodyKeys":["primaryDomain"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新网站 [primaryDomain]","formatEN":"Update website [primaryDomain]"} // @x-panel-log {"bodyKeys":["primaryDomain"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新网站 [primaryDomain]","formatEN":"Update website [primaryDomain]"}
func (b *BaseApi) UpdateWebsite(c *gin.Context) { func (b *BaseApi) UpdateWebsite(c *gin.Context) {
@@ -161,12 +151,12 @@ func (b *BaseApi) UpdateWebsite(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary Search website by id // @Summary Search website by id
// @Description 通过 id 查询网站
// @Accept json // @Accept json
// @Param id path integer true "request" // @Param id path integer true "request"
// @Success 200 {object} response.WebsiteDTO // @Success 200 {object} response.WebsiteDTO
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /websites/:id [get]
// @Router /websites/{id} [get]
func (b *BaseApi) GetWebsite(c *gin.Context) { func (b *BaseApi) GetWebsite(c *gin.Context) {
id, err := helper.GetParamID(c) id, err := helper.GetParamID(c)
if err != nil { if err != nil {
@@ -183,13 +173,12 @@ func (b *BaseApi) GetWebsite(c *gin.Context) {
// @Tags Website Nginx // @Tags Website Nginx
// @Summary Search website nginx by id // @Summary Search website nginx by id
// @Description 通过 id 查询网站 nginx
// @Accept json // @Accept json
// @Param id path integer true "request" // @Param id path integer true "request"
// @Param type path string true "type"
// @Success 200 {object} response.FileInfo // @Success 200 {object} response.FileInfo
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /websites/:id/config/:type [get]
// @Router /websites/{id}/config/{type} [get]
func (b *BaseApi) GetWebsiteNginx(c *gin.Context) { func (b *BaseApi) GetWebsiteNginx(c *gin.Context) {
id, err := helper.GetParamID(c) id, err := helper.GetParamID(c)
if err != nil { if err != nil {
@@ -208,11 +197,11 @@ func (b *BaseApi) GetWebsiteNginx(c *gin.Context) {
// @Tags Website Nginx // @Tags Website Nginx
// @Summary Load nginx conf // @Summary Load nginx conf
// @Description 获取 nginx 配置
// @Accept json // @Accept json
// @Param request body request.NginxScopeReq true "request" // @Param request body request.NginxScopeReq true "request"
// @Success 200 {object} response.WebsiteNginxConfig // @Success 200 {object} response.WebsiteNginxConfig
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/config [post] // @Router /websites/config [post]
func (b *BaseApi) GetNginxConfig(c *gin.Context) { func (b *BaseApi) GetNginxConfig(c *gin.Context) {
var req request.NginxScopeReq var req request.NginxScopeReq
@@ -229,11 +218,11 @@ func (b *BaseApi) GetNginxConfig(c *gin.Context) {
// @Tags Website Nginx // @Tags Website Nginx
// @Summary Update nginx conf // @Summary Update nginx conf
// @Description 更新 nginx 配置
// @Accept json // @Accept json
// @Param request body request.NginxConfigUpdate true "request" // @Param request body request.NginxConfigUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/config/update [post] // @Router /websites/config/update [post]
// @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"nginx 配置修改 [domain]","formatEN":"Nginx conf update [domain]"} // @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"nginx 配置修改 [domain]","formatEN":"Nginx conf update [domain]"}
func (b *BaseApi) UpdateNginxConfig(c *gin.Context) { func (b *BaseApi) UpdateNginxConfig(c *gin.Context) {
@@ -250,12 +239,12 @@ func (b *BaseApi) UpdateNginxConfig(c *gin.Context) {
// @Tags Website HTTPS // @Tags Website HTTPS
// @Summary Load https conf // @Summary Load https conf
// @Description 获取 https 配置
// @Accept json // @Accept json
// @Param id path integer true "request" // @Param id path integer true "request"
// @Success 200 {object} response.WebsiteHTTPS // @Success 200 {object} response.WebsiteHTTPS
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /websites/:id/https [get]
// @Router /websites/{id}/https [get]
func (b *BaseApi) GetHTTPSConfig(c *gin.Context) { func (b *BaseApi) GetHTTPSConfig(c *gin.Context) {
id, err := helper.GetParamID(c) id, err := helper.GetParamID(c)
if err != nil { if err != nil {
@@ -272,13 +261,12 @@ func (b *BaseApi) GetHTTPSConfig(c *gin.Context) {
// @Tags Website HTTPS // @Tags Website HTTPS
// @Summary Update https conf // @Summary Update https conf
// @Description 更新 https 配置
// @Accept json // @Accept json
// @Param id path integer true "request"
// @Param request body request.WebsiteHTTPSOp true "request" // @Param request body request.WebsiteHTTPSOp true "request"
// @Success 200 {object} response.WebsiteHTTPS // @Success 200 {object} response.WebsiteHTTPS
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /websites/:id/https [post]
// @Router /websites/{id}/https [post]
// @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新网站 [domain] https 配置","formatEN":"Update website https [domain] conf"} // @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新网站 [domain] https 配置","formatEN":"Update website https [domain] conf"}
func (b *BaseApi) UpdateHTTPSConfig(c *gin.Context) { func (b *BaseApi) UpdateHTTPSConfig(c *gin.Context) {
var req request.WebsiteHTTPSOp var req request.WebsiteHTTPSOp
@@ -298,11 +286,11 @@ func (b *BaseApi) UpdateHTTPSConfig(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary Check before create website // @Summary Check before create website
// @Description 网站创建前检查
// @Accept json // @Accept json
// @Param request body request.WebsiteInstallCheckReq true "request" // @Param request body request.WebsiteInstallCheckReq true "request"
// @Success 200 {array} response.WebsitePreInstallCheck // @Success 200 {array} response.WebsitePreInstallCheck
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/check [post] // @Router /websites/check [post]
func (b *BaseApi) CreateWebsiteCheck(c *gin.Context) { func (b *BaseApi) CreateWebsiteCheck(c *gin.Context) {
var req request.WebsiteInstallCheckReq var req request.WebsiteInstallCheckReq
@@ -317,13 +305,76 @@ func (b *BaseApi) CreateWebsiteCheck(c *gin.Context) {
helper.SuccessWithData(c, data) helper.SuccessWithData(c, data)
} }
// @Tags Website WAF
// @Summary Load websit waf conf
// @Description 获取网站 waf 配置
// @Accept json
// @Param request body request.WebsiteWafReq true "request"
// @Success 200 {object} response.WebsiteWafConfig
// @Security ApiKeyAuth
// @Router /websites/waf/config [post]
func (b *BaseApi) GetWebsiteWafConfig(c *gin.Context) {
var req request.WebsiteWafReq
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
data, err := websiteService.GetWafConfig(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, data)
}
// @Tags Website WAF
// @Summary Update website waf conf
// @Description 更新 网站 waf 配置
// @Accept json
// @Param request body request.WebsiteWafUpdate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Router /websites/waf/update [post]
// @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"WAF 配置修改 [domain]","formatEN":"WAF conf update [domain]"}
func (b *BaseApi) UpdateWebsiteWafConfig(c *gin.Context) {
var req request.WebsiteWafUpdate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := websiteService.UpdateWafConfig(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Website WAF
// @Summary Update website waf file
// @Description 更新 网站 waf 配置文件
// @Accept json
// @Param request body request.WebsiteWafUpdate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Router /websites/waf/file/update [post]
// @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"WAF 配置文件修改 [domain]","formatEN":"WAF conf file update [domain]"}
func (b *BaseApi) UpdateWebsiteWafFile(c *gin.Context) {
var req request.WebsiteWafFileUpdate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := websiteService.UpdateWafFile(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}
// @Tags Website Nginx // @Tags Website Nginx
// @Summary Update website nginx conf // @Summary Update website nginx conf
// @Description 更新 网站 nginx 配置
// @Accept json // @Accept json
// @Param request body request.WebsiteNginxUpdate true "request" // @Param request body request.WebsiteNginxUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/nginx/update [post] // @Router /websites/nginx/update [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"[domain] Nginx 配置修改","formatEN":"[domain] Nginx conf update"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"[domain] Nginx 配置修改","formatEN":"[domain] Nginx conf update"}
func (b *BaseApi) UpdateWebsiteNginxConfig(c *gin.Context) { func (b *BaseApi) UpdateWebsiteNginxConfig(c *gin.Context) {
@@ -340,11 +391,11 @@ func (b *BaseApi) UpdateWebsiteNginxConfig(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary Operate website log // @Summary Operate website log
// @Description 操作网站日志
// @Accept json // @Accept json
// @Param request body request.WebsiteLogReq true "request" // @Param request body request.WebsiteLogReq true "request"
// @Success 200 {object} response.WebsiteLog // @Success 200 {object} response.WebsiteLog
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/log [post] // @Router /websites/log [post]
// @x-panel-log {"bodyKeys":["id", "operate"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"[domain][operate] 日志","formatEN":"[domain][operate] logs"} // @x-panel-log {"bodyKeys":["id", "operate"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"[domain][operate] 日志","formatEN":"[domain][operate] logs"}
func (b *BaseApi) OpWebsiteLog(c *gin.Context) { func (b *BaseApi) OpWebsiteLog(c *gin.Context) {
@@ -362,11 +413,11 @@ func (b *BaseApi) OpWebsiteLog(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary Change default server // @Summary Change default server
// @Description 操作网站日志
// @Accept json // @Accept json
// @Param request body request.WebsiteDefaultUpdate true "request" // @Param request body request.WebsiteDefaultUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/default/server [post] // @Router /websites/default/server [post]
// @x-panel-log {"bodyKeys":["id", "operate"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"修改默认 server => [domain]","formatEN":"Change default server => [domain]"} // @x-panel-log {"bodyKeys":["id", "operate"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"修改默认 server => [domain]","formatEN":"Change default server => [domain]"}
func (b *BaseApi) ChangeDefaultServer(c *gin.Context) { func (b *BaseApi) ChangeDefaultServer(c *gin.Context) {
@@ -382,13 +433,13 @@ func (b *BaseApi) ChangeDefaultServer(c *gin.Context) {
} }
// @Tags Website // @Tags Website
// @Summary Load website php conf // @Summary Load websit php conf
// @Description 获取网站 php 配置
// @Accept json // @Accept json
// @Param id path integer true "request" // @Param id path integer true "request"
// @Success 200 {object} response.PHPConfig // @Success 200 {object} response.PHPConfig
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /websites/php/config/:id [get]
// @Router /websites/php/config/{id} [get]
func (b *BaseApi) GetWebsitePHPConfig(c *gin.Context) { func (b *BaseApi) GetWebsitePHPConfig(c *gin.Context) {
id, err := helper.GetParamID(c) id, err := helper.GetParamID(c)
if err != nil { if err != nil {
@@ -405,11 +456,11 @@ func (b *BaseApi) GetWebsitePHPConfig(c *gin.Context) {
// @Tags Website PHP // @Tags Website PHP
// @Summary Update website php conf // @Summary Update website php conf
// @Description 更新 网站 PHP 配置
// @Accept json // @Accept json
// @Param request body request.WebsitePHPConfigUpdate true "request" // @Param request body request.WebsitePHPConfigUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/php/config [post] // @Router /websites/php/config [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"[domain] PHP 配置修改","formatEN":"[domain] PHP conf update"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"[domain] PHP 配置修改","formatEN":"[domain] PHP conf update"}
func (b *BaseApi) UpdateWebsitePHPConfig(c *gin.Context) { func (b *BaseApi) UpdateWebsitePHPConfig(c *gin.Context) {
@@ -426,11 +477,11 @@ func (b *BaseApi) UpdateWebsitePHPConfig(c *gin.Context) {
// @Tags Website PHP // @Tags Website PHP
// @Summary Update php conf // @Summary Update php conf
// @Description 更新 php 配置文件
// @Accept json // @Accept json
// @Param request body request.WebsitePHPFileUpdate true "request" // @Param request body request.WebsitePHPFileUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/php/update [post] // @Router /websites/php/update [post]
// @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"php 配置修改 [domain]","formatEN":"Nginx conf update [domain]"} // @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"php 配置修改 [domain]","formatEN":"Nginx conf update [domain]"}
func (b *BaseApi) UpdatePHPFile(c *gin.Context) { func (b *BaseApi) UpdatePHPFile(c *gin.Context) {
@@ -447,11 +498,11 @@ func (b *BaseApi) UpdatePHPFile(c *gin.Context) {
// @Tags Website PHP // @Tags Website PHP
// @Summary Update php version // @Summary Update php version
// @Description 变更 php 版本
// @Accept json // @Accept json
// @Param request body request.WebsitePHPVersionReq true "request" // @Param request body request.WebsitePHPVersionReq true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/php/version [post] // @Router /websites/php/version [post]
// @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"php 版本变更 [domain]","formatEN":"php version update [domain]"} // @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"php 版本变更 [domain]","formatEN":"php version update [domain]"}
func (b *BaseApi) ChangePHPVersion(c *gin.Context) { func (b *BaseApi) ChangePHPVersion(c *gin.Context) {
@@ -468,11 +519,11 @@ func (b *BaseApi) ChangePHPVersion(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary Get rewrite conf // @Summary Get rewrite conf
// @Description 获取伪静态配置
// @Accept json // @Accept json
// @Param request body request.NginxRewriteReq true "request" // @Param request body request.NginxRewriteReq true "request"
// @Success 200 {object} response.NginxRewriteRes // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/rewrite [post] // @Router /websites/rewrite [post]
func (b *BaseApi) GetRewriteConfig(c *gin.Context) { func (b *BaseApi) GetRewriteConfig(c *gin.Context) {
var req request.NginxRewriteReq var req request.NginxRewriteReq
@@ -489,11 +540,11 @@ func (b *BaseApi) GetRewriteConfig(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary Update rewrite conf // @Summary Update rewrite conf
// @Description 更新伪静态配置
// @Accept json // @Accept json
// @Param request body request.NginxRewriteUpdate true "request" // @Param request body request.NginxRewriteUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/rewrite/update [post] // @Router /websites/rewrite/update [post]
// @x-panel-log {"bodyKeys":["websiteID"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteID","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"伪静态配置修改 [domain]","formatEN":"Nginx conf rewrite update [domain]"} // @x-panel-log {"bodyKeys":["websiteID"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteID","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"伪静态配置修改 [domain]","formatEN":"Nginx conf rewrite update [domain]"}
func (b *BaseApi) UpdateRewriteConfig(c *gin.Context) { func (b *BaseApi) UpdateRewriteConfig(c *gin.Context) {
@@ -510,11 +561,11 @@ func (b *BaseApi) UpdateRewriteConfig(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary Update Site Dir // @Summary Update Site Dir
// @Description 更新网站目录
// @Accept json // @Accept json
// @Param request body request.WebsiteUpdateDir true "request" // @Param request body request.WebsiteUpdateDir true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/dir/update [post] // @Router /websites/dir/update [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新网站 [domain] 目录","formatEN":"Update domain [domain] dir"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新网站 [domain] 目录","formatEN":"Update domain [domain] dir"}
func (b *BaseApi) UpdateSiteDir(c *gin.Context) { func (b *BaseApi) UpdateSiteDir(c *gin.Context) {
@@ -531,11 +582,11 @@ func (b *BaseApi) UpdateSiteDir(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary Update Site Dir permission // @Summary Update Site Dir permission
// @Description 更新网站目录权限
// @Accept json // @Accept json
// @Param request body request.WebsiteUpdateDirPermission true "request" // @Param request body request.WebsiteUpdateDirPermission true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/dir/permission [post] // @Router /websites/dir/permission [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新网站 [domain] 目录权限","formatEN":"Update domain [domain] dir permission"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新网站 [domain] 目录权限","formatEN":"Update domain [domain] dir permission"}
func (b *BaseApi) UpdateSiteDirPermission(c *gin.Context) { func (b *BaseApi) UpdateSiteDirPermission(c *gin.Context) {
@@ -552,11 +603,11 @@ func (b *BaseApi) UpdateSiteDirPermission(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary Get proxy conf // @Summary Get proxy conf
// @Description 获取反向代理配置
// @Accept json // @Accept json
// @Param request body request.WebsiteProxyReq true "request" // @Param request body request.WebsiteProxyReq true "request"
// @Success 200 {array} request.WebsiteProxyConfig // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/proxies [post] // @Router /websites/proxies [post]
func (b *BaseApi) GetProxyConfig(c *gin.Context) { func (b *BaseApi) GetProxyConfig(c *gin.Context) {
var req request.WebsiteProxyReq var req request.WebsiteProxyReq
@@ -571,35 +622,13 @@ func (b *BaseApi) GetProxyConfig(c *gin.Context) {
helper.SuccessWithData(c, res) helper.SuccessWithData(c, res)
} }
// @Tags Website
// @Summary Delete proxy conf
// @Accept json
// @Param request body request.WebsiteProxyDel true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/proxies/del [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"删除网站 [domain] 反向代理配置","formatEN":"Delete domain [domain] proxy config"}
func (b *BaseApi) DeleteProxyConfig(c *gin.Context) {
var req request.WebsiteProxyDel
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
err := websiteService.DeleteProxy(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
// @Tags Website // @Tags Website
// @Summary Update proxy conf // @Summary Update proxy conf
// @Description 修改反向代理配置
// @Accept json // @Accept json
// @Param request body request.WebsiteProxyConfig true "request" // @Param request body request.WebsiteProxyConfig true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/proxies/update [post] // @Router /websites/proxies/update [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"修改网站 [domain] 反向代理配置 ","formatEN":"Update domain [domain] proxy config"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"修改网站 [domain] 反向代理配置 ","formatEN":"Update domain [domain] proxy config"}
func (b *BaseApi) UpdateProxyConfig(c *gin.Context) { func (b *BaseApi) UpdateProxyConfig(c *gin.Context) {
@@ -617,11 +646,11 @@ func (b *BaseApi) UpdateProxyConfig(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary Update proxy file // @Summary Update proxy file
// @Description 更新反向代理文件
// @Accept json // @Accept json
// @Param request body request.NginxProxyUpdate true "request" // @Param request body request.NginxProxyUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/proxy/file [post] // @Router /websites/proxy/file [post]
// @x-panel-log {"bodyKeys":["websiteID"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteID","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新反向代理文件 [domain]","formatEN":"Nginx conf proxy file update [domain]"} // @x-panel-log {"bodyKeys":["websiteID"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteID","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新反向代理文件 [domain]","formatEN":"Nginx conf proxy file update [domain]"}
func (b *BaseApi) UpdateProxyConfigFile(c *gin.Context) { func (b *BaseApi) UpdateProxyConfigFile(c *gin.Context) {
@@ -638,11 +667,11 @@ func (b *BaseApi) UpdateProxyConfigFile(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary Get AuthBasic conf // @Summary Get AuthBasic conf
// @Description 获取密码访问配置
// @Accept json // @Accept json
// @Param request body request.NginxAuthReq true "request" // @Param request body request.NginxAuthReq true "request"
// @Success 200 {object} response.NginxAuthRes // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/auths [post] // @Router /websites/auths [post]
func (b *BaseApi) GetAuthConfig(c *gin.Context) { func (b *BaseApi) GetAuthConfig(c *gin.Context) {
var req request.NginxAuthReq var req request.NginxAuthReq
@@ -659,11 +688,11 @@ func (b *BaseApi) GetAuthConfig(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary Get AuthBasic conf // @Summary Get AuthBasic conf
// @Description 更新密码访问配置
// @Accept json // @Accept json
// @Param request body request.NginxAuthUpdate true "request" // @Param request body request.NginxAuthUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/auths/update [post] // @Router /websites/auths/update [post]
func (b *BaseApi) UpdateAuthConfig(c *gin.Context) { func (b *BaseApi) UpdateAuthConfig(c *gin.Context) {
var req request.NginxAuthUpdate var req request.NginxAuthUpdate
@@ -679,11 +708,11 @@ func (b *BaseApi) UpdateAuthConfig(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary Get AntiLeech conf // @Summary Get AntiLeech conf
// @Description 获取防盗链配置
// @Accept json // @Accept json
// @Param request body request.NginxCommonReq true "request" // @Param request body request.NginxCommonReq true "request"
// @Success 200 {object} response.NginxAntiLeechRes // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/leech [post] // @Router /websites/leech [post]
func (b *BaseApi) GetAntiLeech(c *gin.Context) { func (b *BaseApi) GetAntiLeech(c *gin.Context) {
var req request.NginxCommonReq var req request.NginxCommonReq
@@ -699,12 +728,12 @@ func (b *BaseApi) GetAntiLeech(c *gin.Context) {
} }
// @Tags Website // @Tags Website
// @Summary Update AntiLeech conf // @Summary Update AntiLeech
// @Description 更新防盗链配置
// @Accept json // @Accept json
// @Param request body request.NginxAntiLeechUpdate true "request" // @Param request body request.NginxAntiLeechUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/leech/update [post] // @Router /websites/leech/update [post]
func (b *BaseApi) UpdateAntiLeech(c *gin.Context) { func (b *BaseApi) UpdateAntiLeech(c *gin.Context) {
var req request.NginxAntiLeechUpdate var req request.NginxAntiLeechUpdate
@@ -720,11 +749,11 @@ func (b *BaseApi) UpdateAntiLeech(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary Update redirect conf // @Summary Update redirect conf
// @Description 修改重定向配置
// @Accept json // @Accept json
// @Param request body request.NginxRedirectReq true "request" // @Param request body request.NginxRedirectReq true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/redirect/update [post] // @Router /websites/redirect/update [post]
// @x-panel-log {"bodyKeys":["websiteID"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteID","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"修改网站 [domain] 重定向理配置 ","formatEN":"Update domain [domain] redirect config"} // @x-panel-log {"bodyKeys":["websiteID"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteID","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"修改网站 [domain] 重定向理配置 ","formatEN":"Update domain [domain] redirect config"}
func (b *BaseApi) UpdateRedirectConfig(c *gin.Context) { func (b *BaseApi) UpdateRedirectConfig(c *gin.Context) {
@@ -742,11 +771,11 @@ func (b *BaseApi) UpdateRedirectConfig(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary Get redirect conf // @Summary Get redirect conf
// @Description 获取重定向配置
// @Accept json // @Accept json
// @Param request body request.WebsiteProxyReq true "request" // @Param request body request.WebsiteProxyReq true "request"
// @Success 200 {array} response.NginxRedirectConfig // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/redirect [post] // @Router /websites/redirect [post]
func (b *BaseApi) GetRedirectConfig(c *gin.Context) { func (b *BaseApi) GetRedirectConfig(c *gin.Context) {
var req request.WebsiteRedirectReq var req request.WebsiteRedirectReq
@@ -763,11 +792,11 @@ func (b *BaseApi) GetRedirectConfig(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary Update redirect file // @Summary Update redirect file
// @Description 更新重定向文件
// @Accept json // @Accept json
// @Param request body request.NginxRedirectUpdate true "request" // @Param request body request.NginxRedirectUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/redirect/file [post] // @Router /websites/redirect/file [post]
// @x-panel-log {"bodyKeys":["websiteID"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteID","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新重定向文件 [domain]","formatEN":"Nginx conf redirect file update [domain]"} // @x-panel-log {"bodyKeys":["websiteID"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteID","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新重定向文件 [domain]","formatEN":"Nginx conf redirect file update [domain]"}
func (b *BaseApi) UpdateRedirectConfigFile(c *gin.Context) { func (b *BaseApi) UpdateRedirectConfigFile(c *gin.Context) {
@@ -784,11 +813,11 @@ func (b *BaseApi) UpdateRedirectConfigFile(c *gin.Context) {
// @Tags Website // @Tags Website
// @Summary Get website dir // @Summary Get website dir
// @Description 获取网站目录配置
// @Accept json // @Accept json
// @Param request body request.WebsiteCommonReq true "request" // @Param request body request.WebsiteCommonReq true "request"
// @Success 200 {object} response.WebsiteDirConfig // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/dir [post] // @Router /websites/dir [post]
func (b *BaseApi) GetDirConfig(c *gin.Context) { func (b *BaseApi) GetDirConfig(c *gin.Context) {
var req request.WebsiteCommonReq var req request.WebsiteCommonReq
@@ -802,46 +831,3 @@ func (b *BaseApi) GetDirConfig(c *gin.Context) {
} }
helper.SuccessWithData(c, res) helper.SuccessWithData(c, res)
} }
// @Tags Website
// @Summary Get default html
// @Accept json
// @Param type path string true "type"
// @Success 200 {object} response.WebsiteHtmlRes
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/default/html/{type} [get]
func (b *BaseApi) GetDefaultHtml(c *gin.Context) {
resourceType, err := helper.GetStrParamByKey(c, "type")
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
return
}
fileInfo, err := websiteService.GetDefaultHtml(resourceType)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, fileInfo)
}
// @Tags Website
// @Summary Update default html
// @Accept json
// @Param request body request.WebsiteHtmlUpdate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/default/html/update [post]
// @x-panel-log {"bodyKeys":["type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新默认 html","formatEN":"Update default html"}
func (b *BaseApi) UpdateDefaultHtml(c *gin.Context) {
var req request.WebsiteHtmlUpdate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := websiteService.UpdateDefaultHtml(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
+3 -3
View File
@@ -10,11 +10,11 @@ import (
// @Tags Website Acme // @Tags Website Acme
// @Summary Page website acme accounts // @Summary Page website acme accounts
// @Description 获取网站 acme 列表分页
// @Accept json // @Accept json
// @Param request body dto.PageInfo true "request" // @Param request body dto.PageInfo true "request"
// @Success 200 {object} dto.PageResult // @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/acme/search [post] // @Router /websites/acme/search [post]
func (b *BaseApi) PageWebsiteAcmeAccount(c *gin.Context) { func (b *BaseApi) PageWebsiteAcmeAccount(c *gin.Context) {
var req dto.PageInfo var req dto.PageInfo
@@ -34,11 +34,11 @@ func (b *BaseApi) PageWebsiteAcmeAccount(c *gin.Context) {
// @Tags Website Acme // @Tags Website Acme
// @Summary Create website acme account // @Summary Create website acme account
// @Description 创建网站 acme
// @Accept json // @Accept json
// @Param request body request.WebsiteAcmeAccountCreate true "request" // @Param request body request.WebsiteAcmeAccountCreate true "request"
// @Success 200 {object} response.WebsiteAcmeAccountDTO // @Success 200 {object} response.WebsiteAcmeAccountDTO
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/acme [post] // @Router /websites/acme [post]
// @x-panel-log {"bodyKeys":["email"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建网站 acme [email]","formatEN":"Create website acme [email]"} // @x-panel-log {"bodyKeys":["email"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建网站 acme [email]","formatEN":"Create website acme [email]"}
func (b *BaseApi) CreateWebsiteAcmeAccount(c *gin.Context) { func (b *BaseApi) CreateWebsiteAcmeAccount(c *gin.Context) {
@@ -56,11 +56,11 @@ func (b *BaseApi) CreateWebsiteAcmeAccount(c *gin.Context) {
// @Tags Website Acme // @Tags Website Acme
// @Summary Delete website acme account // @Summary Delete website acme account
// @Description 删除网站 acme
// @Accept json // @Accept json
// @Param request body request.WebsiteResourceReq true "request" // @Param request body request.WebsiteResourceReq true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/acme/del [post] // @Router /websites/acme/del [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"website_acme_accounts","output_column":"email","output_value":"email"}],"formatZH":"删除网站 acme [email]","formatEN":"Delete website acme [email]"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"website_acme_accounts","output_column":"email","output_value":"email"}],"formatZH":"删除网站 acme [email]","formatEN":"Delete website acme [email]"}
func (b *BaseApi) DeleteWebsiteAcmeAccount(c *gin.Context) { func (b *BaseApi) DeleteWebsiteAcmeAccount(c *gin.Context) {
-177
View File
@@ -1,177 +0,0 @@
package v1
import (
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
"github.com/1Panel-dev/1Panel/backend/constant"
"github.com/gin-gonic/gin"
"net/http"
"net/url"
"strconv"
)
// @Tags Website CA
// @Summary Page website ca
// @Accept json
// @Param request body request.WebsiteCASearch true "request"
// @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/ca/search [post]
func (b *BaseApi) PageWebsiteCA(c *gin.Context) {
var req request.WebsiteCASearch
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
total, cas, err := websiteCAService.Page(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, dto.PageResult{
Total: total,
Items: cas,
})
}
// @Tags Website CA
// @Summary Create website ca
// @Accept json
// @Param request body request.WebsiteCACreate true "request"
// @Success 200 {object} request.WebsiteCACreate
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/ca [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建网站 ca [name]","formatEN":"Create website ca [name]"}
func (b *BaseApi) CreateWebsiteCA(c *gin.Context) {
var req request.WebsiteCACreate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
res, err := websiteCAService.Create(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, res)
}
// @Tags Website CA
// @Summary Get website ca
// @Accept json
// @Param id path int true "id"
// @Success 200 {object} response.WebsiteCADTO
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/ca/{id} [get]
func (b *BaseApi) GetWebsiteCA(c *gin.Context) {
id, err := helper.GetParamID(c)
if err != nil {
return
}
res, err := websiteCAService.GetCA(id)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, res)
}
// @Tags Website CA
// @Summary Delete website ca
// @Accept json
// @Param request body request.WebsiteCommonReq true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/ca/del [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"website_cas","output_column":"name","output_value":"name"}],"formatZH":"删除网站 ca [name]","formatEN":"Delete website ca [name]"}
func (b *BaseApi) DeleteWebsiteCA(c *gin.Context) {
var req request.WebsiteCommonReq
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := websiteCAService.Delete(req.ID); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
// @Tags Website CA
// @Summary Obtain SSL
// @Accept json
// @Param request body request.WebsiteCAObtain true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/ca/obtain [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"website_cas","output_column":"name","output_value":"name"}],"formatZH":"自签 SSL 证书 [name]","formatEN":"Obtain SSL [name]"}
func (b *BaseApi) ObtainWebsiteCA(c *gin.Context) {
var req request.WebsiteCAObtain
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if _, err := websiteCAService.ObtainSSL(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
// @Tags Website CA
// @Summary Renew Obtain SSL
// @Accept json
// @Param request body request.WebsiteCAObtain true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/ca/renew [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"website_cas","output_column":"name","output_value":"name"}],"formatZH":"自签 SSL 证书 [name]","formatEN":"Obtain SSL [name]"}
func (b *BaseApi) RenewWebsiteCA(c *gin.Context) {
var req request.WebsiteCARenew
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if _, err := websiteCAService.ObtainSSL(request.WebsiteCAObtain{
SSLID: req.SSLID,
Renew: true,
Unit: "year",
Time: 1,
}); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithOutData(c)
}
// @Tags Website CA
// @Summary Download CA file
// @Accept json
// @Param request body request.WebsiteResourceReq true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/ca/download [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"website_cas","output_column":"name","output_value":"name"}],"formatZH":"下载 CA 证书文件 [name]","formatEN":"download ca file [name]"}
func (b *BaseApi) DownloadCAFile(c *gin.Context) {
var req request.WebsiteResourceReq
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
file, err := websiteCAService.DownloadFile(req.ID)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
defer file.Close()
info, err := file.Stat()
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
c.Header("Content-Length", strconv.FormatInt(info.Size(), 10))
c.Header("Content-Disposition", "attachment; filename*=utf-8''"+url.PathEscape(info.Name()))
http.ServeContent(c.Writer, c.Request, info.Name(), info.ModTime(), file)
}
+4 -4
View File
@@ -10,11 +10,11 @@ import (
// @Tags Website DNS // @Tags Website DNS
// @Summary Page website dns accounts // @Summary Page website dns accounts
// @Description 获取网站 dns 列表分页
// @Accept json // @Accept json
// @Param request body dto.PageInfo true "request" // @Param request body dto.PageInfo true "request"
// @Success 200 {object} dto.PageResult // @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/dns/search [post] // @Router /websites/dns/search [post]
func (b *BaseApi) PageWebsiteDnsAccount(c *gin.Context) { func (b *BaseApi) PageWebsiteDnsAccount(c *gin.Context) {
var req dto.PageInfo var req dto.PageInfo
@@ -34,11 +34,11 @@ func (b *BaseApi) PageWebsiteDnsAccount(c *gin.Context) {
// @Tags Website DNS // @Tags Website DNS
// @Summary Create website dns account // @Summary Create website dns account
// @Description 创建网站 dns
// @Accept json // @Accept json
// @Param request body request.WebsiteDnsAccountCreate true "request" // @Param request body request.WebsiteDnsAccountCreate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/dns [post] // @Router /websites/dns [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建网站 dns [name]","formatEN":"Create website dns [name]"} // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建网站 dns [name]","formatEN":"Create website dns [name]"}
func (b *BaseApi) CreateWebsiteDnsAccount(c *gin.Context) { func (b *BaseApi) CreateWebsiteDnsAccount(c *gin.Context) {
@@ -55,11 +55,11 @@ func (b *BaseApi) CreateWebsiteDnsAccount(c *gin.Context) {
// @Tags Website DNS // @Tags Website DNS
// @Summary Update website dns account // @Summary Update website dns account
// @Description 更新网站 dns
// @Accept json // @Accept json
// @Param request body request.WebsiteDnsAccountUpdate true "request" // @Param request body request.WebsiteDnsAccountUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/dns/update [post] // @Router /websites/dns/update [post]
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新网站 dns [name]","formatEN":"Update website dns [name]"} // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新网站 dns [name]","formatEN":"Update website dns [name]"}
func (b *BaseApi) UpdateWebsiteDnsAccount(c *gin.Context) { func (b *BaseApi) UpdateWebsiteDnsAccount(c *gin.Context) {
@@ -76,11 +76,11 @@ func (b *BaseApi) UpdateWebsiteDnsAccount(c *gin.Context) {
// @Tags Website DNS // @Tags Website DNS
// @Summary Delete website dns account // @Summary Delete website dns account
// @Description 删除网站 dns
// @Accept json // @Accept json
// @Param request body request.WebsiteResourceReq true "request" // @Param request body request.WebsiteResourceReq true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/dns/del [post] // @Router /websites/dns/del [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"website_dns_accounts","output_column":"name","output_value":"name"}],"formatZH":"删除网站 dns [name]","formatEN":"Delete website dns [name]"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"website_dns_accounts","output_column":"name","output_value":"name"}],"formatZH":"删除网站 dns [name]","formatEN":"Delete website dns [name]"}
func (b *BaseApi) DeleteWebsiteDnsAccount(c *gin.Context) { func (b *BaseApi) DeleteWebsiteDnsAccount(c *gin.Context) {
+5 -5
View File
@@ -9,11 +9,11 @@ import (
// @Tags Website Domain // @Tags Website Domain
// @Summary Delete website domain // @Summary Delete website domain
// @Description 删除网站域名
// @Accept json // @Accept json
// @Param request body request.WebsiteDomainDelete true "request" // @Param request body request.WebsiteDomainDelete true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/domains/del [post] // @Router /websites/domains/del [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"website_domains","output_column":"domain","output_value":"domain"}],"formatZH":"删除域名 [domain]","formatEN":"Delete domain [domain]"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"website_domains","output_column":"domain","output_value":"domain"}],"formatZH":"删除域名 [domain]","formatEN":"Delete domain [domain]"}
func (b *BaseApi) DeleteWebDomain(c *gin.Context) { func (b *BaseApi) DeleteWebDomain(c *gin.Context) {
@@ -30,11 +30,11 @@ func (b *BaseApi) DeleteWebDomain(c *gin.Context) {
// @Tags Website Domain // @Tags Website Domain
// @Summary Create website domain // @Summary Create website domain
// @Description 创建网站域名
// @Accept json // @Accept json
// @Param request body request.WebsiteDomainCreate true "request" // @Param request body request.WebsiteDomainCreate true "request"
// @Success 200 {array} model.WebsiteDomain // @Success 200 {object} model.WebsiteDomain
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/domains [post] // @Router /websites/domains [post]
// @x-panel-log {"bodyKeys":["domain"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建域名 [domain]","formatEN":"Create domain [domain]"} // @x-panel-log {"bodyKeys":["domain"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建域名 [domain]","formatEN":"Create domain [domain]"}
func (b *BaseApi) CreateWebDomain(c *gin.Context) { func (b *BaseApi) CreateWebDomain(c *gin.Context) {
@@ -52,12 +52,12 @@ func (b *BaseApi) CreateWebDomain(c *gin.Context) {
// @Tags Website Domain // @Tags Website Domain
// @Summary Search website domains by websiteId // @Summary Search website domains by websiteId
// @Description 通过网站 id 查询域名
// @Accept json // @Accept json
// @Param websiteId path integer true "request" // @Param websiteId path integer true "request"
// @Success 200 {array} model.WebsiteDomain // @Success 200 {array} model.WebsiteDomain
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /websites/domains/:websiteId [get]
// @Router /websites/domains/{websiteId} [get]
func (b *BaseApi) GetWebDomains(c *gin.Context) { func (b *BaseApi) GetWebDomains(c *gin.Context) {
websiteId, err := helper.GetIntParamByKey(c, "websiteId") websiteId, err := helper.GetIntParamByKey(c, "websiteId")
if err != nil { if err != nil {
+28 -61
View File
@@ -1,10 +1,7 @@
package v1 package v1
import ( import (
"net/http"
"net/url"
"reflect" "reflect"
"strconv"
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
@@ -15,11 +12,11 @@ import (
// @Tags Website SSL // @Tags Website SSL
// @Summary Page website ssl // @Summary Page website ssl
// @Description 获取网站 ssl 列表分页
// @Accept json // @Accept json
// @Param request body request.WebsiteSSLSearch true "request" // @Param request body request.WebsiteSSLSearch true "request"
// @Success 200 {array} response.WebsiteSSLDTO // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/ssl/search [post] // @Router /websites/ssl/search [post]
func (b *BaseApi) PageWebsiteSSL(c *gin.Context) { func (b *BaseApi) PageWebsiteSSL(c *gin.Context) {
var req request.WebsiteSSLSearch var req request.WebsiteSSLSearch
@@ -48,11 +45,11 @@ func (b *BaseApi) PageWebsiteSSL(c *gin.Context) {
// @Tags Website SSL // @Tags Website SSL
// @Summary Create website ssl // @Summary Create website ssl
// @Description 创建网站 ssl
// @Accept json // @Accept json
// @Param request body request.WebsiteSSLCreate true "request" // @Param request body request.WebsiteSSLCreate true "request"
// @Success 200 {object} request.WebsiteSSLCreate // @Success 200 {object} request.WebsiteSSLCreate
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/ssl [post] // @Router /websites/ssl [post]
// @x-panel-log {"bodyKeys":["primaryDomain"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建网站 ssl [primaryDomain]","formatEN":"Create website ssl [primaryDomain]"} // @x-panel-log {"bodyKeys":["primaryDomain"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建网站 ssl [primaryDomain]","formatEN":"Create website ssl [primaryDomain]"}
func (b *BaseApi) CreateWebsiteSSL(c *gin.Context) { func (b *BaseApi) CreateWebsiteSSL(c *gin.Context) {
@@ -69,33 +66,33 @@ func (b *BaseApi) CreateWebsiteSSL(c *gin.Context) {
} }
// @Tags Website SSL // @Tags Website SSL
// @Summary Apply ssl // @Summary Reset website ssl
// @Description 重置网站 ssl
// @Accept json // @Accept json
// @Param request body request.WebsiteSSLApply true "request" // @Param request body request.WebsiteSSLRenew true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /websites/ssl/renew [post]
// @Router /websites/ssl/obtain [post] // @x-panel-log {"bodyKeys":["SSLId"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"SSLId","isList":false,"db":"website_ssls","output_column":"primary_domain","output_value":"domain"}],"formatZH":"重置 ssl [domain]","formatEN":"Renew ssl [domain]"}
// @x-panel-log {"bodyKeys":["ID"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ID","isList":false,"db":"website_ssls","output_column":"primary_domain","output_value":"domain"}],"formatZH":"申请证书 [domain]","formatEN":"apply ssl [domain]"} func (b *BaseApi) RenewWebsiteSSL(c *gin.Context) {
func (b *BaseApi) ApplyWebsiteSSL(c *gin.Context) { var req request.WebsiteSSLRenew
var req request.WebsiteSSLApply
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }
if err := websiteSSLService.ObtainSSL(req); err != nil { if err := websiteSSLService.Renew(req.SSLID); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
} }
helper.SuccessWithOutData(c) helper.SuccessWithData(c, nil)
} }
// @Tags Website SSL // @Tags Website SSL
// @Summary Resolve website ssl // @Summary Resolve website ssl
// @Description 解析网站 ssl
// @Accept json // @Accept json
// @Param request body request.WebsiteDNSReq true "request" // @Param request body request.WebsiteDNSReq true "request"
// @Success 200 {array} response.WebsiteDNSRes // @Success 200 {array} response.WebsiteDNSRes
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/ssl/resolve [post] // @Router /websites/ssl/resolve [post]
func (b *BaseApi) GetDNSResolve(c *gin.Context) { func (b *BaseApi) GetDNSResolve(c *gin.Context) {
var req request.WebsiteDNSReq var req request.WebsiteDNSReq
@@ -112,19 +109,19 @@ func (b *BaseApi) GetDNSResolve(c *gin.Context) {
// @Tags Website SSL // @Tags Website SSL
// @Summary Delete website ssl // @Summary Delete website ssl
// @Description 删除网站 ssl
// @Accept json // @Accept json
// @Param request body request.WebsiteBatchDelReq true "request" // @Param request body request.WebsiteResourceReq true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/ssl/del [post] // @Router /websites/ssl/del [post]
// @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"website_ssls","output_column":"primary_domain","output_value":"domain"}],"formatZH":"删除 ssl [domain]","formatEN":"Delete ssl [domain]"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"website_ssls","output_column":"primary_domain","output_value":"domain"}],"formatZH":"删除 ssl [domain]","formatEN":"Delete ssl [domain]"}
func (b *BaseApi) DeleteWebsiteSSL(c *gin.Context) { func (b *BaseApi) DeleteWebsiteSSL(c *gin.Context) {
var req request.WebsiteBatchDelReq var req request.WebsiteResourceReq
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }
if err := websiteSSLService.Delete(req.IDs); err != nil { if err := websiteSSLService.Delete(req.ID); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
} }
@@ -133,12 +130,12 @@ func (b *BaseApi) DeleteWebsiteSSL(c *gin.Context) {
// @Tags Website SSL // @Tags Website SSL
// @Summary Search website ssl by website id // @Summary Search website ssl by website id
// @Description 通过网站 id 查询 ssl
// @Accept json // @Accept json
// @Param websiteId path integer true "request" // @Param websiteId path integer true "request"
// @Success 200 {object} response.WebsiteSSLDTO // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /websites/ssl/website/:websiteId [get]
// @Router /websites/ssl/website/{websiteId} [get]
func (b *BaseApi) GetWebsiteSSLByWebsiteId(c *gin.Context) { func (b *BaseApi) GetWebsiteSSLByWebsiteId(c *gin.Context) {
websiteId, err := helper.GetIntParamByKey(c, "websiteId") websiteId, err := helper.GetIntParamByKey(c, "websiteId")
if err != nil { if err != nil {
@@ -155,12 +152,12 @@ func (b *BaseApi) GetWebsiteSSLByWebsiteId(c *gin.Context) {
// @Tags Website SSL // @Tags Website SSL
// @Summary Search website ssl by id // @Summary Search website ssl by id
// @Description 通过 id 查询 ssl
// @Accept json // @Accept json
// @Param id path integer true "request" // @Param id path integer true "request"
// @Success 200 {object} response.WebsiteSSLDTO // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Router /websites/ssl/:id [get]
// @Router /websites/ssl/{id} [get]
func (b *BaseApi) GetWebsiteSSLById(c *gin.Context) { func (b *BaseApi) GetWebsiteSSLById(c *gin.Context) {
id, err := helper.GetParamID(c) id, err := helper.GetParamID(c)
if err != nil { if err != nil {
@@ -176,12 +173,12 @@ func (b *BaseApi) GetWebsiteSSLById(c *gin.Context) {
} }
// @Tags Website SSL // @Tags Website SSL
// @Summary Update Website ssl // @Summary Update ssl
// @Description 更新 ssl
// @Accept json // @Accept json
// @Param request body request.WebsiteSSLUpdate true "request" // @Param request body request.WebsiteSSLUpdate true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/ssl/update [post] // @Router /websites/ssl/update [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"website_ssls","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新证书设置 [domain]","formatEN":"Update ssl config [domain]"} // @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"website_ssls","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新证书设置 [domain]","formatEN":"Update ssl config [domain]"}
func (b *BaseApi) UpdateWebsiteSSL(c *gin.Context) { func (b *BaseApi) UpdateWebsiteSSL(c *gin.Context) {
@@ -197,12 +194,12 @@ func (b *BaseApi) UpdateWebsiteSSL(c *gin.Context) {
} }
// @Tags Website SSL // @Tags Website SSL
// @Summary Upload Website ssl // @Summary Upload ssl
// @Description 上传 ssl
// @Accept json // @Accept json
// @Param request body request.WebsiteSSLUpload true "request" // @Param request body request.WebsiteSSLUpload true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/ssl/upload [post] // @Router /websites/ssl/upload [post]
// @x-panel-log {"bodyKeys":["type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"上传 ssl [type]","formatEN":"Upload ssl [type]"} // @x-panel-log {"bodyKeys":["type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"上传 ssl [type]","formatEN":"Upload ssl [type]"}
func (b *BaseApi) UploadWebsiteSSL(c *gin.Context) { func (b *BaseApi) UploadWebsiteSSL(c *gin.Context) {
@@ -216,33 +213,3 @@ func (b *BaseApi) UploadWebsiteSSL(c *gin.Context) {
} }
helper.SuccessWithData(c, nil) helper.SuccessWithData(c, nil)
} }
// @Tags Website SSL
// @Summary Download SSL file
// @Accept json
// @Param request body request.WebsiteResourceReq true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/ssl/download [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"website_ssls","output_column":"primary_domain","output_value":"domain"}],"formatZH":"下载证书文件 [domain]","formatEN":"download ssl file [domain]"}
func (b *BaseApi) DownloadWebsiteSSL(c *gin.Context) {
var req request.WebsiteResourceReq
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
file, err := websiteSSLService.DownloadFile(req.ID)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
defer file.Close()
info, err := file.Stat()
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
c.Header("Content-Length", strconv.FormatInt(info.Size(), 10))
c.Header("Content-Disposition", "attachment; filename*=utf-8''"+url.PathEscape(info.Name()))
http.ServeContent(c.Writer, c.Request, info.Name(), info.ModTime(), file)
}
-45
View File
@@ -1,45 +0,0 @@
package dto
import "time"
type OllamaModelInfo struct {
ID uint `json:"id"`
Name string `json:"name"`
Size string `json:"size"`
From string `json:"from"`
LogFileExist bool `json:"logFileExist"`
Status string `json:"status"`
Message string `json:"message"`
CreatedAt time.Time `json:"createdAt"`
}
type OllamaModelDropList struct {
ID uint `json:"id"`
Name string `json:"name"`
}
type OllamaModelName struct {
Name string `json:"name"`
}
type OllamaBindDomain struct {
Domain string `json:"domain" validate:"required"`
AppInstallID uint `json:"appInstallID" validate:"required"`
SSLID uint `json:"sslID"`
WebsiteID uint `json:"websiteID"`
IPList string `json:"ipList"`
}
type OllamaBindDomainReq struct {
AppInstallID uint `json:"appInstallID" validate:"required"`
}
type OllamaBindDomainRes struct {
Domain string `json:"domain"`
SSLID uint `json:"sslID"`
AcmeAccountID uint `json:"acmeAccountID"`
AllowIPs []string `json:"allowIPs"`
WebsiteID uint `json:"websiteID"`
ConnUrl string `json:"connUrl"`
}
-20
View File
@@ -1,20 +0,0 @@
package dto
type CreateOrUpdateAlert struct {
AlertTitle string `json:"alertTitle"`
AlertType string `json:"alertType"`
AlertCount uint `json:"alertCount"`
EntryID uint `json:"entryID"`
}
type AlertBase struct {
AlertType string `json:"alertType"`
EntryID uint `json:"entryID"`
}
type PushAlert struct {
TaskName string `json:"taskName"`
AlertType string `json:"alertType"`
EntryID uint `json:"entryID"`
Param string `json:"param"`
}
+13 -33
View File
@@ -1,5 +1,9 @@
package dto package dto
import (
"github.com/1Panel-dev/1Panel/backend/app/model"
)
type AppDatabase struct { type AppDatabase struct {
ServiceName string `json:"PANEL_DB_HOST"` ServiceName string `json:"PANEL_DB_HOST"`
DbName string `json:"PANEL_DB_NAME"` DbName string `json:"PANEL_DB_NAME"`
@@ -9,18 +13,12 @@ type AppDatabase struct {
type AuthParam struct { type AuthParam struct {
RootPassword string `json:"PANEL_DB_ROOT_PASSWORD"` RootPassword string `json:"PANEL_DB_ROOT_PASSWORD"`
RootUser string `json:"PANEL_DB_ROOT_USER"`
} }
type RedisAuthParam struct { type RedisAuthParam struct {
RootPassword string `json:"PANEL_REDIS_ROOT_PASSWORD"` RootPassword string `json:"PANEL_REDIS_ROOT_PASSWORD"`
} }
type MinioAuthParam struct {
RootPassword string `json:"PANEL_MINIO_ROOT_PASSWORD"`
RootUser string `json:"PANEL_MINIO_ROOT_USER"`
}
type ContainerExec struct { type ContainerExec struct {
ContainerName string `json:"containerName"` ContainerName string `json:"containerName"`
DbParam AppDatabase `json:"dbParam"` DbParam AppDatabase `json:"dbParam"`
@@ -33,9 +31,8 @@ type AppOssConfig struct {
} }
type AppVersion struct { type AppVersion struct {
Version string `json:"version"` Version string `json:"version"`
DetailId uint `json:"detailId"` DetailId uint `json:"detailId"`
DockerCompose string `json:"dockerCompose"`
} }
type AppList struct { type AppList struct {
@@ -58,7 +55,7 @@ type AppDefine struct {
} }
type LocalAppAppDefine struct { type LocalAppAppDefine struct {
AppProperty AppProperty `json:"additionalProperties" yaml:"additionalProperties"` AppProperty model.App `json:"additionalProperties" yaml:"additionalProperties"`
} }
type LocalAppParam struct { type LocalAppParam struct {
@@ -78,9 +75,8 @@ type AppProperty struct {
Name string `json:"name"` Name string `json:"name"`
Type string `json:"type"` Type string `json:"type"`
Tags []string `json:"tags"` Tags []string `json:"tags"`
ShortDescZh string `json:"shortDescZh" yaml:"shortDescZh"` ShortDescZh string `json:"shortDescZh"`
ShortDescEn string `json:"shortDescEn" yaml:"shortDescEn"` ShortDescEn string `json:"shortDescEn"`
Description Locale `json:"description"`
Key string `json:"key"` Key string `json:"key"`
Required []string `json:"Required"` Required []string `json:"Required"`
CrossVersionUpdate bool `json:"crossVersionUpdate"` CrossVersionUpdate bool `json:"crossVersionUpdate"`
@@ -89,8 +85,6 @@ type AppProperty struct {
Website string `json:"website"` Website string `json:"website"`
Github string `json:"github"` Github string `json:"github"`
Document string `json:"document"` Document string `json:"document"`
Version float64 `json:"version"`
GpuSupport bool `json:"gpuSupport"`
} }
type AppConfigVersion struct { type AppConfigVersion struct {
@@ -102,33 +96,19 @@ type AppConfigVersion struct {
} }
type Tag struct { type Tag struct {
Key string `json:"key"` Key string `json:"key"`
Name string `json:"name"` Name string `json:"name"`
Sort int `json:"sort"` Sort int `json:"sort"`
Locales Locale `json:"locales"`
}
type Locale struct {
En string `json:"en"`
Ja string `json:"ja"`
Ms string `json:"ms"`
PtBr string `json:"pt-br" yaml:"pt-br"`
Ru string `json:"ru"`
ZhHant string `json:"zh-hant" yaml:"zh-hant"`
Zh string `json:"zh"`
Ko string `json:"ko"`
} }
type AppForm struct { type AppForm struct {
FormFields []AppFormFields `json:"formFields"` FormFields []AppFormFields `json:"formFields"`
SupportVersion float64 `json:"supportVersion"`
} }
type AppFormFields struct { type AppFormFields struct {
Type string `json:"type"` Type string `json:"type"`
LabelZh string `json:"labelZh"` LabelZh string `json:"labelZh"`
LabelEn string `json:"labelEn"` LabelEn string `json:"labelEn"`
Label Locale `json:"label"`
Required bool `json:"required"` Required bool `json:"required"`
Default interface{} `json:"default"` Default interface{} `json:"default"`
EnvKey string `json:"envKey"` EnvKey string `json:"envKey"`
+7 -11
View File
@@ -23,12 +23,13 @@ type MfaCredential struct {
} }
type Login struct { type Login struct {
Name string `json:"name" validate:"required"` Name string `json:"name" validate:"required"`
Password string `json:"password" validate:"required"` Password string `json:"password" validate:"required"`
Captcha string `json:"captcha"` IgnoreCaptcha bool `json:"ignoreCaptcha"`
CaptchaID string `json:"captchaID"` Captcha string `json:"captcha"`
AuthMethod string `json:"authMethod" validate:"required,oneof=jwt session"` CaptchaID string `json:"captchaID"`
Language string `json:"language" validate:"required,oneof=zh en tw ja ko ru ms 'pt-BR'"` AuthMethod string `json:"authMethod" validate:"required,oneof=jwt session"`
Language string `json:"language" validate:"required,oneof=zh en tw"`
} }
type MFALogin struct { type MFALogin struct {
@@ -37,8 +38,3 @@ type MFALogin struct {
Code string `json:"code" validate:"required"` Code string `json:"code" validate:"required"`
AuthMethod string `json:"authMethod"` AuthMethod string `json:"authMethod"`
} }
type LoginSetting struct {
NeedCaptcha bool `json:"needCaptcha"`
Language string `json:"language"`
}
+4 -24
View File
@@ -21,36 +21,21 @@ type BackupInfo struct {
Vars string `json:"vars"` Vars string `json:"vars"`
} }
type BackupFile struct {
ID uint `json:"id"`
Name string `json:"name"`
Size int64 `json:"size"`
}
type OneDriveInfo struct {
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret"`
RedirectUri string `json:"redirect_uri"`
}
type BackupSearchFile struct { type BackupSearchFile struct {
Type string `json:"type" validate:"required"` Type string `json:"type" validate:"required"`
} }
type CommonBackup struct { type CommonBackup struct {
Type string `json:"type" validate:"required,oneof=app mysql mariadb redis website postgresql"` Type string `json:"type" validate:"required,oneof=app mysql mariadb redis website"`
Name string `json:"name"` Name string `json:"name"`
DetailName string `json:"detailName"` DetailName string `json:"detailName"`
Secret string `json:"secret"`
FileName string `json:"fileName"`
} }
type CommonRecover struct { type CommonRecover struct {
Source string `json:"source" validate:"required,oneof=OSS S3 SFTP MINIO LOCAL COS KODO OneDrive WebDAV"` Source string `json:"source" validate:"required,oneof=OSS S3 SFTP MINIO LOCAL COS KODO OneDrive"`
Type string `json:"type" validate:"required,oneof=app mysql mariadb redis website postgresql"` Type string `json:"type" validate:"required,oneof=app mysql mariadb redis website"`
Name string `json:"name"` Name string `json:"name"`
DetailName string `json:"detailName"` DetailName string `json:"detailName"`
File string `json:"file"` File string `json:"file"`
Secret string `json:"secret"`
} }
type RecordSearch struct { type RecordSearch struct {
@@ -60,11 +45,6 @@ type RecordSearch struct {
DetailName string `json:"detailName"` DetailName string `json:"detailName"`
} }
type RecordSearchByCronjob struct {
PageInfo
CronjobID uint `json:"cronjobID" validate:"required"`
}
type BackupRecords struct { type BackupRecords struct {
ID uint `json:"id"` ID uint `json:"id"`
CreatedAt time.Time `json:"createdAt"` CreatedAt time.Time `json:"createdAt"`
@@ -75,7 +55,7 @@ type BackupRecords struct {
} }
type DownloadRecord struct { type DownloadRecord struct {
Source string `json:"source" validate:"required,oneof=OSS S3 SFTP MINIO LOCAL COS KODO OneDrive WebDAV"` Source string `json:"source" validate:"required,oneof=OSS S3 SFTP MINIO LOCAL COS KODO OneDrive"`
FileDir string `json:"fileDir" validate:"required"` FileDir string `json:"fileDir" validate:"required"`
FileName string `json:"fileName" validate:"required"` FileName string `json:"fileName" validate:"required"`
} }
-101
View File
@@ -1,101 +0,0 @@
package dto
import (
"time"
)
type SearchClamWithPage struct {
PageInfo
Info string `json:"info"`
OrderBy string `json:"orderBy" validate:"required,oneof=name status created_at"`
Order string `json:"order" validate:"required,oneof=null ascending descending"`
}
type ClamBaseInfo struct {
Version string `json:"version"`
IsActive bool `json:"isActive"`
IsExist bool `json:"isExist"`
FreshVersion string `json:"freshVersion"`
FreshIsActive bool `json:"freshIsActive"`
FreshIsExist bool `json:"freshIsExist"`
}
type ClamInfo struct {
ID uint `json:"id"`
CreatedAt time.Time `json:"createdAt"`
Name string `json:"name"`
Status string `json:"status"`
Path string `json:"path"`
InfectedStrategy string `json:"infectedStrategy"`
InfectedDir string `json:"infectedDir"`
LastHandleDate string `json:"lastHandleDate"`
Spec string `json:"spec"`
Description string `json:"description"`
AlertCount uint `json:"alertCount"`
}
type ClamLogSearch struct {
PageInfo
ClamID uint `json:"clamID"`
StartTime time.Time `json:"startTime"`
EndTime time.Time `json:"endTime"`
}
type ClamLogReq struct {
Tail string `json:"tail"`
ClamName string `json:"clamName"`
RecordName string `json:"recordName"`
}
type ClamFileReq struct {
Tail string `json:"tail"`
Name string `json:"name" validate:"required"`
}
type ClamLog struct {
Name string `json:"name"`
ScanDate string `json:"scanDate"`
ScanTime string `json:"scanTime"`
InfectedFiles string `json:"infectedFiles"`
TotalError string `json:"totalError"`
Status string `json:"status"`
}
type ClamCreate struct {
Name string `json:"name"`
Status string `json:"status"`
Path string `json:"path"`
InfectedStrategy string `json:"infectedStrategy"`
InfectedDir string `json:"infectedDir"`
Spec string `json:"spec"`
Description string `json:"description"`
AlertCount uint `json:"alertCount"`
AlertTitle string `json:"alertTitle"`
}
type ClamUpdate struct {
ID uint `json:"id"`
Name string `json:"name"`
Path string `json:"path"`
InfectedStrategy string `json:"infectedStrategy"`
InfectedDir string `json:"infectedDir"`
Spec string `json:"spec"`
Description string `json:"description"`
AlertCount uint `json:"alertCount"`
AlertTitle string `json:"alertTitle"`
}
type ClamUpdateStatus struct {
ID uint `json:"id"`
Status string `json:"status"`
}
type ClamDelete struct {
RemoveRecord bool `json:"removeRecord"`
RemoveInfected bool `json:"removeInfected"`
Ids []uint `json:"ids" validate:"required"`
}
+1 -10
View File
@@ -1,12 +1,9 @@
package dto package dto
type SearchCommandWithPage struct { type SearchCommandWithPage struct {
PageInfo SearchWithPage
OrderBy string `json:"orderBy" validate:"required,oneof=name command created_at"`
Order string `json:"order" validate:"required,oneof=null ascending descending"`
GroupID uint `json:"groupID"` GroupID uint `json:"groupID"`
Info string `json:"info"` Info string `json:"info"`
Name string `json:"name"`
} }
type CommandOperate struct { type CommandOperate struct {
@@ -30,9 +27,3 @@ type CommandTree struct {
Label string `json:"label"` Label string `json:"label"`
Children []CommandInfo `json:"children"` Children []CommandInfo `json:"children"`
} }
type RedisCommand struct {
ID uint `json:"id"`
Name string `json:"name"`
Command string `json:"command"`
}
+3 -15
View File
@@ -2,7 +2,9 @@ package dto
type SearchWithPage struct { type SearchWithPage struct {
PageInfo PageInfo
Info string `json:"info"` Info string `json:"info"`
OrderBy string `json:"orderBy"`
Order string `json:"order"`
} }
type PageInfo struct { type PageInfo struct {
@@ -39,21 +41,7 @@ type DeleteByName struct {
Name string `json:"name" validate:"required"` Name string `json:"name" validate:"required"`
} }
type UpdateByFile struct {
File string `json:"file"`
}
type UpdateByNameAndFile struct {
Name string `json:"name"`
File string `json:"file"`
}
type OperationWithNameAndType struct { type OperationWithNameAndType struct {
Name string `json:"name"` Name string `json:"name"`
Type string `json:"type" validate:"required"` Type string `json:"type" validate:"required"`
} }
type ForceDelete struct {
IDs []uint `json:"ids"`
ForceDelete bool `json:"forceDelete"`
}
+27 -66
View File
@@ -1,17 +1,14 @@
package dto package dto
import ( import "time"
"time"
)
type PageContainer struct { type PageContainer struct {
PageInfo PageInfo
Name string `json:"name"` Name string `json:"name"`
State string `json:"state" validate:"required,oneof=all created running paused restarting removing exited dead"` State string `json:"state" validate:"required,oneof=all created running paused restarting removing exited dead"`
OrderBy string `json:"orderBy" validate:"required,oneof=name state created_at"` OrderBy string `json:"orderBy"`
Order string `json:"order" validate:"required,oneof=null ascending descending"` Order string `json:"order"`
Filters string `json:"filters"` Filters string `json:"filters"`
ExcludeAppStore bool `json:"excludeAppStore"`
} }
type InspectReq struct { type InspectReq struct {
@@ -33,15 +30,11 @@ type ContainerInfo struct {
IsFromApp bool `json:"isFromApp"` IsFromApp bool `json:"isFromApp"`
IsFromCompose bool `json:"isFromCompose"` IsFromCompose bool `json:"isFromCompose"`
AppName string `json:"appName"`
AppInstallName string `json:"appInstallName"`
Websites []string `json:"websites"`
} }
type ResourceLimit struct { type ResourceLimit struct {
CPU int `json:"cpu"` CPU int `json:"cpu"`
Memory uint64 `json:"memory"` Memory int `json:"memory"`
} }
type ContainerOperate struct { type ContainerOperate struct {
@@ -50,8 +43,6 @@ type ContainerOperate struct {
Name string `json:"name" validate:"required"` Name string `json:"name" validate:"required"`
Image string `json:"image" validate:"required"` Image string `json:"image" validate:"required"`
Network string `json:"network"` Network string `json:"network"`
Ipv4 string `json:"ipv4"`
Ipv6 string `json:"ipv6"`
PublishAllPorts bool `json:"publishAllPorts"` PublishAllPorts bool `json:"publishAllPorts"`
ExposedPorts []PortHelper `json:"exposedPorts"` ExposedPorts []PortHelper `json:"exposedPorts"`
Tty bool `json:"tty"` Tty bool `json:"tty"`
@@ -61,7 +52,6 @@ type ContainerOperate struct {
CPUShares int64 `json:"cpuShares"` CPUShares int64 `json:"cpuShares"`
NanoCPUs float64 `json:"nanoCPUs"` NanoCPUs float64 `json:"nanoCPUs"`
Memory float64 `json:"memory"` Memory float64 `json:"memory"`
Privileged bool `json:"privileged"`
AutoRemove bool `json:"autoRemove"` AutoRemove bool `json:"autoRemove"`
Volumes []VolumeHelper `json:"volumes"` Volumes []VolumeHelper `json:"volumes"`
Labels []string `json:"labels"` Labels []string `json:"labels"`
@@ -102,7 +92,6 @@ type ContainerStats struct {
} }
type VolumeHelper struct { type VolumeHelper struct {
Type string `json:"type"`
SourceDir string `json:"sourceDir"` SourceDir string `json:"sourceDir"`
ContainerDir string `json:"containerDir"` ContainerDir string `json:"containerDir"`
Mode string `json:"mode"` Mode string `json:"mode"`
@@ -116,7 +105,7 @@ type PortHelper struct {
type ContainerOperation struct { type ContainerOperation struct {
Names []string `json:"names" validate:"required"` Names []string `json:"names" validate:"required"`
Operation string `json:"operation" validate:"required,oneof=up start stop restart kill pause unpause remove"` Operation string `json:"operation" validate:"required,oneof=start stop restart kill pause unpause remove"`
} }
type ContainerRename struct { type ContainerRename struct {
@@ -124,17 +113,8 @@ type ContainerRename struct {
NewName string `json:"newName" validate:"required"` NewName string `json:"newName" validate:"required"`
} }
type ContainerCommit struct {
ContainerId string `json:"containerID" validate:"required"`
ContainerName string `json:"containerName"`
NewImageName string `json:"newImageName"`
Comment string `json:"comment"`
Author string `json:"author"`
Pause bool `json:"pause"`
}
type ContainerPrune struct { type ContainerPrune struct {
PruneType string `json:"pruneType" validate:"required,oneof=container image volume network buildcache"` PruneType string `json:"pruneType" validate:"required,oneof=container image volume network"`
WithTagAll bool `json:"withTagAll"` WithTagAll bool `json:"withTagAll"`
} }
@@ -155,21 +135,13 @@ type Network struct {
Attachable bool `json:"attachable"` Attachable bool `json:"attachable"`
} }
type NetworkCreate struct { type NetworkCreate struct {
Name string `json:"name" validate:"required"` Name string `json:"name" validate:"required"`
Driver string `json:"driver" validate:"required"` Driver string `json:"driver" validate:"required"`
Options []string `json:"options"` Options []string `json:"options"`
Ipv4 bool `json:"ipv4"` Subnet string `json:"subnet"`
Subnet string `json:"subnet"` Gateway string `json:"gateway"`
Gateway string `json:"gateway"` IPRange string `json:"ipRange"`
IPRange string `json:"ipRange"` Labels []string `json:"labels"`
AuxAddress []SettingUpdate `json:"auxAddress"`
Ipv6 bool `json:"ipv6"`
SubnetV6 string `json:"subnetV6"`
GatewayV6 string `json:"gatewayV6"`
IPRangeV6 string `json:"ipRangeV6"`
AuxAddressV6 []SettingUpdate `json:"auxAddressV6"`
Labels []string `json:"labels"`
} }
type Volume struct { type Volume struct {
@@ -187,7 +159,6 @@ type VolumeCreate struct {
} }
type BatchDelete struct { type BatchDelete struct {
Force bool `json:"force"`
Names []string `json:"names" validate:"required"` Names []string `json:"names" validate:"required"`
} }
@@ -200,7 +171,6 @@ type ComposeInfo struct {
Workdir string `json:"workdir"` Workdir string `json:"workdir"`
Path string `json:"path"` Path string `json:"path"`
Containers []ComposeContainer `json:"containers"` Containers []ComposeContainer `json:"containers"`
Env []string `json:"env"`
} }
type ComposeContainer struct { type ComposeContainer struct {
ContainerID string `json:"containerID"` ContainerID string `json:"containerID"`
@@ -209,29 +179,20 @@ type ComposeContainer struct {
State string `json:"state"` State string `json:"state"`
} }
type ComposeCreate struct { type ComposeCreate struct {
Name string `json:"name"` Name string `json:"name"`
From string `json:"from" validate:"required,oneof=edit path template"` From string `json:"from" validate:"required,oneof=edit path template"`
File string `json:"file"` File string `json:"file"`
Path string `json:"path"` Path string `json:"path"`
Template uint `json:"template"` Template uint `json:"template"`
Env []string `json:"env"`
} }
type ComposeOperation struct { type ComposeOperation struct {
Name string `json:"name" validate:"required"` Name string `json:"name" validate:"required"`
Path string `json:"path"` Path string `json:"path" validate:"required"`
Operation string `json:"operation" validate:"required,oneof=up start stop down delete"` Operation string `json:"operation" validate:"required,oneof=start stop down"`
WithFile bool `json:"withFile"` WithFile bool `json:"withFile"`
} }
type ComposeUpdate struct { type ComposeUpdate struct {
Name string `json:"name" validate:"required"` Name string `json:"name" validate:"required"`
Path string `json:"path" validate:"required"` Path string `json:"path" validate:"required"`
Content string `json:"content" validate:"required"` Content string `json:"content" validate:"required"`
Env []string `json:"env"`
}
type ContainerLog struct {
Container string `json:"container" validate:"required"`
Since string `json:"since"`
Tail uint `json:"tail"`
ContainerType string `json:"containerType"`
} }
+56 -69
View File
@@ -1,63 +1,51 @@
package dto package dto
import ( import "time"
"time"
)
type PageCronjob struct {
PageInfo
Info string `json:"info"`
OrderBy string `json:"orderBy" validate:"required,oneof=name status created_at"`
Order string `json:"order" validate:"required,oneof=null ascending descending"`
}
type CronjobCreate struct { type CronjobCreate struct {
Name string `json:"name" validate:"required"` Name string `json:"name" validate:"required"`
Type string `json:"type" validate:"required"` Type string `json:"type" validate:"required"`
Spec string `json:"spec" validate:"required"` SpecType string `json:"specType" validate:"required"`
Week int `json:"week" validate:"number,max=6,min=0"`
Day int `json:"day" validate:"number"`
Hour int `json:"hour" validate:"number"`
Minute int `json:"minute" validate:"number"`
Second int `json:"second" validate:"number"`
Script string `json:"script"` Script string `json:"script"`
Command string `json:"command"`
ContainerName string `json:"containerName"` ContainerName string `json:"containerName"`
AppID string `json:"appID"` AppID string `json:"appID"`
Website string `json:"website"` Website string `json:"website"`
ExclusionRules string `json:"exclusionRules"` ExclusionRules string `json:"exclusionRules"`
DBType string `json:"dbType"`
DBName string `json:"dbName"` DBName string `json:"dbName"`
URL string `json:"url"` URL string `json:"url"`
SourceDir string `json:"sourceDir"` SourceDir string `json:"sourceDir"`
KeepLocal bool `json:"keepLocal"`
BackupAccounts string `json:"backupAccounts"` TargetDirID int `json:"targetDirID"`
DefaultDownload string `json:"defaultDownload"` RetainCopies int `json:"retainCopies" validate:"number,min=1"`
RetainCopies int `json:"retainCopies" validate:"number,min=1"`
Secret string `json:"secret"`
AlertCount uint `json:"alertCount"`
AlertTitle string `json:"alertTitle"`
} }
type CronjobUpdate struct { type CronjobUpdate struct {
ID uint `json:"id" validate:"required"` ID uint `json:"id" validate:"required"`
Type string `json:"type" validate:"required"` Name string `json:"name" validate:"required"`
Name string `json:"name" validate:"required"` SpecType string `json:"specType" validate:"required"`
Spec string `json:"spec" validate:"required"` Week int `json:"week" validate:"number,max=6,min=0"`
Day int `json:"day" validate:"number"`
Hour int `json:"hour" validate:"number"`
Minute int `json:"minute" validate:"number"`
Second int `json:"second" validate:"number"`
Script string `json:"script"` Script string `json:"script"`
Command string `json:"command"`
ContainerName string `json:"containerName"` ContainerName string `json:"containerName"`
AppID string `json:"appID"` AppID string `json:"appID"`
Website string `json:"website"` Website string `json:"website"`
ExclusionRules string `json:"exclusionRules"` ExclusionRules string `json:"exclusionRules"`
DBType string `json:"dbType"`
DBName string `json:"dbName"` DBName string `json:"dbName"`
URL string `json:"url"` URL string `json:"url"`
SourceDir string `json:"sourceDir"` SourceDir string `json:"sourceDir"`
KeepLocal bool `json:"keepLocal"`
BackupAccounts string `json:"backupAccounts"` TargetDirID int `json:"targetDirID"`
DefaultDownload string `json:"defaultDownload"` RetainCopies int `json:"retainCopies" validate:"number,min=1"`
RetainCopies int `json:"retainCopies" validate:"number,min=1"`
Secret string `json:"secret"`
AlertCount uint `json:"alertCount"`
AlertTitle string `json:"alertTitle"`
} }
type CronjobUpdateStatus struct { type CronjobUpdateStatus struct {
@@ -71,42 +59,41 @@ type CronjobDownload struct {
} }
type CronjobClean struct { type CronjobClean struct {
IsDelete bool `json:"isDelete"` CleanData bool `json:"cleanData"`
CleanData bool `json:"cleanData"` CronjobID uint `json:"cronjobID" validate:"required"`
CleanRemoteData bool `json:"cleanRemoteData"`
CronjobID uint `json:"cronjobID" validate:"required"`
} }
type CronjobBatchDelete struct { type CronjobBatchDelete struct {
CleanData bool `json:"cleanData"` CleanData bool `json:"cleanData"`
CleanRemoteData bool `json:"cleanRemoteData"` IDs []uint `json:"ids" validate:"required"`
IDs []uint `json:"ids" validate:"required"`
} }
type CronjobInfo struct { type CronjobInfo struct {
ID uint `json:"id"` ID uint `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Type string `json:"type"` Type string `json:"type"`
Spec string `json:"spec"` SpecType string `json:"specType"`
Week int `json:"week"`
Day int `json:"day"`
Hour int `json:"hour"`
Minute int `json:"minute"`
Second int `json:"second"`
Script string `json:"script"` Script string `json:"script"`
Command string `json:"command"` ContainerName string `json:"containerName"`
ContainerName string `json:"containerName"` AppID string `json:"appID"`
AppID string `json:"appID"` Website string `json:"website"`
Website string `json:"website"` ExclusionRules string `json:"exclusionRules"`
ExclusionRules string `json:"exclusionRules"` DBName string `json:"dbName"`
DBType string `json:"dbType"` URL string `json:"url"`
DBName string `json:"dbName"` SourceDir string `json:"sourceDir"`
URL string `json:"url"` KeepLocal bool `json:"keepLocal"`
SourceDir string `json:"sourceDir"` TargetDir string `json:"targetDir"`
BackupAccounts string `json:"backupAccounts"` TargetDirID int `json:"targetDirID"`
DefaultDownload string `json:"defaultDownload"` RetainCopies int `json:"retainCopies"`
RetainCopies int `json:"retainCopies"`
LastRecordTime string `json:"lastRecordTime"` LastRecordTime string `json:"lastRecordTime"`
Status string `json:"status"` Status string `json:"status"`
Secret string `json:"secret"`
AlertCount uint `json:"alertCount"`
} }
type SearchRecord struct { type SearchRecord struct {
@@ -118,12 +105,12 @@ type SearchRecord struct {
} }
type Record struct { type Record struct {
ID uint `json:"id"` ID uint `json:"id"`
StartTime string `json:"startTime"` StartTime time.Time `json:"startTime"`
Records string `json:"records"` Records string `json:"records"`
Status string `json:"status"` Status string `json:"status"`
Message string `json:"message"` Message string `json:"message"`
TargetPath string `json:"targetPath"` TargetPath string `json:"targetPath"`
Interval int `json:"interval"` Interval int `json:"interval"`
File string `json:"file"` File string `json:"file"`
} }
+5 -55
View File
@@ -16,31 +16,14 @@ type DashboardBase struct {
KernelArch string `json:"kernelArch"` KernelArch string `json:"kernelArch"`
KernelVersion string `json:"kernelVersion"` KernelVersion string `json:"kernelVersion"`
VirtualizationSystem string `json:"virtualizationSystem"` VirtualizationSystem string `json:"virtualizationSystem"`
IpV4Addr string `json:"ipv4Addr"`
SystemProxy string `json:"SystemProxy"` CPUCores int `json:"cpuCores"`
CPUCores int `json:"cpuCores"` CPULogicalCores int `json:"cpuLogicalCores"`
CPULogicalCores int `json:"cpuLogicalCores"` CPUModelName string `json:"cpuModelName"`
CPUModelName string `json:"cpuModelName"`
CurrentInfo DashboardCurrent `json:"currentInfo"` CurrentInfo DashboardCurrent `json:"currentInfo"`
} }
type OsInfo struct {
OS string `json:"os"`
Platform string `json:"platform"`
PlatformFamily string `json:"platformFamily"`
KernelArch string `json:"kernelArch"`
KernelVersion string `json:"kernelVersion"`
DiskSize int64 `json:"diskSize"`
}
type DashboardReq struct {
Scope string `json:"scope"`
IoOption string `json:"ioOption"`
NetOption string `json:"netOption"`
}
type DashboardCurrent struct { type DashboardCurrent struct {
Uptime uint64 `json:"uptime"` Uptime uint64 `json:"uptime"`
TimeSinceUptime string `json:"timeSinceUptime"` TimeSinceUptime string `json:"timeSinceUptime"`
@@ -60,12 +43,7 @@ type DashboardCurrent struct {
MemoryTotal uint64 `json:"memoryTotal"` MemoryTotal uint64 `json:"memoryTotal"`
MemoryAvailable uint64 `json:"memoryAvailable"` MemoryAvailable uint64 `json:"memoryAvailable"`
MemoryUsed uint64 `json:"memoryUsed"` MemoryUsed uint64 `json:"memoryUsed"`
MemoryUsedPercent float64 `json:"memoryUsedPercent"` MemoryUsedPercent float64 `json:"MemoryUsedPercent"`
SwapMemoryTotal uint64 `json:"swapMemoryTotal"`
SwapMemoryAvailable uint64 `json:"swapMemoryAvailable"`
SwapMemoryUsed uint64 `json:"swapMemoryUsed"`
SwapMemoryUsedPercent float64 `json:"swapMemoryUsedPercent"`
IOReadBytes uint64 `json:"ioReadBytes"` IOReadBytes uint64 `json:"ioReadBytes"`
IOWriteBytes uint64 `json:"ioWriteBytes"` IOWriteBytes uint64 `json:"ioWriteBytes"`
@@ -78,9 +56,6 @@ type DashboardCurrent struct {
NetBytesSent uint64 `json:"netBytesSent"` NetBytesSent uint64 `json:"netBytesSent"`
NetBytesRecv uint64 `json:"netBytesRecv"` NetBytesRecv uint64 `json:"netBytesRecv"`
GPUData []GPUInfo `json:"gpuData"`
XPUData []XPUInfo `json:"xpuData"`
ShotTime time.Time `json:"shotTime"` ShotTime time.Time `json:"shotTime"`
} }
@@ -98,28 +73,3 @@ type DiskInfo struct {
InodesFree uint64 `json:"inodesFree"` InodesFree uint64 `json:"inodesFree"`
InodesUsedPercent float64 `json:"inodesUsedPercent"` InodesUsedPercent float64 `json:"inodesUsedPercent"`
} }
type GPUInfo struct {
Index uint `json:"index"`
ProductName string `json:"productName"`
GPUUtil string `json:"gpuUtil"`
Temperature string `json:"temperature"`
PerformanceState string `json:"performanceState"`
PowerUsage string `json:"powerUsage"`
PowerDraw string `json:"powerDraw"`
MaxPowerLimit string `json:"maxPowerLimit"`
MemoryUsage string `json:"memoryUsage"`
MemUsed string `json:"memUsed"`
MemTotal string `json:"memTotal"`
FanSpeed string `json:"fanSpeed"`
}
type XPUInfo struct {
DeviceID int `json:"deviceID"`
DeviceName string `json:"deviceName"`
Memory string `json:"memory"`
Temperature string `json:"temperature"`
MemoryUsed string `json:"memoryUsed"`
Power string `json:"power"`
MemoryUtil string `json:"memoryUtil"`
}
+59 -101
View File
@@ -2,33 +2,12 @@ package dto
import "time" import "time"
// common
type DBConfUpdateByFile struct {
Type string `json:"type" validate:"required,oneof=mysql mariadb postgresql redis"`
Database string `json:"database" validate:"required"`
File string `json:"file"`
}
type ChangeDBInfo struct {
ID uint `json:"id"`
From string `json:"from" validate:"required,oneof=local remote"`
Type string `json:"type" validate:"required,oneof=mysql mariadb postgresql"`
Database string `json:"database" validate:"required"`
Value string `json:"value" validate:"required"`
}
type DBBaseInfo struct {
Name string `json:"name"`
ContainerName string `json:"containerName"`
Port int64 `json:"port"`
}
// mysql
type MysqlDBSearch struct { type MysqlDBSearch struct {
PageInfo PageInfo
Info string `json:"info"` Info string `json:"info"`
Database string `json:"database" validate:"required"` Database string `json:"database" validate:"required"`
OrderBy string `json:"orderBy" validate:"required,oneof=name created_at"` OrderBy string `json:"orderBy"`
Order string `json:"order" validate:"required,oneof=null ascending descending"` Order string `json:"order"`
} }
type MysqlDBInfo struct { type MysqlDBInfo struct {
@@ -41,7 +20,7 @@ type MysqlDBInfo struct {
Username string `json:"username"` Username string `json:"username"`
Password string `json:"password"` Password string `json:"password"`
Permission string `json:"permission"` Permission string `json:"permission"`
IsDelete bool `json:"isDelete"` BackupCount int `json:"backupCount"`
Description string `json:"description"` Description string `json:"description"`
} }
@@ -64,14 +43,6 @@ type MysqlDBCreate struct {
Description string `json:"description"` Description string `json:"description"`
} }
type BindUser struct {
Database string `json:"database" validate:"required"`
DB string `json:"db" validate:"required"`
Username string `json:"username" validate:"required"`
Password string `json:"password" validate:"required"`
Permission string `json:"permission" validate:"required"`
}
type MysqlLoadDB struct { type MysqlLoadDB struct {
From string `json:"from" validate:"required,oneof=local remote"` From string `json:"from" validate:"required,oneof=local remote"`
Type string `json:"type" validate:"required,oneof=mysql mariadb"` Type string `json:"type" validate:"required,oneof=mysql mariadb"`
@@ -131,7 +102,7 @@ type MysqlStatus struct {
} }
type MysqlVariables struct { type MysqlVariables struct {
BinlogCacheSize string `json:"binlog_cache_size"` BinlogCachSize string `json:"binlog_cache_size"`
InnodbBufferPoolSize string `json:"innodb_buffer_pool_size"` InnodbBufferPoolSize string `json:"innodb_buffer_pool_size"`
InnodbLogBufferSize string `json:"innodb_log_buffer_size"` InnodbLogBufferSize string `json:"innodb_log_buffer_size"`
JoinBufferSize string `json:"join_buffer_size"` JoinBufferSize string `json:"join_buffer_size"`
@@ -139,7 +110,7 @@ type MysqlVariables struct {
MaxConnections string `json:"max_connections"` MaxConnections string `json:"max_connections"`
MaxHeapTableSize string `json:"max_heap_table_size"` MaxHeapTableSize string `json:"max_heap_table_size"`
QueryCacheSize string `json:"query_cache_size"` QueryCacheSize string `json:"query_cache_size"`
QueryCacheType string `json:"query_cache_type"` QueryCache_type string `json:"query_cache_type"`
ReadBufferSize string `json:"read_buffer_size"` ReadBufferSize string `json:"read_buffer_size"`
ReadRndBufferSize string `json:"read_rnd_buffer_size"` ReadRndBufferSize string `json:"read_rnd_buffer_size"`
SortBufferSize string `json:"sort_buffer_size"` SortBufferSize string `json:"sort_buffer_size"`
@@ -162,29 +133,48 @@ type MysqlVariablesUpdateHelper struct {
Param string `json:"param"` Param string `json:"param"`
Value interface{} `json:"value"` Value interface{} `json:"value"`
} }
type MysqlConfUpdateByFile struct {
Type string `json:"type" validate:"required,oneof=mysql mariadb"`
Database string `json:"database" validate:"required"`
File string `json:"file"`
}
type ChangeDBInfo struct {
ID uint `json:"id"`
From string `json:"from" validate:"required,oneof=local remote"`
Type string `json:"type" validate:"required,oneof=mysql mariadb"`
Database string `json:"database" validate:"required"`
Value string `json:"value" validate:"required"`
}
type DBBaseInfo struct {
Name string `json:"name"`
ContainerName string `json:"containerName"`
Port int64 `json:"port"`
}
// redis // redis
type ChangeRedisPass struct { type ChangeRedisPass struct {
Database string `json:"database" validate:"required"` Value string `json:"value" validate:"required"`
Value string `json:"value"`
} }
type RedisConfUpdate struct { type RedisConfUpdate struct {
Database string `json:"database" validate:"required"`
Timeout string `json:"timeout"` Timeout string `json:"timeout"`
Maxclients string `json:"maxclients"` Maxclients string `json:"maxclients"`
Maxmemory string `json:"maxmemory"` Maxmemory string `json:"maxmemory"`
} }
type RedisConfPersistenceUpdate struct { type RedisConfPersistenceUpdate struct {
Database string `json:"database" validate:"required"`
Type string `json:"type" validate:"required,oneof=aof rbd"` Type string `json:"type" validate:"required,oneof=aof rbd"`
Appendonly string `json:"appendonly"` Appendonly string `json:"appendonly"`
Appendfsync string `json:"appendfsync"` Appendfsync string `json:"appendfsync"`
Save string `json:"save"` Save string `json:"save"`
} }
type RedisConfUpdateByFile struct {
File string `json:"file" validate:"required"`
RestartNow bool `json:"restartNow"`
}
type RedisConf struct { type RedisConf struct {
Database string `json:"database" validate:"required"`
Name string `json:"name"` Name string `json:"name"`
Port int64 `json:"port"` Port int64 `json:"port"`
ContainerName string `json:"containerName"` ContainerName string `json:"containerName"`
@@ -195,20 +185,18 @@ type RedisConf struct {
} }
type RedisPersistence struct { type RedisPersistence struct {
Database string `json:"database" validate:"required"`
Appendonly string `json:"appendonly"` Appendonly string `json:"appendonly"`
Appendfsync string `json:"appendfsync"` Appendfsync string `json:"appendfsync"`
Save string `json:"save"` Save string `json:"save"`
} }
type RedisStatus struct { type RedisStatus struct {
Database string `json:"database" validate:"required"`
TcpPort string `json:"tcp_port"` TcpPort string `json:"tcp_port"`
UptimeInDays string `json:"uptime_in_days"` UptimeInDays string `json:"uptime_in_days"`
ConnectedClients string `json:"connected_clients"` ConnectedClients string `json:"connected_clients"`
UsedMemory string `json:"used_memory"` UsedMemory string `json:"used_memory"`
UsedMemoryRss string `json:"used_memory_rss"` UsedMemory_rss string `json:"used_memory_rss"`
UsedMemoryPeak string `json:"used_memory_peak"` UsedMemory_peak string `json:"used_memory_peak"`
MemFragmentationRatio string `json:"mem_fragmentation_ratio"` MemFragmentationRatio string `json:"mem_fragmentation_ratio"`
TotalConnectionsReceived string `json:"total_connections_received"` TotalConnectionsReceived string `json:"total_connections_received"`
TotalCommandsProcessed string `json:"total_commands_processed"` TotalCommandsProcessed string `json:"total_commands_processed"`
@@ -219,14 +207,12 @@ type RedisStatus struct {
} }
type DatabaseFileRecords struct { type DatabaseFileRecords struct {
Database string `json:"database" validate:"required"`
FileName string `json:"fileName"` FileName string `json:"fileName"`
FileDir string `json:"fileDir"` FileDir string `json:"fileDir"`
CreatedAt string `json:"createdAt"` CreatedAt string `json:"createdAt"`
Size int `json:"size"` Size int `json:"size"`
} }
type RedisBackupRecover struct { type RedisBackupRecover struct {
Database string `json:"database" validate:"required"`
FileName string `json:"fileName"` FileName string `json:"fileName"`
FileDir string `json:"fileDir"` FileDir string `json:"fileDir"`
} }
@@ -236,29 +222,22 @@ type DatabaseSearch struct {
PageInfo PageInfo
Info string `json:"info"` Info string `json:"info"`
Type string `json:"type"` Type string `json:"type"`
OrderBy string `json:"orderBy" validate:"required,oneof=name created_at"` OrderBy string `json:"orderBy"`
Order string `json:"order" validate:"required,oneof=null ascending descending"` Order string `json:"order"`
} }
type DatabaseInfo struct { type DatabaseInfo struct {
ID uint `json:"id"` ID uint `json:"id"`
CreatedAt time.Time `json:"createdAt"` CreatedAt time.Time `json:"createdAt"`
Name string `json:"name" validate:"max=256"` Name string `json:"name" validate:"max=256"`
From string `json:"from"` From string `json:"from"`
Type string `json:"type"` Type string `json:"type"`
Version string `json:"version"` Version string `json:"version"`
Address string `json:"address"` Address string `json:"address"`
Port uint `json:"port"` Port uint `json:"port"`
Username string `json:"username"` Username string `json:"username"`
Password string `json:"password"` Password string `json:"password"`
Description string `json:"description"`
SSL bool `json:"ssl"`
RootCert string `json:"rootCert"`
ClientKey string `json:"clientKey"`
ClientCert string `json:"clientCert"`
SkipVerify bool `json:"skipVerify"`
Description string `json:"description"`
} }
type DatabaseOption struct { type DatabaseOption struct {
@@ -270,47 +249,26 @@ type DatabaseOption struct {
Address string `json:"address"` Address string `json:"address"`
} }
type DatabaseItem struct {
ID uint `json:"id"`
From string `json:"from"`
Database string `json:"database"`
Name string `json:"name"`
}
type DatabaseCreate struct { type DatabaseCreate struct {
Name string `json:"name" validate:"required,max=256"` Name string `json:"name" validate:"required,max=256"`
Type string `json:"type" validate:"required"` Type string `json:"type" validate:"required"`
From string `json:"from" validate:"required,oneof=local remote"` From string `json:"from" validate:"required,oneof=local remote"`
Version string `json:"version" validate:"required"` Version string `json:"version" validate:"required"`
Address string `json:"address"` Address string `json:"address"`
Port uint `json:"port"` Port uint `json:"port"`
Username string `json:"username" validate:"required"` Username string `json:"username" validate:"required"`
Password string `json:"password"` Password string `json:"password" validate:"required"`
SSL bool `json:"ssl"`
RootCert string `json:"rootCert"`
ClientKey string `json:"clientKey"`
ClientCert string `json:"clientCert"`
SkipVerify bool `json:"skipVerify"`
Description string `json:"description"` Description string `json:"description"`
} }
type DatabaseUpdate struct { type DatabaseUpdate struct {
ID uint `json:"id"` ID uint `json:"id"`
Type string `json:"type" validate:"required"` Type string `json:"type" validate:"required"`
Version string `json:"version" validate:"required"` Version string `json:"version" validate:"required"`
Address string `json:"address"` Address string `json:"address"`
Port uint `json:"port"` Port uint `json:"port"`
Username string `json:"username" validate:"required"` Username string `json:"username" validate:"required"`
Password string `json:"password"` Password string `json:"password" validate:"required"`
SSL bool `json:"ssl"`
RootCert string `json:"rootCert"`
ClientKey string `json:"clientKey"`
ClientCert string `json:"clientCert"`
SkipVerify bool `json:"skipVerify"`
Description string `json:"description"` Description string `json:"description"`
} }
-85
View File
@@ -1,85 +0,0 @@
package dto
import "time"
type PostgresqlDBSearch struct {
PageInfo
Info string `json:"info"`
Database string `json:"database" validate:"required"`
OrderBy string `json:"orderBy" validate:"required,oneof=name created_at"`
Order string `json:"order" validate:"required,oneof=null ascending descending"`
}
type PostgresqlDBInfo struct {
ID uint `json:"id"`
CreatedAt time.Time `json:"createdAt"`
Name string `json:"name"`
From string `json:"from"`
PostgresqlName string `json:"postgresqlName"`
Format string `json:"format"`
Username string `json:"username"`
Password string `json:"password"`
SuperUser bool `json:"superUser"`
IsDelete bool `json:"isDelete"`
Description string `json:"description"`
}
type PostgresqlOption struct {
ID uint `json:"id"`
From string `json:"from"`
Type string `json:"type"`
Database string `json:"database"`
Name string `json:"name"`
}
type PostgresqlDBCreate struct {
Name string `json:"name" validate:"required"`
From string `json:"from" validate:"required,oneof=local remote"`
Database string `json:"database" validate:"required"`
Format string `json:"format"`
Username string `json:"username" validate:"required"`
Password string `json:"password" validate:"required"`
SuperUser bool `json:"superUser"`
Description string `json:"description"`
}
type PostgresqlBindUser struct {
Name string `json:"name" validate:"required"`
Database string `json:"database" validate:"required"`
Username string `json:"username" validate:"required"`
Password string `json:"password" validate:"required"`
SuperUser bool `json:"superUser"`
}
type PostgresqlPrivileges struct {
Name string `json:"name" validate:"required"`
Database string `json:"database" validate:"required"`
Username string `json:"username" validate:"required"`
SuperUser bool `json:"superUser"`
}
type PostgresqlLoadDB struct {
From string `json:"from" validate:"required,oneof=local remote"`
Type string `json:"type" validate:"required,oneof=postgresql"`
Database string `json:"database" validate:"required"`
}
type PostgresqlDBDeleteCheck struct {
ID uint `json:"id" validate:"required"`
Type string `json:"type" validate:"required,oneof=postgresql"`
Database string `json:"database" validate:"required"`
}
type PostgresqlDBDelete struct {
ID uint `json:"id" validate:"required"`
Type string `json:"type" validate:"required,oneof=postgresql"`
Database string `json:"database" validate:"required"`
ForceDelete bool `json:"forceDelete"`
DeleteBackup bool `json:"deleteBackup"`
}
type PostgresqlConfUpdateByFile struct {
Type string `json:"type" validate:"required,oneof=postgresql mariadb"`
Database string `json:"database" validate:"required"`
File string `json:"file"`
}
-41
View File
@@ -1,41 +0,0 @@
package dto
type DeviceBaseInfo struct {
DNS []string `json:"dns"`
Hosts []HostHelper `json:"hosts"`
Hostname string `json:"hostname"`
TimeZone string `json:"timeZone"`
LocalTime string `json:"localTime"`
Ntp string `json:"ntp"`
User string `json:"user"`
SwapMemoryTotal uint64 `json:"swapMemoryTotal"`
SwapMemoryAvailable uint64 `json:"swapMemoryAvailable"`
SwapMemoryUsed uint64 `json:"swapMemoryUsed"`
MaxSize uint64 `json:"maxSize"`
SwapDetails []SwapHelper `json:"swapDetails"`
}
type HostHelper struct {
IP string `json:"ip"`
Host string `json:"host"`
}
type SwapHelper struct {
Path string `json:"path" validate:"required"`
Size uint64 `json:"size"`
Used string `json:"used"`
IsNew bool `json:"isNew"`
}
type TimeZoneOptions struct {
From string `json:"from"`
Zones []string `json:"zones"`
}
type ChangePasswd struct {
User string `json:"user"`
Passwd string `json:"passwd"`
}
-11
View File
@@ -14,11 +14,6 @@ type DaemonJsonConf struct {
IPTables bool `json:"iptables"` IPTables bool `json:"iptables"`
CgroupDriver string `json:"cgroupDriver"` CgroupDriver string `json:"cgroupDriver"`
Ipv6 bool `json:"ipv6"`
FixedCidrV6 string `json:"fixedCidrV6"`
Ip6Tables bool `json:"ip6Tables"`
Experimental bool `json:"experimental"`
LogMaxSize string `json:"logMaxSize"` LogMaxSize string `json:"logMaxSize"`
LogMaxFile string `json:"logMaxFile"` LogMaxFile string `json:"logMaxFile"`
} }
@@ -28,12 +23,6 @@ type LogOption struct {
LogMaxFile string `json:"logMaxFile"` LogMaxFile string `json:"logMaxFile"`
} }
type Ipv6Option struct {
FixedCidrV6 string `json:"fixedCidrV6"`
Ip6Tables bool `json:"ip6Tables" validate:"required"`
Experimental bool `json:"experimental"`
}
type DockerOperation struct { type DockerOperation struct {
Operation string `json:"operation" validate:"required,oneof=start restart stop"` Operation string `json:"operation" validate:"required,oneof=start restart stop"`
} }
-29
View File
@@ -1,29 +0,0 @@
package dto
type Fail2BanBaseInfo struct {
IsEnable bool `json:"isEnable"`
IsActive bool `json:"isActive"`
IsExist bool `json:"isExist"`
Version string `json:"version"`
Port int `json:"port"`
MaxRetry int `json:"maxRetry"`
BanTime string `json:"banTime"`
FindTime string `json:"findTime"`
BanAction string `json:"banAction"`
LogPath string `json:"logPath"`
}
type Fail2BanSearch struct {
Status string `json:"status" validate:"required,oneof=banned ignore"`
}
type Fail2BanUpdate struct {
Key string `json:"key" validate:"required,oneof=port bantime findtime maxretry banaction logpath"`
Value string `json:"value"`
}
type Fail2BanSet struct {
IPs []string `json:"ips"`
Operate string `json:"operate" validate:"required,oneof=banned ignore"`
}
+1 -13
View File
@@ -16,7 +16,7 @@ type RuleSearch struct {
} }
type FirewallOperation struct { type FirewallOperation struct {
Operation string `json:"operation" validate:"required,oneof=start stop restart disablePing enablePing"` Operation string `json:"operation" validate:"required,oneof=start stop disablePing enablePing"`
} }
type PortRuleOperate struct { type PortRuleOperate struct {
@@ -29,18 +29,6 @@ type PortRuleOperate struct {
Description string `json:"description"` Description string `json:"description"`
} }
type ForwardRuleOperate struct {
ForceDelete bool `json:"forceDelete"`
Rules []struct {
Operation string `json:"operation" validate:"required,oneof=add remove"`
Num string `json:"num"`
Protocol string `json:"protocol" validate:"required,oneof=tcp udp tcp/udp"`
Port string `json:"port" validate:"required"`
TargetIP string `json:"targetIP"`
TargetPort string `json:"targetPort" validate:"required"`
} `json:"rules"`
}
type UpdateFirewallDescription struct { type UpdateFirewallDescription struct {
Type string `json:"type"` Type string `json:"type"`
Address string `json:"address"` Address string `json:"address"`
-43
View File
@@ -1,43 +0,0 @@
package dto
import (
"time"
)
type FtpInfo struct {
ID uint `json:"id"`
CreatedAt time.Time `json:"createdAt"`
User string `json:"user"`
Password string `json:"password"`
Path string `json:"path"`
Status string `json:"status"`
Description string `json:"description"`
}
type FtpBaseInfo struct {
IsActive bool `json:"isActive"`
IsExist bool `json:"isExist"`
}
type FtpLogSearch struct {
PageInfo
User string `json:"user"`
Operation string `json:"operation"`
}
type FtpCreate struct {
User string `json:"user" validate:"required"`
Password string `json:"password" validate:"required"`
Path string `json:"path" validate:"required"`
Description string `json:"description"`
}
type FtpUpdate struct {
ID uint `json:"id"`
Password string `json:"password" validate:"required"`
Path string `json:"path" validate:"required"`
Status string `json:"status"`
Description string `json:"description"`
}
+1
View File
@@ -27,6 +27,7 @@ type ImagePull struct {
} }
type ImageTag struct { type ImageTag struct {
RepoID uint `json:"repoID"`
SourceID string `json:"sourceID" validate:"required"` SourceID string `json:"sourceID" validate:"required"`
TargetName string `json:"targetName" validate:"required"` TargetName string `json:"targetName" validate:"required"`
} }
+4 -4
View File
@@ -6,8 +6,8 @@ type ImageRepoCreate struct {
Name string `json:"name" validate:"required"` Name string `json:"name" validate:"required"`
DownloadUrl string `json:"downloadUrl"` DownloadUrl string `json:"downloadUrl"`
Protocol string `json:"protocol"` Protocol string `json:"protocol"`
Username string `json:"username"` Username string `json:"username" validate:"max=256"`
Password string `json:"password"` Password string `json:"password" validate:"max=256"`
Auth bool `json:"auth"` Auth bool `json:"auth"`
} }
@@ -15,8 +15,8 @@ type ImageRepoUpdate struct {
ID uint `json:"id"` ID uint `json:"id"`
DownloadUrl string `json:"downloadUrl"` DownloadUrl string `json:"downloadUrl"`
Protocol string `json:"protocol"` Protocol string `json:"protocol"`
Username string `json:"username"` Username string `json:"username" validate:"max=256"`
Password string `json:"password"` Password string `json:"password" validate:"max=256"`
Auth bool `json:"auth"` Auth bool `json:"auth"`
} }
-10
View File
@@ -1,10 +0,0 @@
package dto
type DockerComposeService struct {
Image string `yaml:"image"`
ContainerName string `yaml:"container_name"`
Restart string `yaml:"restart"`
Ports []string `yaml:"ports"`
Environment []string `yaml:"environment"`
Command []string `yaml:"command"`
}
+8 -26
View File
@@ -32,8 +32,6 @@ type AppContainerConfig struct {
EditCompose bool `json:"editCompose"` EditCompose bool `json:"editCompose"`
DockerCompose string `json:"dockerCompose"` DockerCompose string `json:"dockerCompose"`
HostMode bool `json:"hostMode"` HostMode bool `json:"hostMode"`
PullImage bool `json:"pullImage"`
GpuConfig bool `json:"gpuConfig"`
} }
type AppInstalledSearch struct { type AppInstalledSearch struct {
@@ -44,7 +42,6 @@ type AppInstalledSearch struct {
Update bool `json:"update"` Update bool `json:"update"`
Unused bool `json:"unused"` Unused bool `json:"unused"`
All bool `json:"all"` All bool `json:"all"`
Sync bool `json:"sync"`
} }
type AppInstalledInfo struct { type AppInstalledInfo struct {
@@ -62,24 +59,14 @@ type AppBackupDelete struct {
} }
type AppInstalledOperate struct { type AppInstalledOperate struct {
InstallId uint `json:"installId" validate:"required"` InstallId uint `json:"installId" validate:"required"`
BackupId uint `json:"backupId"` BackupId uint `json:"backupId"`
DetailId uint `json:"detailId"` DetailId uint `json:"detailId"`
Operate constant.AppOperate `json:"operate" validate:"required"` Operate constant.AppOperate `json:"operate" validate:"required"`
ForceDelete bool `json:"forceDelete"` ForceDelete bool `json:"forceDelete"`
DeleteBackup bool `json:"deleteBackup"` DeleteBackup bool `json:"deleteBackup"`
DeleteDB bool `json:"deleteDB"` DeleteDB bool `json:"deleteDB"`
Backup bool `json:"backup"` Backup bool `json:"backup"`
PullImage bool `json:"pullImage"`
DockerCompose string `json:"dockerCompose"`
}
type AppInstallUpgrade struct {
InstallID uint `json:"installId"`
DetailID uint `json:"detailId"`
Backup bool `json:"backup"`
PullImage bool `json:"pullImage"`
DockerCompose string `json:"dockerCompose"`
} }
type AppInstalledUpdate struct { type AppInstalledUpdate struct {
@@ -98,8 +85,3 @@ type PortUpdate struct {
Name string `json:"name"` Name string `json:"name"`
Port int64 `json:"port"` Port int64 `json:"port"`
} }
type AppUpdateVersion struct {
AppInstallID uint `json:"appInstallID" validate:"required"`
UpdateVersion string `json:"updateVersion"`
}

Some files were not shown because too many files have changed in this diff Show More