mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-12-16 09:49:07 +08:00
55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
|
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"
|
||
|
)
|
||
|
|
||
|
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) {
|
||
|
var req dto.WebsiteAcmeAccountCreate
|
||
|
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) {
|
||
|
|
||
|
id, err := helper.GetParamID(c)
|
||
|
if err != nil {
|
||
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
if err := websiteAcmeAccountService.Delete(id); err != nil {
|
||
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||
|
return
|
||
|
}
|
||
|
helper.SuccessWithData(c, nil)
|
||
|
}
|