1Panel/backend/app/api/v1/website_acme_account.go

54 lines
1.7 KiB
Go
Raw Normal View History

2022-11-11 17:41:39 +08:00
package v1
import (
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/app/dto"
2022-12-14 15:26:51 +08:00
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
2022-11-11 17:41:39 +08:00
"github.com/1Panel-dev/1Panel/backend/constant"
"github.com/gin-gonic/gin"
)
func (b *BaseApi) PageWebsiteAcmeAccount(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 := websiteAcmeAccountService.Page(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, dto.PageResult{
Total: total,
Items: accounts,
})
}
func (b *BaseApi) CreateWebsiteAcmeAccount(c *gin.Context) {
2022-12-14 15:26:51 +08:00
var req request.WebsiteAcmeAccountCreate
2022-11-11 17:41:39 +08:00
if err := c.ShouldBindJSON(&req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
return
}
res, err := websiteAcmeAccountService.Create(req)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, res)
}
func (b *BaseApi) DeleteWebsiteAcmeAccount(c *gin.Context) {
2022-12-22 10:30:32 +08:00
var req request.WebsiteResourceReq
if err := c.ShouldBindJSON(&req); err != nil {
2022-11-11 17:41:39 +08:00
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
return
}
2022-12-22 10:30:32 +08:00
if err := websiteAcmeAccountService.Delete(req.ID); err != nil {
2022-11-11 17:41:39 +08:00
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, nil)
}