2023-01-09 22:55:10 +08:00
|
|
|
package v1
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
|
|
|
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
|
|
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
// @Tags System Setting
|
|
|
|
// @Summary Load upgrade info
|
2023-02-05 23:48:37 +08:00
|
|
|
// @Description 系统更新信息
|
2023-01-09 22:55:10 +08:00
|
|
|
// @Success 200 {object} dto.UpgradeInfo
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /settings/upgrade [get]
|
|
|
|
func (b *BaseApi) GetUpgradeInfo(c *gin.Context) {
|
2023-01-30 21:05:20 +08:00
|
|
|
info, err := upgradeService.SearchUpgrade()
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, info)
|
|
|
|
}
|
|
|
|
|
2023-03-21 15:16:28 +08:00
|
|
|
// @Tags System Setting
|
|
|
|
// @Summary Load release notes by version
|
|
|
|
// @Description 获取版本 release notes
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body dto.Upgrade true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /settings/upgrade [get]
|
|
|
|
func (b *BaseApi) GetNotesByVersion(c *gin.Context) {
|
|
|
|
var req dto.Upgrade
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
notes, err := upgradeService.LoadNotes(req)
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, notes)
|
|
|
|
}
|
|
|
|
|
2023-01-30 21:05:20 +08:00
|
|
|
// @Tags System Setting
|
|
|
|
// @Summary Upgrade
|
|
|
|
// @Description 系统更新
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body dto.Upgrade true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /settings/upgrade [post]
|
2023-10-07 15:46:44 +08:00
|
|
|
// @x-panel-log {"bodyKeys":["version"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新系统 => [version]","formatEN":"upgrade service => [version]"}
|
2023-01-30 21:05:20 +08:00
|
|
|
func (b *BaseApi) Upgrade(c *gin.Context) {
|
|
|
|
var req dto.Upgrade
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
2023-02-05 23:48:37 +08:00
|
|
|
if err := upgradeService.Upgrade(req); err != nil {
|
2023-01-30 21:05:20 +08:00
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, nil)
|
|
|
|
}
|