mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-03-14 01:34:47 +08:00
fix: 简化接口校验代码 (#2704)
This commit is contained in:
parent
63bbc0242c
commit
12dcb4d646
@ -25,10 +25,10 @@ type BaseApi struct{}
|
|||||||
// @Router /auth/login [post]
|
// @Router /auth/login [post]
|
||||||
func (b *BaseApi) Login(c *gin.Context) {
|
func (b *BaseApi) Login(c *gin.Context) {
|
||||||
var req dto.Login
|
var req dto.Login
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.AuthMethod != "jwt" && !req.IgnoreCaptcha {
|
if req.AuthMethod != "jwt" && !req.IgnoreCaptcha {
|
||||||
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)
|
||||||
@ -60,14 +60,10 @@ func (b *BaseApi) Login(c *gin.Context) {
|
|||||||
// @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 := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, 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 {
|
||||||
|
@ -8,7 +8,6 @@ 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"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -23,12 +22,7 @@ import (
|
|||||||
// @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) {
|
||||||
var req dto.BackupOperate
|
var req dto.BackupOperate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(req.Credential) != 0 {
|
if len(req.Credential) != 0 {
|
||||||
@ -65,12 +59,7 @@ func (b *BaseApi) CreateBackup(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(req.Credential) != 0 {
|
if len(req.Credential) != 0 {
|
||||||
@ -125,12 +114,7 @@ func (b *BaseApi) LoadOneDriveInfo(c *gin.Context) {
|
|||||||
// @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]"}
|
// @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 := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,8 +135,7 @@ func (b *BaseApi) DeleteBackup(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,12 +162,7 @@ func (b *BaseApi) SearchBackupRecords(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.DownloadRecord
|
var req dto.DownloadRecord
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,12 +185,7 @@ func (b *BaseApi) DownloadRecord(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.BatchDeleteReq
|
var req dto.BatchDeleteReq
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,14 +207,10 @@ func (b *BaseApi) DeleteBackupRecord(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.BackupOperate
|
var req dto.BackupOperate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(req.Credential) != 0 {
|
if len(req.Credential) != 0 {
|
||||||
credential, err := base64.StdEncoding.DecodeString(req.Credential)
|
credential, err := base64.StdEncoding.DecodeString(req.Credential)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -292,14 +261,10 @@ func (b *BaseApi) ListBackup(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := backupService.ListFiles(req)
|
data, err := backupService.ListFiles(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
@ -320,12 +285,7 @@ func (b *BaseApi) LoadFilesFromBackup(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,12 +325,7 @@ func (b *BaseApi) Backup(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.CommonRecover
|
var req dto.CommonRecover
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,12 +373,7 @@ func (b *BaseApi) Recover(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.CommonRecover
|
var req dto.CommonRecover
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ 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"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,14 +18,10 @@ import (
|
|||||||
// @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) {
|
||||||
var req dto.CommandOperate
|
var req dto.CommandOperate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := commandService.Create(req); err != nil {
|
if err := commandService.Create(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -44,8 +39,7 @@ func (b *BaseApi) CreateCommand(c *gin.Context) {
|
|||||||
// @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.SearchWithPage
|
var req dto.SearchWithPage
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,12 +82,7 @@ func (b *BaseApi) ListCommand(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.BatchDeleteReq
|
var req dto.BatchDeleteReq
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,12 +104,7 @@ func (b *BaseApi) DeleteCommand(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.CommandOperate
|
var req dto.CommandOperate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ 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"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,14 +18,10 @@ import (
|
|||||||
// @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) {
|
||||||
var req dto.ComposeTemplateCreate
|
var req dto.ComposeTemplateCreate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := composeTemplateService.Create(req); err != nil {
|
if err := composeTemplateService.Create(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -45,8 +40,7 @@ func (b *BaseApi) CreateComposeTemplate(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,12 +84,7 @@ func (b *BaseApi) ListComposeTemplate(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.BatchDeleteReq
|
var req dto.BatchDeleteReq
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,12 +106,7 @@ func (b *BaseApi) DeleteComposeTemplate(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ComposeTemplateUpdate
|
var req dto.ComposeTemplateUpdate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,12 +20,7 @@ import (
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,12 +62,7 @@ func (b *BaseApi) ListContainer(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,12 +88,7 @@ func (b *BaseApi) SearchCompose(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ComposeCreate
|
var req dto.ComposeCreate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,12 +111,7 @@ func (b *BaseApi) TestCompose(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ComposeCreate
|
var req dto.ComposeCreate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,12 +134,7 @@ func (b *BaseApi) CreateCompose(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ComposeOperation
|
var req dto.ComposeOperation
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,14 +156,10 @@ func (b *BaseApi) OperatorCompose(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ContainerOperate
|
var req dto.ContainerOperate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := containerService.ContainerUpdate(req); err != nil {
|
if err := containerService.ContainerUpdate(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -206,14 +177,10 @@ func (b *BaseApi) ContainerUpdate(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := containerService.ContainerInfo(req)
|
data, err := containerService.ContainerInfo(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
@ -242,12 +209,12 @@ func (b *BaseApi) LoadResourceLimit(c *gin.Context) {
|
|||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Router /containers/list/stats [get]
|
// @Router /containers/list/stats [get]
|
||||||
func (b *BaseApi) ContainerListStats(c *gin.Context) {
|
func (b *BaseApi) ContainerListStats(c *gin.Context) {
|
||||||
datas, err := containerService.ContainerListStats()
|
data, err := containerService.ContainerListStats()
|
||||||
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, datas)
|
helper.SuccessWithData(c, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container
|
// @Tags Container
|
||||||
@ -261,14 +228,10 @@ func (b *BaseApi) ContainerListStats(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ContainerOperate
|
var req dto.ContainerOperate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := containerService.ContainerCreate(req); err != nil {
|
if err := containerService.ContainerCreate(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -287,14 +250,10 @@ func (b *BaseApi) ContainerCreate(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ContainerUpgrade
|
var req dto.ContainerUpgrade
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := containerService.ContainerUpgrade(req); err != nil {
|
if err := containerService.ContainerUpgrade(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -313,14 +272,10 @@ func (b *BaseApi) ContainerUpgrade(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ContainerPrune
|
var req dto.ContainerPrune
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
report, err := containerService.Prune(req)
|
report, err := containerService.Prune(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
@ -340,14 +295,10 @@ func (b *BaseApi) ContainerPrune(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.OperationWithName
|
var req dto.OperationWithName
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := containerService.ContainerLogClean(req); err != nil {
|
if err := containerService.ContainerLogClean(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -365,10 +316,10 @@ func (b *BaseApi) CleanContainerLog(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
content := containerService.LoadContainerLogs(req)
|
content := containerService.LoadContainerLogs(req)
|
||||||
helper.SuccessWithData(c, content)
|
helper.SuccessWithData(c, content)
|
||||||
}
|
}
|
||||||
@ -384,14 +335,10 @@ func (b *BaseApi) LoadContainerLog(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ContainerRename
|
var req dto.ContainerRename
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := containerService.ContainerRename(req); err != nil {
|
if err := containerService.ContainerRename(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -410,14 +357,10 @@ func (b *BaseApi) ContainerRename(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ContainerOperation
|
var req dto.ContainerOperation
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := containerService.ContainerOperation(req); err != nil {
|
if err := containerService.ContainerOperation(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -457,12 +400,7 @@ func (b *BaseApi) ContainerStats(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -513,12 +451,7 @@ func (b *BaseApi) ContainerLogs(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -561,12 +494,7 @@ func (b *BaseApi) ListNetwork(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.BatchDelete
|
var req dto.BatchDelete
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -588,12 +516,7 @@ func (b *BaseApi) DeleteNetwork(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.NetworkCreate
|
var req dto.NetworkCreate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,12 +538,7 @@ func (b *BaseApi) CreateNetwork(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -663,12 +581,7 @@ func (b *BaseApi) ListVolume(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.BatchDelete
|
var req dto.BatchDelete
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -690,12 +603,7 @@ func (b *BaseApi) DeleteVolume(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.VolumeCreate
|
var req dto.VolumeCreate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -717,12 +625,7 @@ func (b *BaseApi) CreateVolume(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ComposeUpdate
|
var req dto.ComposeUpdate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ 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/1Panel-dev/1Panel/backend/utils/common"
|
"github.com/1Panel-dev/1Panel/backend/utils/common"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
@ -22,14 +21,10 @@ import (
|
|||||||
// @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) {
|
||||||
var req dto.CronjobCreate
|
var req dto.CronjobCreate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := cronjobService.Create(req); err != nil {
|
if err := cronjobService.Create(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -47,8 +42,7 @@ func (b *BaseApi) CreateCronjob(c *gin.Context) {
|
|||||||
// @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.SearchWithPage
|
var req dto.SearchWithPage
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,10 +68,10 @@ func (b *BaseApi) SearchCronjob(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
loc, _ := time.LoadLocation(common.LoadTimeZone())
|
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)
|
||||||
@ -104,8 +98,7 @@ func (b *BaseApi) SearchJobRecords(c *gin.Context) {
|
|||||||
// @Router /cronjob/record/log [post]
|
// @Router /cronjob/record/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 := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
content, err := cronjobService.LoadRecordLog(req)
|
content, err := cronjobService.LoadRecordLog(req)
|
||||||
@ -127,8 +120,7 @@ func (b *BaseApi) LoadRecordLog(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.CronjobClean
|
var req dto.CronjobClean
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,12 +143,7 @@ func (b *BaseApi) CleanRecord(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.CronjobBatchDelete
|
var req dto.CronjobBatchDelete
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,12 +165,7 @@ func (b *BaseApi) DeleteCronjob(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.CronjobUpdate
|
var req dto.CronjobUpdate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,12 +187,7 @@ func (b *BaseApi) UpdateCronjob(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.CronjobUpdateStatus
|
var req dto.CronjobUpdateStatus
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,12 +209,7 @@ func (b *BaseApi) UpdateCronjobStatus(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.CronjobDownload
|
var req dto.CronjobDownload
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,12 +233,7 @@ func (b *BaseApi) TargetDownload(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.OperateByID
|
var req dto.OperateByID
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ 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"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,14 +18,10 @@ import (
|
|||||||
// @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) {
|
||||||
var req dto.DatabaseCreate
|
var req dto.DatabaseCreate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
return
|
return
|
||||||
@ -45,14 +40,10 @@ func (b *BaseApi) CreateDatabase(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.DatabaseCreate
|
var req dto.DatabaseCreate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, databaseService.CheckDatabase(req))
|
helper.SuccessWithData(c, databaseService.CheckDatabase(req))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,8 +57,7 @@ func (b *BaseApi) CheckDatabase(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,12 +125,7 @@ func (b *BaseApi) GetDatabase(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,12 +148,7 @@ func (b *BaseApi) DeleteCheckDatabase(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.DatabaseDelete
|
var req dto.DatabaseDelete
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,12 +170,7 @@ func (b *BaseApi) DeleteDatabase(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.DatabaseUpdate
|
var req dto.DatabaseUpdate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ 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"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -22,14 +21,10 @@ import (
|
|||||||
// @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) {
|
||||||
var req dto.MysqlDBCreate
|
var req dto.MysqlDBCreate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(req.Password) != 0 {
|
if len(req.Password) != 0 {
|
||||||
password, err := base64.StdEncoding.DecodeString(req.Password)
|
password, err := base64.StdEncoding.DecodeString(req.Password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -57,14 +52,10 @@ func (b *BaseApi) CreateMysql(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.UpdateDescription
|
var req dto.UpdateDescription
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := mysqlService.UpdateDescription(req); err != nil {
|
if err := mysqlService.UpdateDescription(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -83,14 +74,10 @@ func (b *BaseApi) UpdateMysqlDescription(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ChangeDBInfo
|
var req dto.ChangeDBInfo
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(req.Value) != 0 {
|
if len(req.Value) != 0 {
|
||||||
value, err := base64.StdEncoding.DecodeString(req.Value)
|
value, err := base64.StdEncoding.DecodeString(req.Value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -118,14 +105,10 @@ func (b *BaseApi) ChangeMysqlPassword(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ChangeDBInfo
|
var req dto.ChangeDBInfo
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := mysqlService.ChangeAccess(req); err != nil {
|
if err := mysqlService.ChangeAccess(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -144,8 +127,7 @@ func (b *BaseApi) ChangeMysqlAccess(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.MysqlVariablesUpdate
|
var req dto.MysqlVariablesUpdate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,12 +149,7 @@ func (b *BaseApi) UpdateMysqlVariables(c *gin.Context) {
|
|||||||
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 mysql 数据库配置信息","formatEN":"update the mysql database configuration information"}
|
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 mysql 数据库配置信息","formatEN":"update the mysql database configuration information"}
|
||||||
func (b *BaseApi) UpdateMysqlConfByFile(c *gin.Context) {
|
func (b *BaseApi) UpdateMysqlConfByFile(c *gin.Context) {
|
||||||
var req dto.MysqlConfUpdateByFile
|
var req dto.MysqlConfUpdateByFile
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,8 +171,7 @@ func (b *BaseApi) UpdateMysqlConfByFile(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,14 +214,10 @@ func (b *BaseApi) ListDBName(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := mysqlService.LoadFromRemote(req); err != nil {
|
if err := mysqlService.LoadFromRemote(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -264,12 +236,7 @@ func (b *BaseApi) LoadDBFromRemote(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,12 +259,7 @@ func (b *BaseApi) DeleteCheckMysql(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.MysqlDBDelete
|
var req dto.MysqlDBDelete
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,10 +283,10 @@ func (b *BaseApi) DeleteMysql(c *gin.Context) {
|
|||||||
// @Router /databases/baseinfo [post]
|
// @Router /databases/baseinfo [post]
|
||||||
func (b *BaseApi) LoadBaseinfo(c *gin.Context) {
|
func (b *BaseApi) LoadBaseinfo(c *gin.Context) {
|
||||||
var req dto.OperationWithNameAndType
|
var req dto.OperationWithNameAndType
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := mysqlService.LoadBaseInfo(req)
|
data, err := mysqlService.LoadBaseInfo(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
@ -344,10 +306,10 @@ func (b *BaseApi) LoadBaseinfo(c *gin.Context) {
|
|||||||
// @Router /databases/load/file [post]
|
// @Router /databases/load/file [post]
|
||||||
func (b *BaseApi) LoadDatabaseFile(c *gin.Context) {
|
func (b *BaseApi) LoadDatabaseFile(c *gin.Context) {
|
||||||
var req dto.OperationWithNameAndType
|
var req dto.OperationWithNameAndType
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
content, err := mysqlService.LoadDatabaseFile(req)
|
content, err := mysqlService.LoadDatabaseFile(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
@ -366,10 +328,10 @@ func (b *BaseApi) LoadDatabaseFile(c *gin.Context) {
|
|||||||
// @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 := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
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)
|
||||||
@ -389,10 +351,10 @@ func (b *BaseApi) LoadRemoteAccess(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := mysqlService.LoadStatus(req)
|
data, err := mysqlService.LoadStatus(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
@ -412,10 +374,10 @@ func (b *BaseApi) LoadStatus(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := mysqlService.LoadVariables(req)
|
data, err := mysqlService.LoadVariables(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
|
@ -9,7 +9,6 @@ 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/1Panel-dev/1Panel/backend/utils/compose"
|
"github.com/1Panel-dev/1Panel/backend/utils/compose"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
@ -73,14 +72,10 @@ func (b *BaseApi) LoadPersistenceConf(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.RedisConfUpdate
|
var req dto.RedisConfUpdate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBind(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := redisService.UpdateConf(req); err != nil {
|
if err := redisService.UpdateConf(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -99,14 +94,10 @@ func (b *BaseApi) UpdateRedisConf(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ChangeRedisPass
|
var req dto.ChangeRedisPass
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(req.Value) != 0 {
|
if len(req.Value) != 0 {
|
||||||
value, err := base64.StdEncoding.DecodeString(req.Value)
|
value, err := base64.StdEncoding.DecodeString(req.Value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -134,14 +125,10 @@ func (b *BaseApi) ChangeRedisPassword(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.RedisConfPersistenceUpdate
|
var req dto.RedisConfPersistenceUpdate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := redisService.UpdatePersistenceConf(req); err != nil {
|
if err := redisService.UpdatePersistenceConf(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -159,8 +146,7 @@ func (b *BaseApi) UpdateRedisPersistenceConf(c *gin.Context) {
|
|||||||
// @Router /databases/redis/backup/search [post]
|
// @Router /databases/redis/backup/search [post]
|
||||||
func (b *BaseApi) RedisBackupList(c *gin.Context) {
|
func (b *BaseApi) RedisBackupList(c *gin.Context) {
|
||||||
var req dto.PageInfo
|
var req dto.PageInfo
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,10 +173,10 @@ func (b *BaseApi) RedisBackupList(c *gin.Context) {
|
|||||||
// @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) UpdateRedisConfByFile(c *gin.Context) {
|
func (b *BaseApi) UpdateRedisConfByFile(c *gin.Context) {
|
||||||
var req dto.RedisConfUpdateByFile
|
var req dto.RedisConfUpdateByFile
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
redisInfo, err := redisService.LoadConf()
|
redisInfo, err := redisService.LoadConf()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
|
@ -6,7 +6,6 @@ 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"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -65,8 +64,7 @@ func (b *BaseApi) LoadDaemonJson(c *gin.Context) {
|
|||||||
// @x-panel-log {"bodyKeys":["key", "value"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 docker daemon.json 配置 [key]=>[value]","formatEN":"Updated the docker daemon.json configuration [key]=>[value]"}
|
// @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 := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,8 +87,7 @@ func (b *BaseApi) UpdateDaemonJson(c *gin.Context) {
|
|||||||
// @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":"更新 docker daemon.json 日志配置","formatEN":"Updated the docker daemon.json 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 := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBind(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,12 +110,7 @@ func (b *BaseApi) UpdateLogOption(c *gin.Context) {
|
|||||||
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 docker daemon.json 配置","formatEN":"Updated the docker daemon.json configuration"}
|
// @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 := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,12 +133,7 @@ func (b *BaseApi) UpdateDaemonJsonByFile(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.DockerOperation
|
var req dto.DockerOperation
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ 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"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -28,18 +27,13 @@ func (b *BaseApi) LoadFirewallBaseInfo(c *gin.Context) {
|
|||||||
// @Summary Page firewall rules
|
// @Summary Page firewall rules
|
||||||
// @Description 获取防火墙规则列表分页
|
// @Description 获取防火墙规则列表分页
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.SearchWithPage true "request"
|
// @Param request body dto.RuleSearch true "request"
|
||||||
// @Success 200 {object} dto.PageResult
|
// @Success 200 {object} dto.PageResult
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,12 +60,7 @@ func (b *BaseApi) SearchFirewallRule(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.FirewallOperation
|
var req dto.FirewallOperation
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,14 +83,10 @@ func (b *BaseApi) OperateFirewall(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.PortRuleOperate
|
var req dto.PortRuleOperate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := firewallService.OperatePortRule(req, true); err != nil {
|
if err := firewallService.OperatePortRule(req, true); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -120,14 +105,10 @@ func (b *BaseApi) OperatePortRule(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.AddrRuleOperate
|
var req dto.AddrRuleOperate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := firewallService.OperateAddressRule(req, true); err != nil {
|
if err := firewallService.OperateAddressRule(req, true); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -145,14 +126,10 @@ func (b *BaseApi) OperateIPRule(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := firewallService.BatchOperateRule(req); err != nil {
|
if err := firewallService.BatchOperateRule(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -170,14 +147,10 @@ func (b *BaseApi) BatchOperateRule(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := firewallService.UpdateDescription(req); err != nil {
|
if err := firewallService.UpdateDescription(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -195,14 +168,10 @@ func (b *BaseApi) UpdateFirewallDescription(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := firewallService.UpdatePortRule(req); err != nil {
|
if err := firewallService.UpdatePortRule(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -220,14 +189,10 @@ func (b *BaseApi) UpdatePortRule(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := firewallService.UpdateAddrRule(req); err != nil {
|
if err := firewallService.UpdateAddrRule(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
|
@ -4,7 +4,6 @@ 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"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,14 +18,10 @@ import (
|
|||||||
// @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) {
|
||||||
var req dto.GroupCreate
|
var req dto.GroupCreate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := groupService.Create(req); err != nil {
|
if err := groupService.Create(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -45,12 +40,7 @@ func (b *BaseApi) CreateGroup(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.OperateByID
|
var req dto.OperateByID
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,14 +62,10 @@ func (b *BaseApi) DeleteGroup(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.GroupUpdate
|
var req dto.GroupUpdate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := groupService.Update(req); err != nil {
|
if err := groupService.Update(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -97,12 +83,7 @@ func (b *BaseApi) UpdateGroup(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ 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/1Panel-dev/1Panel/backend/utils/encrypt"
|
"github.com/1Panel-dev/1Panel/backend/utils/encrypt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
@ -20,12 +19,7 @@ import (
|
|||||||
// @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) {
|
||||||
var req dto.HostOperate
|
var req dto.HostOperate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,12 +41,7 @@ func (b *BaseApi) CreateHost(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,8 +78,7 @@ func (b *BaseApi) TestByID(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBind(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,8 +101,7 @@ func (b *BaseApi) HostTree(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,12 +128,7 @@ func (b *BaseApi) SearchHost(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.BatchDeleteReq
|
var req dto.BatchDeleteReq
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,14 +150,10 @@ func (b *BaseApi) DeleteHost(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.HostOperate
|
var req dto.HostOperate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
if len(req.Password) != 0 && req.AuthMode == "password" {
|
if len(req.Password) != 0 && req.AuthMode == "password" {
|
||||||
req.Password, err = hostService.EncryptHost(req.Password)
|
req.Password, err = hostService.EncryptHost(req.Password)
|
||||||
@ -238,12 +216,7 @@ func (b *BaseApi) UpdateHost(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ChangeHostGroup
|
var req dto.ChangeHostGroup
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ 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"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,12 +18,7 @@ import (
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,12 +61,7 @@ func (b *BaseApi) ListImage(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ImageBuild
|
var req dto.ImageBuild
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,12 +85,7 @@ func (b *BaseApi) ImageBuild(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ImagePull
|
var req dto.ImagePull
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,12 +109,7 @@ func (b *BaseApi) ImagePull(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ImagePush
|
var req dto.ImagePush
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,12 +133,7 @@ func (b *BaseApi) ImagePush(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.BatchDelete
|
var req dto.BatchDelete
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,12 +156,7 @@ func (b *BaseApi) ImageRemove(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ImageSave
|
var req dto.ImageSave
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,12 +179,7 @@ func (b *BaseApi) ImageSave(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ImageTag
|
var req dto.ImageTag
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,12 +202,7 @@ func (b *BaseApi) ImageTag(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ImageLoad
|
var req dto.ImageLoad
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ 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"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,12 +18,7 @@ import (
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,14 +62,10 @@ func (b *BaseApi) ListRepo(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := imageRepoService.Login(req); err != nil {
|
if err := imageRepoService.Login(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -95,14 +85,10 @@ func (b *BaseApi) CheckRepoStatus(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ImageRepoCreate
|
var req dto.ImageRepoCreate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := imageRepoService.Create(req); err != nil {
|
if err := imageRepoService.Create(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -122,12 +108,7 @@ func (b *BaseApi) CreateRepo(c *gin.Context) {
|
|||||||
// @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]"}
|
// @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.ImageRepoDelete
|
var req dto.ImageRepoDelete
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,12 +131,7 @@ func (b *BaseApi) DeleteRepo(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.ImageRepoUpdate
|
var req dto.ImageRepoUpdate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ 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"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -18,8 +17,7 @@ import (
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,8 +43,7 @@ func (b *BaseApi) GetLoginLogs(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,12 +70,7 @@ func (b *BaseApi) GetOperationLogs(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.CleanLog
|
var req dto.CleanLog
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,10 +106,10 @@ func (b *BaseApi) GetSystemFiles(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := logService.LoadSystemLog(req.Name)
|
data, err := logService.LoadSystemLog(req.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
|
@ -17,14 +17,10 @@ import (
|
|||||||
|
|
||||||
func (b *BaseApi) LoadMonitor(c *gin.Context) {
|
func (b *BaseApi) LoadMonitor(c *gin.Context) {
|
||||||
var req dto.MonitorSearch
|
var req dto.MonitorSearch
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
loc, _ := time.LoadLocation(common.LoadTimeZone())
|
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)
|
||||||
|
@ -49,12 +49,7 @@ func (b *BaseApi) GetSystemAvailable(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.SettingUpdate
|
var req dto.SettingUpdate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,12 +71,7 @@ func (b *BaseApi) UpdateSetting(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.PasswordUpdate
|
var req dto.PasswordUpdate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,12 +93,7 @@ func (b *BaseApi) UpdatePassword(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.SSLUpdate
|
var req dto.SSLUpdate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,12 +162,7 @@ func (b *BaseApi) LoadInterfaceAddr(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.BindInfo
|
var req dto.BindInfo
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,12 +184,7 @@ func (b *BaseApi) UpdateBindInfo(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.PortUpdate
|
var req dto.PortUpdate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,12 +206,7 @@ func (b *BaseApi) UpdatePort(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.PasswordUpdate
|
var req dto.PasswordUpdate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,10 +243,10 @@ func (b *BaseApi) LoadTimeZone(c *gin.Context) {
|
|||||||
// @x-panel-log {"bodyKeys":["ntpSite"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"系统时间同步[ntpSite]","formatEN":"sync system time [ntpSite]"}
|
// @x-panel-log {"bodyKeys":["ntpSite"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"系统时间同步[ntpSite]","formatEN":"sync system time [ntpSite]"}
|
||||||
func (b *BaseApi) SyncTime(c *gin.Context) {
|
func (b *BaseApi) SyncTime(c *gin.Context) {
|
||||||
var req dto.SyncTime
|
var req dto.SyncTime
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := settingService.SyncTime(req); err != nil {
|
if err := settingService.SyncTime(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -340,10 +310,10 @@ func (b *BaseApi) ScanSystem(c *gin.Context) {
|
|||||||
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清理系统垃圾文件","formatEN":"Clean system junk files"}
|
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清理系统垃圾文件","formatEN":"Clean system junk files"}
|
||||||
func (b *BaseApi) SystemClean(c *gin.Context) {
|
func (b *BaseApi) SystemClean(c *gin.Context) {
|
||||||
var req []dto.Clean
|
var req []dto.Clean
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBind(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
settingService.SystemClean(req)
|
settingService.SystemClean(req)
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.SuccessWithData(c, nil)
|
||||||
@ -359,8 +329,7 @@ func (b *BaseApi) SystemClean(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -384,10 +353,10 @@ func (b *BaseApi) LoadMFA(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.MfaCredential
|
var req dto.MfaCredential
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
success := mfa.ValidCode(req.Code, req.Interval, req.Secret)
|
success := mfa.ValidCode(req.Code, req.Interval, req.Secret)
|
||||||
if !success {
|
if !success {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, errors.New("code is not valid"))
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, errors.New("code is not valid"))
|
||||||
|
@ -4,7 +4,6 @@ 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"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,14 +18,10 @@ import (
|
|||||||
// @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) {
|
||||||
var req dto.SnapshotCreate
|
var req dto.SnapshotCreate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := snapshotService.SnapshotCreate(req); err != nil {
|
if err := snapshotService.SnapshotCreate(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -45,14 +40,10 @@ func (b *BaseApi) CreateSnapshot(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.SnapshotImport
|
var req dto.SnapshotImport
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := snapshotService.SnapshotImport(req); err != nil {
|
if err := snapshotService.SnapshotImport(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -70,14 +61,10 @@ func (b *BaseApi) ImportSnapshot(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := snapshotService.LoadSnapShotStatus(req.ID)
|
data, err := snapshotService.LoadSnapShotStatus(req.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
@ -97,14 +84,10 @@ func (b *BaseApi) LoadSnapShotStatus(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.UpdateDescription
|
var req dto.UpdateDescription
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := snapshotService.UpdateDescription(req); err != nil {
|
if err := snapshotService.UpdateDescription(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -122,10 +105,10 @@ func (b *BaseApi) UpdateSnapDescription(c *gin.Context) {
|
|||||||
// @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.SearchWithPage
|
var req dto.SearchWithPage
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
total, accounts, err := snapshotService.SearchWithPage(req)
|
total, accounts, err := snapshotService.SearchWithPage(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
@ -148,12 +131,7 @@ func (b *BaseApi) SearchSnapshot(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.SnapshotRecover
|
var req dto.SnapshotRecover
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,12 +153,7 @@ func (b *BaseApi) RecoverSnapshot(c *gin.Context) {
|
|||||||
// @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) {
|
||||||
var req dto.SnapshotRecover
|
var req dto.SnapshotRecover
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,12 +175,7 @@ func (b *BaseApi) RollbackSnapshot(c *gin.Context) {
|
|||||||
// @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.BatchDeleteReq
|
var req dto.BatchDeleteReq
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ 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"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -33,12 +32,7 @@ func (b *BaseApi) GetSSHInfo(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,12 +54,7 @@ func (b *BaseApi) OperateSSH(c *gin.Context) {
|
|||||||
// @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.SettingUpdate
|
var req dto.SettingUpdate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,12 +76,7 @@ func (b *BaseApi) UpdateSSH(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,12 +98,7 @@ func (b *BaseApi) UpdateSSHByfile(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,12 +119,7 @@ func (b *BaseApi) GenerateSSH(c *gin.Context) {
|
|||||||
// @Router /host/ssh/secret [post]
|
// @Router /host/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 := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,12 +141,7 @@ func (b *BaseApi) LoadSSHSecret(c *gin.Context) {
|
|||||||
// @Router /host/ssh/log/analysis [post]
|
// @Router /host/ssh/log/analysis [post]
|
||||||
func (b *BaseApi) AnalysisLog(c *gin.Context) {
|
func (b *BaseApi) AnalysisLog(c *gin.Context) {
|
||||||
var req dto.SearchForAnalysis
|
var req dto.SearchForAnalysis
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,12 +163,7 @@ func (b *BaseApi) AnalysisLog(c *gin.Context) {
|
|||||||
// @Router /host/ssh/log [post]
|
// @Router /host/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 := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := global.VALID.Struct(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,10 +32,10 @@ func (b *BaseApi) GetUpgradeInfo(c *gin.Context) {
|
|||||||
// @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
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
notes, err := upgradeService.LoadNotes(req)
|
notes, err := upgradeService.LoadNotes(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
@ -55,10 +55,10 @@ func (b *BaseApi) GetNotesByVersion(c *gin.Context) {
|
|||||||
// @x-panel-log {"bodyKeys":["version"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新系统 => [version]","formatEN":"upgrade service => [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 := c.ShouldBindJSON(&req); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := upgradeService.Upgrade(req); err != nil {
|
if err := upgradeService.Upgrade(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
|
@ -12,19 +12,19 @@ type UserLoginInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type MfaRequest struct {
|
type MfaRequest struct {
|
||||||
Title string `json:"title"`
|
Title string `json:"title" validate:"required"`
|
||||||
Interval int `json:"interval"`
|
Interval int `json:"interval" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MfaCredential struct {
|
type MfaCredential struct {
|
||||||
Secret string `json:"secret"`
|
Secret string `json:"secret" validate:"required"`
|
||||||
Code string `json:"code"`
|
Code string `json:"code" validate:"required"`
|
||||||
Interval string `json:"interval"`
|
Interval string `json:"interval" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Login struct {
|
type Login struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name" validate:"required"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password" validate:"required"`
|
||||||
IgnoreCaptcha bool `json:"ignoreCaptcha"`
|
IgnoreCaptcha bool `json:"ignoreCaptcha"`
|
||||||
Captcha string `json:"captcha"`
|
Captcha string `json:"captcha"`
|
||||||
CaptchaID string `json:"captchaID"`
|
CaptchaID string `json:"captchaID"`
|
||||||
@ -33,8 +33,8 @@ type Login struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type MFALogin struct {
|
type MFALogin struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name" validate:"required"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password" validate:"required"`
|
||||||
Code string `json:"code"`
|
Code string `json:"code" validate:"required"`
|
||||||
AuthMethod string `json:"authMethod"`
|
AuthMethod string `json:"authMethod"`
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,8 @@ type PageContainer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type InspectReq struct {
|
type InspectReq struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id" validate:"required"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContainerInfo struct {
|
type ContainerInfo struct {
|
||||||
@ -40,8 +40,8 @@ type ResourceLimit struct {
|
|||||||
type ContainerOperate struct {
|
type ContainerOperate struct {
|
||||||
ContainerID string `json:"containerID"`
|
ContainerID string `json:"containerID"`
|
||||||
ForcePull bool `json:"forcePull"`
|
ForcePull bool `json:"forcePull"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name" validate:"required"`
|
||||||
Image string `json:"image"`
|
Image string `json:"image" validate:"required"`
|
||||||
Network string `json:"network"`
|
Network string `json:"network"`
|
||||||
PublishAllPorts bool `json:"publishAllPorts"`
|
PublishAllPorts bool `json:"publishAllPorts"`
|
||||||
ExposedPorts []PortHelper `json:"exposedPorts"`
|
ExposedPorts []PortHelper `json:"exposedPorts"`
|
||||||
@ -110,7 +110,7 @@ type ContainerOperation struct {
|
|||||||
|
|
||||||
type ContainerRename struct {
|
type ContainerRename struct {
|
||||||
Name string `json:"name" validate:"required"`
|
Name string `json:"name" validate:"required"`
|
||||||
NewName string `json:"newName"`
|
NewName string `json:"newName" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContainerPrune struct {
|
type ContainerPrune struct {
|
||||||
@ -135,8 +135,8 @@ type Network struct {
|
|||||||
Attachable bool `json:"attachable"`
|
Attachable bool `json:"attachable"`
|
||||||
}
|
}
|
||||||
type NetworkCreate struct {
|
type NetworkCreate struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name" validate:"required"`
|
||||||
Driver string `json:"driver"`
|
Driver string `json:"driver" validate:"required"`
|
||||||
Options []string `json:"options"`
|
Options []string `json:"options"`
|
||||||
Subnet string `json:"subnet"`
|
Subnet string `json:"subnet"`
|
||||||
Gateway string `json:"gateway"`
|
Gateway string `json:"gateway"`
|
||||||
@ -152,8 +152,8 @@ type Volume struct {
|
|||||||
CreatedAt time.Time `json:"createdAt"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
}
|
}
|
||||||
type VolumeCreate struct {
|
type VolumeCreate struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name" validate:"required"`
|
||||||
Driver string `json:"driver"`
|
Driver string `json:"driver" validate:"required"`
|
||||||
Options []string `json:"options"`
|
Options []string `json:"options"`
|
||||||
Labels []string `json:"labels"`
|
Labels []string `json:"labels"`
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ type CronjobClean struct {
|
|||||||
|
|
||||||
type CronjobBatchDelete struct {
|
type CronjobBatchDelete struct {
|
||||||
CleanData bool `json:"cleanData"`
|
CleanData bool `json:"cleanData"`
|
||||||
IDs []uint `json:"ids"`
|
IDs []uint `json:"ids" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CronjobInfo struct {
|
type CronjobInfo struct {
|
||||||
|
@ -170,7 +170,7 @@ type RedisConfPersistenceUpdate struct {
|
|||||||
Save string `json:"save"`
|
Save string `json:"save"`
|
||||||
}
|
}
|
||||||
type RedisConfUpdateByFile struct {
|
type RedisConfUpdateByFile struct {
|
||||||
File string `json:"file"`
|
File string `json:"file" validate:"required"`
|
||||||
RestartNow bool `json:"restartNow"`
|
RestartNow bool `json:"restartNow"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ type UpgradeInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SyncTime struct {
|
type SyncTime struct {
|
||||||
NtpSite string `json:"ntpSite"`
|
NtpSite string `json:"ntpSite" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type BindInfo struct {
|
type BindInfo struct {
|
||||||
@ -144,7 +144,7 @@ type BindInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Upgrade struct {
|
type Upgrade struct {
|
||||||
Version string `json:"version"`
|
Version string `json:"version" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CleanData struct {
|
type CleanData struct {
|
||||||
|
@ -7377,7 +7377,7 @@ const docTemplate = `{
|
|||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/dto.SearchWithPage"
|
"$ref": "#/definitions/dto.RuleSearch"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -12983,6 +12983,10 @@ const docTemplate = `{
|
|||||||
},
|
},
|
||||||
"dto.ContainerOperate": {
|
"dto.ContainerOperate": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"image",
|
||||||
|
"name"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"autoRemove": {
|
"autoRemove": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
@ -13122,7 +13126,8 @@ const docTemplate = `{
|
|||||||
"dto.ContainerRename": {
|
"dto.ContainerRename": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"name"
|
"name",
|
||||||
|
"newName"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"name": {
|
"name": {
|
||||||
@ -13182,6 +13187,9 @@ const docTemplate = `{
|
|||||||
},
|
},
|
||||||
"dto.CronjobBatchDelete": {
|
"dto.CronjobBatchDelete": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"ids"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"cleanData": {
|
"cleanData": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
@ -14272,6 +14280,10 @@ const docTemplate = `{
|
|||||||
},
|
},
|
||||||
"dto.InspectReq": {
|
"dto.InspectReq": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"type"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -14294,6 +14306,10 @@ const docTemplate = `{
|
|||||||
},
|
},
|
||||||
"dto.Login": {
|
"dto.Login": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"name",
|
||||||
|
"password"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"authMethod": {
|
"authMethod": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -14320,6 +14336,11 @@ const docTemplate = `{
|
|||||||
},
|
},
|
||||||
"dto.MFALogin": {
|
"dto.MFALogin": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"code",
|
||||||
|
"name",
|
||||||
|
"password"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"authMethod": {
|
"authMethod": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -14337,6 +14358,11 @@ const docTemplate = `{
|
|||||||
},
|
},
|
||||||
"dto.MfaCredential": {
|
"dto.MfaCredential": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"code",
|
||||||
|
"interval",
|
||||||
|
"secret"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"code": {
|
"code": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -14751,6 +14777,10 @@ const docTemplate = `{
|
|||||||
},
|
},
|
||||||
"dto.NetworkCreate": {
|
"dto.NetworkCreate": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"driver",
|
||||||
|
"name"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"driver": {
|
"driver": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -15111,6 +15141,9 @@ const docTemplate = `{
|
|||||||
},
|
},
|
||||||
"dto.RedisConfUpdateByFile": {
|
"dto.RedisConfUpdateByFile": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"file"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"file": {
|
"file": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -15189,6 +15222,34 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"dto.RuleSearch": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"page",
|
||||||
|
"pageSize",
|
||||||
|
"type"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"info": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"page": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"pageSize": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"strategy": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"dto.SSHConf": {
|
"dto.SSHConf": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -15706,6 +15767,9 @@ const docTemplate = `{
|
|||||||
},
|
},
|
||||||
"dto.SyncTime": {
|
"dto.SyncTime": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"ntpSite"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"ntpSite": {
|
"ntpSite": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -15770,6 +15834,9 @@ const docTemplate = `{
|
|||||||
},
|
},
|
||||||
"dto.Upgrade": {
|
"dto.Upgrade": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"version"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"version": {
|
"version": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -15806,6 +15873,10 @@ const docTemplate = `{
|
|||||||
},
|
},
|
||||||
"dto.VolumeCreate": {
|
"dto.VolumeCreate": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"driver",
|
||||||
|
"name"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"driver": {
|
"driver": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -16502,6 +16573,17 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"request.ExposedPort": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"containerPort": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"hostPort": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"request.FavoriteCreate": {
|
"request.FavoriteCreate": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
@ -17270,6 +17352,12 @@ const docTemplate = `{
|
|||||||
"codeDir": {
|
"codeDir": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"exposedPorts": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/request.ExposedPort"
|
||||||
|
}
|
||||||
|
},
|
||||||
"image": {
|
"image": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@ -17355,6 +17443,12 @@ const docTemplate = `{
|
|||||||
"codeDir": {
|
"codeDir": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"exposedPorts": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/request.ExposedPort"
|
||||||
|
}
|
||||||
|
},
|
||||||
"id": {
|
"id": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
@ -7370,7 +7370,7 @@
|
|||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/dto.SearchWithPage"
|
"$ref": "#/definitions/dto.RuleSearch"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -12976,6 +12976,10 @@
|
|||||||
},
|
},
|
||||||
"dto.ContainerOperate": {
|
"dto.ContainerOperate": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"image",
|
||||||
|
"name"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"autoRemove": {
|
"autoRemove": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
@ -13115,7 +13119,8 @@
|
|||||||
"dto.ContainerRename": {
|
"dto.ContainerRename": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"name"
|
"name",
|
||||||
|
"newName"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"name": {
|
"name": {
|
||||||
@ -13175,6 +13180,9 @@
|
|||||||
},
|
},
|
||||||
"dto.CronjobBatchDelete": {
|
"dto.CronjobBatchDelete": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"ids"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"cleanData": {
|
"cleanData": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
@ -14265,6 +14273,10 @@
|
|||||||
},
|
},
|
||||||
"dto.InspectReq": {
|
"dto.InspectReq": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"type"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -14287,6 +14299,10 @@
|
|||||||
},
|
},
|
||||||
"dto.Login": {
|
"dto.Login": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"name",
|
||||||
|
"password"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"authMethod": {
|
"authMethod": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -14313,6 +14329,11 @@
|
|||||||
},
|
},
|
||||||
"dto.MFALogin": {
|
"dto.MFALogin": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"code",
|
||||||
|
"name",
|
||||||
|
"password"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"authMethod": {
|
"authMethod": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -14330,6 +14351,11 @@
|
|||||||
},
|
},
|
||||||
"dto.MfaCredential": {
|
"dto.MfaCredential": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"code",
|
||||||
|
"interval",
|
||||||
|
"secret"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"code": {
|
"code": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -14744,6 +14770,10 @@
|
|||||||
},
|
},
|
||||||
"dto.NetworkCreate": {
|
"dto.NetworkCreate": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"driver",
|
||||||
|
"name"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"driver": {
|
"driver": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -15104,6 +15134,9 @@
|
|||||||
},
|
},
|
||||||
"dto.RedisConfUpdateByFile": {
|
"dto.RedisConfUpdateByFile": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"file"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"file": {
|
"file": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -15182,6 +15215,34 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"dto.RuleSearch": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"page",
|
||||||
|
"pageSize",
|
||||||
|
"type"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"info": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"page": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"pageSize": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"strategy": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"dto.SSHConf": {
|
"dto.SSHConf": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -15699,6 +15760,9 @@
|
|||||||
},
|
},
|
||||||
"dto.SyncTime": {
|
"dto.SyncTime": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"ntpSite"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"ntpSite": {
|
"ntpSite": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -15763,6 +15827,9 @@
|
|||||||
},
|
},
|
||||||
"dto.Upgrade": {
|
"dto.Upgrade": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"version"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"version": {
|
"version": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -15799,6 +15866,10 @@
|
|||||||
},
|
},
|
||||||
"dto.VolumeCreate": {
|
"dto.VolumeCreate": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"driver",
|
||||||
|
"name"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"driver": {
|
"driver": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -16495,6 +16566,17 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"request.ExposedPort": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"containerPort": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"hostPort": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"request.FavoriteCreate": {
|
"request.FavoriteCreate": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
@ -17263,6 +17345,12 @@
|
|||||||
"codeDir": {
|
"codeDir": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"exposedPorts": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/request.ExposedPort"
|
||||||
|
}
|
||||||
|
},
|
||||||
"image": {
|
"image": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@ -17348,6 +17436,12 @@
|
|||||||
"codeDir": {
|
"codeDir": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"exposedPorts": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/request.ExposedPort"
|
||||||
|
}
|
||||||
|
},
|
||||||
"id": {
|
"id": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
@ -428,6 +428,9 @@ definitions:
|
|||||||
items:
|
items:
|
||||||
$ref: '#/definitions/dto.VolumeHelper'
|
$ref: '#/definitions/dto.VolumeHelper'
|
||||||
type: array
|
type: array
|
||||||
|
required:
|
||||||
|
- image
|
||||||
|
- name
|
||||||
type: object
|
type: object
|
||||||
dto.ContainerOperation:
|
dto.ContainerOperation:
|
||||||
properties:
|
properties:
|
||||||
@ -478,6 +481,7 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
required:
|
required:
|
||||||
- name
|
- name
|
||||||
|
- newName
|
||||||
type: object
|
type: object
|
||||||
dto.ContainerStats:
|
dto.ContainerStats:
|
||||||
properties:
|
properties:
|
||||||
@ -518,6 +522,8 @@ definitions:
|
|||||||
items:
|
items:
|
||||||
type: integer
|
type: integer
|
||||||
type: array
|
type: array
|
||||||
|
required:
|
||||||
|
- ids
|
||||||
type: object
|
type: object
|
||||||
dto.CronjobClean:
|
dto.CronjobClean:
|
||||||
properties:
|
properties:
|
||||||
@ -1251,6 +1257,9 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
type:
|
type:
|
||||||
type: string
|
type: string
|
||||||
|
required:
|
||||||
|
- id
|
||||||
|
- type
|
||||||
type: object
|
type: object
|
||||||
dto.LogOption:
|
dto.LogOption:
|
||||||
properties:
|
properties:
|
||||||
@ -1275,6 +1284,9 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
password:
|
password:
|
||||||
type: string
|
type: string
|
||||||
|
required:
|
||||||
|
- name
|
||||||
|
- password
|
||||||
type: object
|
type: object
|
||||||
dto.MFALogin:
|
dto.MFALogin:
|
||||||
properties:
|
properties:
|
||||||
@ -1286,6 +1298,10 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
password:
|
password:
|
||||||
type: string
|
type: string
|
||||||
|
required:
|
||||||
|
- code
|
||||||
|
- name
|
||||||
|
- password
|
||||||
type: object
|
type: object
|
||||||
dto.MfaCredential:
|
dto.MfaCredential:
|
||||||
properties:
|
properties:
|
||||||
@ -1295,6 +1311,10 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
secret:
|
secret:
|
||||||
type: string
|
type: string
|
||||||
|
required:
|
||||||
|
- code
|
||||||
|
- interval
|
||||||
|
- secret
|
||||||
type: object
|
type: object
|
||||||
dto.MysqlConfUpdateByFile:
|
dto.MysqlConfUpdateByFile:
|
||||||
properties:
|
properties:
|
||||||
@ -1588,6 +1608,9 @@ definitions:
|
|||||||
type: array
|
type: array
|
||||||
subnet:
|
subnet:
|
||||||
type: string
|
type: string
|
||||||
|
required:
|
||||||
|
- driver
|
||||||
|
- name
|
||||||
type: object
|
type: object
|
||||||
dto.NginxKey:
|
dto.NginxKey:
|
||||||
enum:
|
enum:
|
||||||
@ -1820,6 +1843,8 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
restartNow:
|
restartNow:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
required:
|
||||||
|
- file
|
||||||
type: object
|
type: object
|
||||||
dto.RedisPersistence:
|
dto.RedisPersistence:
|
||||||
properties:
|
properties:
|
||||||
@ -1866,6 +1891,25 @@ definitions:
|
|||||||
memory:
|
memory:
|
||||||
type: integer
|
type: integer
|
||||||
type: object
|
type: object
|
||||||
|
dto.RuleSearch:
|
||||||
|
properties:
|
||||||
|
info:
|
||||||
|
type: string
|
||||||
|
page:
|
||||||
|
type: integer
|
||||||
|
pageSize:
|
||||||
|
type: integer
|
||||||
|
status:
|
||||||
|
type: string
|
||||||
|
strategy:
|
||||||
|
type: string
|
||||||
|
type:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- page
|
||||||
|
- pageSize
|
||||||
|
- type
|
||||||
|
type: object
|
||||||
dto.SSHConf:
|
dto.SSHConf:
|
||||||
properties:
|
properties:
|
||||||
file:
|
file:
|
||||||
@ -2214,6 +2258,8 @@ definitions:
|
|||||||
properties:
|
properties:
|
||||||
ntpSite:
|
ntpSite:
|
||||||
type: string
|
type: string
|
||||||
|
required:
|
||||||
|
- ntpSite
|
||||||
type: object
|
type: object
|
||||||
dto.TreeChild:
|
dto.TreeChild:
|
||||||
properties:
|
properties:
|
||||||
@ -2256,6 +2302,8 @@ definitions:
|
|||||||
properties:
|
properties:
|
||||||
version:
|
version:
|
||||||
type: string
|
type: string
|
||||||
|
required:
|
||||||
|
- version
|
||||||
type: object
|
type: object
|
||||||
dto.UpgradeInfo:
|
dto.UpgradeInfo:
|
||||||
properties:
|
properties:
|
||||||
@ -2289,6 +2337,9 @@ definitions:
|
|||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
type: array
|
type: array
|
||||||
|
required:
|
||||||
|
- driver
|
||||||
|
- name
|
||||||
type: object
|
type: object
|
||||||
dto.VolumeHelper:
|
dto.VolumeHelper:
|
||||||
properties:
|
properties:
|
||||||
@ -2737,6 +2788,13 @@ definitions:
|
|||||||
required:
|
required:
|
||||||
- path
|
- path
|
||||||
type: object
|
type: object
|
||||||
|
request.ExposedPort:
|
||||||
|
properties:
|
||||||
|
containerPort:
|
||||||
|
type: integer
|
||||||
|
hostPort:
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
request.FavoriteCreate:
|
request.FavoriteCreate:
|
||||||
properties:
|
properties:
|
||||||
path:
|
path:
|
||||||
@ -3253,6 +3311,10 @@ definitions:
|
|||||||
type: boolean
|
type: boolean
|
||||||
codeDir:
|
codeDir:
|
||||||
type: string
|
type: string
|
||||||
|
exposedPorts:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/request.ExposedPort'
|
||||||
|
type: array
|
||||||
image:
|
image:
|
||||||
type: string
|
type: string
|
||||||
install:
|
install:
|
||||||
@ -3309,6 +3371,10 @@ definitions:
|
|||||||
type: boolean
|
type: boolean
|
||||||
codeDir:
|
codeDir:
|
||||||
type: string
|
type: string
|
||||||
|
exposedPorts:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/request.ExposedPort'
|
||||||
|
type: array
|
||||||
id:
|
id:
|
||||||
type: integer
|
type: integer
|
||||||
image:
|
image:
|
||||||
@ -8926,7 +8992,7 @@ paths:
|
|||||||
name: request
|
name: request
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/dto.SearchWithPage'
|
$ref: '#/definitions/dto.RuleSearch'
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
|
@ -521,6 +521,7 @@ const updateContainerID = async () => {
|
|||||||
let params = {
|
let params = {
|
||||||
page: 1,
|
page: 1,
|
||||||
pageSize: 1,
|
pageSize: 1,
|
||||||
|
state: 'all',
|
||||||
name: dialogData.value.rowData.name,
|
name: dialogData.value.rowData.name,
|
||||||
filters: '',
|
filters: '',
|
||||||
orderBy: 'created_at',
|
orderBy: 'created_at',
|
||||||
|
@ -6,7 +6,11 @@
|
|||||||
<el-form @submit.prevent ref="newNameRef" v-loading="loading" :model="renameForm" label-position="top">
|
<el-form @submit.prevent ref="newNameRef" v-loading="loading" :model="renameForm" label-position="top">
|
||||||
<el-row type="flex" justify="center">
|
<el-row type="flex" justify="center">
|
||||||
<el-col :span="22">
|
<el-col :span="22">
|
||||||
<el-form-item :label="$t('container.newName')" :rules="Rules.containerName" prop="newName">
|
<el-form-item
|
||||||
|
:label="$t('container.newName')"
|
||||||
|
:rules="[Rules.containerName, Rules.requiredInput]"
|
||||||
|
prop="newName"
|
||||||
|
>
|
||||||
<el-input v-model="renameForm.newName"></el-input>
|
<el-input v-model="renameForm.newName"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user