mirror of https://github.com/1Panel-dev/1Panel
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
2.0 KiB
61 lines
2.0 KiB
2 years ago
|
package v1
|
||
|
|
||
|
import (
|
||
|
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
||
|
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
||
|
"github.com/1Panel-dev/1Panel/backend/global"
|
||
|
"github.com/gin-gonic/gin"
|
||
|
)
|
||
|
|
||
|
// @Tags System Setting
|
||
|
// @Summary Create snapshot
|
||
|
// @Description 创建系统快照
|
||
|
// @Accept json
|
||
|
// @Param request body dto.SnapshotCreate true "request"
|
||
|
// @Success 200
|
||
|
// @Security ApiKeyAuth
|
||
|
// @Router /settings/snapshot [post]
|
||
|
// @x-panel-log {"bodyKeys":["name", "description"],"paramKeys":[],"BeforeFuntions":[],"formatZH":"创建系统快照 [name][description]","formatEN":"Create system snapshot [name][description]"}
|
||
|
func (b *BaseApi) CreateSnapshot(c *gin.Context) {
|
||
|
var req dto.SnapshotCreate
|
||
|
if err := c.ShouldBindJSON(&req); 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
|
||
|
}
|
||
|
if err := snapshotService.Create(req); err != nil {
|
||
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||
|
return
|
||
|
}
|
||
|
helper.SuccessWithData(c, nil)
|
||
|
}
|
||
|
|
||
|
// @Tags System Setting
|
||
|
// @Summary Page system snapshot
|
||
|
// @Description 获取系统快照列表分页
|
||
|
// @Accept json
|
||
|
// @Param request body dto.PageInfo true "request"
|
||
|
// @Success 200 {object} dto.PageResult
|
||
|
// @Security ApiKeyAuth
|
||
|
// @Router /websites/acme/search [post]
|
||
|
func (b *BaseApi) SearchSnapshot(c *gin.Context) {
|
||
|
var req dto.PageInfo
|
||
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||
|
return
|
||
|
}
|
||
|
total, accounts, err := snapshotService.SearchWithPage(req)
|
||
|
if err != nil {
|
||
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||
|
return
|
||
|
}
|
||
|
helper.SuccessWithData(c, dto.PageResult{
|
||
|
Total: total,
|
||
|
Items: accounts,
|
||
|
})
|
||
|
}
|