diff --git a/agent/app/api/v2/website_ssl.go b/agent/app/api/v2/website_ssl.go index 2466209bc..97c64b2b5 100644 --- a/agent/app/api/v2/website_ssl.go +++ b/agent/app/api/v2/website_ssl.go @@ -5,7 +5,6 @@ import ( "mime/multipart" "net/http" "net/url" - "reflect" "strconv" "github.com/1Panel-dev/1Panel/agent/app/model" @@ -29,24 +28,36 @@ func (b *BaseApi) PageWebsiteSSL(c *gin.Context) { if err := helper.CheckBindAndValidate(&req, c); err != nil { return } - if !reflect.DeepEqual(req.PageInfo, dto.PageInfo{}) { - total, accounts, err := websiteSSLService.Page(req) - if err != nil { - helper.InternalServer(c, err) - return - } - helper.SuccessWithDataGzipped(c, dto.PageResult{ - Total: total, - Items: accounts, - }) - } else { - list, err := websiteSSLService.Search(req) - if err != nil { - helper.InternalServer(c, err) - return - } - helper.SuccessWithDataGzipped(c, list) + total, accounts, err := websiteSSLService.Page(req) + if err != nil { + helper.InternalServer(c, err) + return } + helper.SuccessWithDataGzipped(c, dto.PageResult{ + Total: total, + Items: accounts, + }) +} + +// @Tags Website SSL +// @Summary List website ssl +// @Accept json +// @Param request body request.WebsiteSSLListReq true "request" +// @Success 200 {array} response.WebsiteSSLDTO +// @Security ApiKeyAuth +// @Security Timestamp +// @Router /websites/ssl/list [post] +func (b *BaseApi) ListWebsiteSSL(c *gin.Context) { + var req request.WebsiteSSLListReq + if err := helper.CheckBind(&req, c); err != nil { + return + } + list, err := websiteSSLService.Search(req) + if err != nil { + helper.InternalServer(c, err) + return + } + helper.SuccessWithDataGzipped(c, list) } // @Tags Website SSL diff --git a/agent/app/dto/request/website_ssl.go b/agent/app/dto/request/website_ssl.go index 2e96309b7..a42e8ae01 100644 --- a/agent/app/dto/request/website_ssl.go +++ b/agent/app/dto/request/website_ssl.go @@ -10,6 +10,10 @@ type WebsiteSSLSearch struct { Order string `json:"order" validate:"required,oneof=null ascending descending"` } +type WebsiteSSLListReq struct { + AcmeAccountID string `json:"acmeAccountID"` +} + type WebsiteSSLCreate struct { PrimaryDomain string `json:"primaryDomain" validate:"required"` OtherDomains string `json:"otherDomains"` diff --git a/agent/app/service/website_ssl.go b/agent/app/service/website_ssl.go index bc04a3de2..efc461ed0 100644 --- a/agent/app/service/website_ssl.go +++ b/agent/app/service/website_ssl.go @@ -37,7 +37,7 @@ type WebsiteSSLService struct { type IWebsiteSSLService interface { Page(search request.WebsiteSSLSearch) (int64, []response.WebsiteSSLDTO, error) GetSSL(id uint) (*response.WebsiteSSLDTO, error) - Search(req request.WebsiteSSLSearch) ([]response.WebsiteSSLDTO, error) + Search(req request.WebsiteSSLListReq) ([]response.WebsiteSSLDTO, error) Create(create request.WebsiteSSLCreate) (request.WebsiteSSLCreate, error) GetDNSResolve(req request.WebsiteDNSReq) ([]response.WebsiteDNSRes, error) GetWebsiteSSL(websiteId uint) (response.WebsiteSSLDTO, error) @@ -90,7 +90,7 @@ func (w WebsiteSSLService) GetSSL(id uint) (*response.WebsiteSSLDTO, error) { return &res, nil } -func (w WebsiteSSLService) Search(search request.WebsiteSSLSearch) ([]response.WebsiteSSLDTO, error) { +func (w WebsiteSSLService) Search(search request.WebsiteSSLListReq) ([]response.WebsiteSSLDTO, error) { var ( opts []repo.DBOption result []response.WebsiteSSLDTO diff --git a/agent/router/ro_website_ssl.go b/agent/router/ro_website_ssl.go index 420b7045d..28e42d2c9 100644 --- a/agent/router/ro_website_ssl.go +++ b/agent/router/ro_website_ssl.go @@ -14,6 +14,7 @@ func (a *WebsiteSSLRouter) InitRouter(Router *gin.RouterGroup) { baseApi := v2.ApiGroupApp.BaseApi { groupRouter.POST("/search", baseApi.PageWebsiteSSL) + groupRouter.POST("/list", baseApi.ListWebsiteSSL) groupRouter.POST("", baseApi.CreateWebsiteSSL) groupRouter.POST("/resolve", baseApi.GetDNSResolve) groupRouter.POST("/del", baseApi.DeleteWebsiteSSL) diff --git a/frontend/src/api/modules/website.ts b/frontend/src/api/modules/website.ts index cd95d8089..cdbc69c6a 100644 --- a/frontend/src/api/modules/website.ts +++ b/frontend/src/api/modules/website.ts @@ -113,11 +113,11 @@ export const searchSSL = (req: ReqPage) => { }; export const listSSL = (req: Website.SSLReq) => { - return http.post(`/websites/ssl/search`, req); + return http.post(`/websites/ssl/list`, req); }; export const listLocalNodeSSL = (req: Website.SSLReq) => { - return http.postLocalNode(`/websites/ssl/search`, req); + return http.postLocalNode(`/websites/ssl/list`, req); }; export const createSSL = (req: Website.SSLCreate) => {