2022-10-28 17:04:57 +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-13 17:20:13 +08:00
|
|
|
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
2022-10-28 17:04:57 +08:00
|
|
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Tags Website
|
2023-01-05 11:57:03 +08:00
|
|
|
// @Summary Page websites
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Description 获取网站列表分页
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsiteSearch true "request"
|
|
|
|
// @Success 200 {object} dto.PageResult
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/search [post]
|
2022-11-02 15:19:14 +08:00
|
|
|
func (b *BaseApi) PageWebsite(c *gin.Context) {
|
2022-12-13 17:20:13 +08:00
|
|
|
var req request.WebsiteSearch
|
2022-11-02 15:19:14 +08:00
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
2022-12-13 17:20:13 +08:00
|
|
|
total, websites, err := websiteService.PageWebsite(req)
|
2022-11-02 15:19:14 +08:00
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, dto.PageResult{
|
|
|
|
Total: total,
|
|
|
|
Items: websites,
|
|
|
|
})
|
|
|
|
}
|
2022-10-28 17:04:57 +08:00
|
|
|
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Tags Website
|
2023-01-05 11:57:03 +08:00
|
|
|
// @Summary List websites
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Description 获取网站列表
|
2023-07-06 18:04:22 +08:00
|
|
|
// @Success 200 {array} response.WebsiteDTO
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/list [get]
|
2023-01-03 16:56:36 +08:00
|
|
|
func (b *BaseApi) GetWebsites(c *gin.Context) {
|
|
|
|
websites, err := websiteService.GetWebsites()
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, websites)
|
|
|
|
}
|
|
|
|
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Tags Website
|
2023-01-05 11:57:03 +08:00
|
|
|
// @Summary List website names
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Description 获取网站列表
|
2023-07-06 18:04:22 +08:00
|
|
|
// @Success 200 {array} string
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/options [get]
|
2022-11-30 15:47:11 +08:00
|
|
|
func (b *BaseApi) GetWebsiteOptions(c *gin.Context) {
|
|
|
|
websites, err := websiteService.GetWebsiteOptions()
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, websites)
|
|
|
|
}
|
|
|
|
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Tags Website
|
|
|
|
// @Summary Create website
|
|
|
|
// @Description 创建网站
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsiteCreate true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites [post]
|
|
|
|
// @x-panel-log {"bodyKeys":["primaryDomain"],"paramKeys":[],"BeforeFuntions":[],"formatZH":"创建网站 [primaryDomain]","formatEN":"Create website [primaryDomain]"}
|
2022-11-02 15:19:14 +08:00
|
|
|
func (b *BaseApi) CreateWebsite(c *gin.Context) {
|
2022-12-13 17:20:13 +08:00
|
|
|
var req request.WebsiteCreate
|
2022-10-28 17:04:57 +08:00
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
2023-04-12 14:16:29 +08:00
|
|
|
|
|
|
|
err := websiteService.CreateWebsite(req)
|
2022-10-28 17:04:57 +08:00
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, nil)
|
|
|
|
}
|
2022-11-02 15:19:14 +08:00
|
|
|
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Tags Website
|
|
|
|
// @Summary Operate website
|
|
|
|
// @Description 操作网站
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsiteOp true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/operate [post]
|
2023-05-30 15:30:57 +08:00
|
|
|
// @x-panel-log {"bodyKeys":["id", "operate"],"paramKeys":[],"BeforeFuntions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"[operate] 网站 [domain]","formatEN":"[operate] website [domain]"}
|
2022-12-26 16:09:21 +08:00
|
|
|
func (b *BaseApi) OpWebsite(c *gin.Context) {
|
|
|
|
var req request.WebsiteOp
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
err := websiteService.OpWebsite(req)
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, nil)
|
|
|
|
}
|
|
|
|
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Tags Website
|
|
|
|
// @Summary Delete website
|
|
|
|
// @Description 删除网站
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsiteDelete true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
2023-01-05 11:57:03 +08:00
|
|
|
// @Router /websites/del [post]
|
2023-05-30 15:30:57 +08:00
|
|
|
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFuntions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"删除网站 [domain]","formatEN":"Delete website [domain]"}
|
2022-12-13 17:20:13 +08:00
|
|
|
func (b *BaseApi) DeleteWebsite(c *gin.Context) {
|
|
|
|
var req request.WebsiteDelete
|
2022-11-02 15:19:14 +08:00
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
2023-04-12 14:22:29 +08:00
|
|
|
|
|
|
|
err := websiteService.DeleteWebsite(req)
|
2022-11-02 15:19:14 +08:00
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, nil)
|
|
|
|
}
|
2022-11-03 17:06:48 +08:00
|
|
|
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Tags Website
|
|
|
|
// @Summary Update website
|
|
|
|
// @Description 更新网站
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsiteUpdate true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/update [post]
|
|
|
|
// @x-panel-log {"bodyKeys":["primaryDomain"],"paramKeys":[],"BeforeFuntions":[],"formatZH":"更新网站 [primaryDomain]","formatEN":"Update website [primaryDomain]"}
|
2022-12-13 17:20:13 +08:00
|
|
|
func (b *BaseApi) UpdateWebsite(c *gin.Context) {
|
|
|
|
var req request.WebsiteUpdate
|
2022-11-08 17:21:13 +08:00
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if err := websiteService.UpdateWebsite(req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, nil)
|
|
|
|
}
|
|
|
|
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Tags Website
|
|
|
|
// @Summary Search website by id
|
|
|
|
// @Description 通过 id 查询网站
|
|
|
|
// @Accept json
|
|
|
|
// @Param id path integer true "request"
|
|
|
|
// @Success 200 {object} response.WebsiteDTO
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/:id [get]
|
2022-12-13 17:20:13 +08:00
|
|
|
func (b *BaseApi) GetWebsite(c *gin.Context) {
|
2022-11-08 17:21:13 +08:00
|
|
|
id, err := helper.GetParamID(c)
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
website, err := websiteService.GetWebsite(id)
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, website)
|
|
|
|
}
|
|
|
|
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Tags Website Nginx
|
|
|
|
// @Summary Search website nginx by id
|
|
|
|
// @Description 通过 id 查询网站 nginx
|
|
|
|
// @Accept json
|
|
|
|
// @Param id path integer true "request"
|
|
|
|
// @Success 200 {object} response.FileInfo
|
|
|
|
// @Security ApiKeyAuth
|
2023-04-04 18:54:04 +08:00
|
|
|
// @Router /websites/:id/config/:type [get]
|
2022-12-13 17:20:13 +08:00
|
|
|
func (b *BaseApi) GetWebsiteNginx(c *gin.Context) {
|
2022-11-19 17:16:02 +08:00
|
|
|
id, err := helper.GetParamID(c)
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
|
|
|
return
|
|
|
|
}
|
2023-04-04 18:54:04 +08:00
|
|
|
configType := c.Param("type")
|
|
|
|
|
|
|
|
fileInfo, err := websiteService.GetWebsiteNginxConfig(id, configType)
|
2022-11-19 17:16:02 +08:00
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, fileInfo)
|
|
|
|
}
|
|
|
|
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Tags Website Domain
|
|
|
|
// @Summary Search website domains by websiteId
|
|
|
|
// @Description 通过网站 id 查询域名
|
|
|
|
// @Accept json
|
|
|
|
// @Param websiteId path integer true "request"
|
2023-07-06 18:04:22 +08:00
|
|
|
// @Success 200 {array} model.WebsiteDomain
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/domains/:websiteId [get]
|
2022-11-03 17:06:48 +08:00
|
|
|
func (b *BaseApi) GetWebDomains(c *gin.Context) {
|
|
|
|
websiteId, err := helper.GetIntParamByKey(c, "websiteId")
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
list, err := websiteService.GetWebsiteDomain(websiteId)
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, list)
|
|
|
|
}
|
|
|
|
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Tags Website Domain
|
|
|
|
// @Summary Delete website domain
|
|
|
|
// @Description 删除网站域名
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsiteDomainDelete true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/domains/del [post]
|
2023-05-30 15:30:57 +08:00
|
|
|
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFuntions":[{"input_column":"id","input_value":"id","isList":false,"db":"website_domains","output_column":"domain","output_value":"domain"}],"formatZH":"删除域名 [domain]","formatEN":"Delete domain [domain]"}
|
2022-11-03 17:06:48 +08:00
|
|
|
func (b *BaseApi) DeleteWebDomain(c *gin.Context) {
|
2022-12-13 17:20:13 +08:00
|
|
|
var req request.WebsiteDomainDelete
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
2022-11-03 17:06:48 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-12-13 17:20:13 +08:00
|
|
|
if err := websiteService.DeleteWebsiteDomain(req.ID); err != nil {
|
2022-11-03 17:06:48 +08:00
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, nil)
|
|
|
|
}
|
2022-11-03 18:02:07 +08:00
|
|
|
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Tags Website Domain
|
|
|
|
// @Summary Create website domain
|
|
|
|
// @Description 创建网站域名
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsiteDomainCreate true "request"
|
|
|
|
// @Success 200 {object} model.WebsiteDomain
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/domains [post]
|
|
|
|
// @x-panel-log {"bodyKeys":["domain"],"paramKeys":[],"BeforeFuntions":[],"formatZH":"创建域名 [domain]","formatEN":"Create domain [domain]"}
|
2022-11-03 18:02:07 +08:00
|
|
|
func (b *BaseApi) CreateWebDomain(c *gin.Context) {
|
2022-12-13 17:20:13 +08:00
|
|
|
var req request.WebsiteDomainCreate
|
2022-11-03 18:02:07 +08:00
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
domain, err := websiteService.CreateWebsiteDomain(req)
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, domain)
|
|
|
|
}
|
2022-11-07 16:19:05 +08:00
|
|
|
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Tags Website Nginx
|
|
|
|
// @Summary Load nginx conf
|
|
|
|
// @Description 获取 nginx 配置
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.NginxScopeReq true "request"
|
|
|
|
// @Success 200 {object} response.WebsiteNginxConfig
|
|
|
|
// @Security ApiKeyAuth
|
2023-01-05 11:57:03 +08:00
|
|
|
// @Router /websites/config [post]
|
2022-11-07 16:19:05 +08:00
|
|
|
func (b *BaseApi) GetNginxConfig(c *gin.Context) {
|
2022-12-13 18:54:46 +08:00
|
|
|
var req request.NginxScopeReq
|
2022-11-07 16:19:05 +08:00
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
config, err := websiteService.GetNginxConfigByScope(req)
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, config)
|
|
|
|
}
|
|
|
|
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Tags Website Nginx
|
|
|
|
// @Summary Update nginx conf
|
|
|
|
// @Description 更新 nginx 配置
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.NginxConfigUpdate true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/config/update [post]
|
2023-05-30 15:30:57 +08:00
|
|
|
// @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFuntions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"nginx 配置修改 [domain]","formatEN":"Nginx conf update [domain]"}
|
2022-11-07 16:19:05 +08:00
|
|
|
func (b *BaseApi) UpdateNginxConfig(c *gin.Context) {
|
2022-12-13 18:54:46 +08:00
|
|
|
var req request.NginxConfigUpdate
|
2022-11-07 16:19:05 +08:00
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if err := websiteService.UpdateNginxConfigByScope(req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, nil)
|
|
|
|
}
|
2022-11-20 18:32:56 +08:00
|
|
|
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Tags Website HTTPS
|
|
|
|
// @Summary Load https conf
|
|
|
|
// @Description 获取 https 配置
|
|
|
|
// @Accept json
|
|
|
|
// @Param id path integer true "request"
|
|
|
|
// @Success 200 {object} response.WebsiteHTTPS
|
|
|
|
// @Security ApiKeyAuth
|
2023-01-05 11:57:03 +08:00
|
|
|
// @Router /websites/:id/https [get]
|
2022-11-20 18:32:56 +08:00
|
|
|
func (b *BaseApi) GetHTTPSConfig(c *gin.Context) {
|
|
|
|
id, err := helper.GetParamID(c)
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
res, err := websiteService.GetWebsiteHTTPS(id)
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, res)
|
|
|
|
}
|
|
|
|
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Tags Website HTTPS
|
|
|
|
// @Summary Update https conf
|
|
|
|
// @Description 更新 https 配置
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsiteHTTPSOp true "request"
|
2023-01-05 11:57:03 +08:00
|
|
|
// @Success 200 {object} response.WebsiteHTTPS
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/:id/https [post]
|
2023-05-30 15:30:57 +08:00
|
|
|
// @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFuntions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新网站 [domain] https 配置","formatEN":"Update website https [domain] conf"}
|
2022-11-20 18:32:56 +08:00
|
|
|
func (b *BaseApi) UpdateHTTPSConfig(c *gin.Context) {
|
2022-12-13 17:20:13 +08:00
|
|
|
var req request.WebsiteHTTPSOp
|
2022-11-20 18:32:56 +08:00
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
2022-12-28 16:07:43 +08:00
|
|
|
tx, ctx := helper.GetTxAndContext()
|
|
|
|
res, err := websiteService.OpWebsiteHTTPS(ctx, req)
|
2022-11-20 18:32:56 +08:00
|
|
|
if err != nil {
|
2022-12-28 16:07:43 +08:00
|
|
|
tx.Rollback()
|
2022-11-20 18:32:56 +08:00
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
2022-12-28 16:07:43 +08:00
|
|
|
tx.Commit()
|
2022-11-20 18:32:56 +08:00
|
|
|
helper.SuccessWithData(c, res)
|
|
|
|
}
|
2022-12-04 17:45:54 +08:00
|
|
|
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Tags Website
|
|
|
|
// @Summary Check before create website
|
|
|
|
// @Description 网站创建前检查
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsiteInstallCheckReq true "request"
|
2023-07-06 18:04:22 +08:00
|
|
|
// @Success 200 {array} response.WebsitePreInstallCheck
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/check [post]
|
2022-12-04 17:45:54 +08:00
|
|
|
func (b *BaseApi) CreateWebsiteCheck(c *gin.Context) {
|
2022-12-13 17:20:13 +08:00
|
|
|
var req request.WebsiteInstallCheckReq
|
2022-12-04 17:45:54 +08:00
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
data, err := websiteService.PreInstallCheck(req)
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, data)
|
|
|
|
}
|
2022-12-06 11:42:11 +08:00
|
|
|
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Tags Website WAF
|
|
|
|
// @Summary Load websit waf conf
|
|
|
|
// @Description 获取网站 waf 配置
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsiteWafReq true "request"
|
2023-01-05 11:57:03 +08:00
|
|
|
// @Success 200 {object} response.WebsiteWafConfig
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/waf/config [post]
|
2022-12-06 11:42:11 +08:00
|
|
|
func (b *BaseApi) GetWebsiteWafConfig(c *gin.Context) {
|
|
|
|
var req request.WebsiteWafReq
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
data, err := websiteService.GetWafConfig(req)
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, data)
|
|
|
|
}
|
|
|
|
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Tags Website WAF
|
|
|
|
// @Summary Update website waf conf
|
|
|
|
// @Description 更新 网站 waf 配置
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsiteWafUpdate true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/waf/update [post]
|
2023-05-30 15:30:57 +08:00
|
|
|
// @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFuntions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"WAF 配置修改 [domain]","formatEN":"WAF conf update [domain]"}
|
2022-12-06 11:42:11 +08:00
|
|
|
func (b *BaseApi) UpdateWebsiteWafConfig(c *gin.Context) {
|
|
|
|
var req request.WebsiteWafUpdate
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if err := websiteService.UpdateWafConfig(req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, nil)
|
|
|
|
}
|
2022-12-28 11:37:04 +08:00
|
|
|
|
2023-08-02 22:38:32 +08:00
|
|
|
// @Tags Website WAF
|
|
|
|
// @Summary Update website waf file
|
|
|
|
// @Description 更新 网站 waf 配置文件
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsiteWafUpdate true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/waf/file/update [post]
|
|
|
|
// @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFuntions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"WAF 配置文件修改 [domain]","formatEN":"WAF conf file update [domain]"}
|
|
|
|
func (b *BaseApi) UpdateWebsiteWafFile(c *gin.Context) {
|
|
|
|
var req request.WebsiteWafFileUpdate
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if err := websiteService.UpdateWafFile(req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, nil)
|
|
|
|
}
|
|
|
|
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Tags Website Nginx
|
|
|
|
// @Summary Update website nginx conf
|
|
|
|
// @Description 更新 网站 nginx 配置
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsiteNginxUpdate true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/nginx/update [post]
|
2023-05-30 15:30:57 +08:00
|
|
|
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFuntions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"[domain] Nginx 配置修改","formatEN":"[domain] Nginx conf update"}
|
2022-12-28 11:37:04 +08:00
|
|
|
func (b *BaseApi) UpdateWebsiteNginxConfig(c *gin.Context) {
|
|
|
|
var req request.WebsiteNginxUpdate
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if err := websiteService.UpdateNginxConfigFile(req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, nil)
|
|
|
|
}
|
2022-12-30 17:39:17 +08:00
|
|
|
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Tags Website
|
|
|
|
// @Summary Operate website log
|
|
|
|
// @Description 操作网站日志
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsiteLogReq true "request"
|
|
|
|
// @Success 200 {object} response.WebsiteLog
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/log [post]
|
2023-05-30 15:30:57 +08:00
|
|
|
// @x-panel-log {"bodyKeys":["id", "operate"],"paramKeys":[],"BeforeFuntions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"[domain][operate] 日志","formatEN":"[domain][operate] logs"}
|
2022-12-30 17:39:17 +08:00
|
|
|
func (b *BaseApi) OpWebsiteLog(c *gin.Context) {
|
|
|
|
var req request.WebsiteLogReq
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
res, err := websiteService.OpWebsiteLog(req)
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, res)
|
|
|
|
}
|
2023-01-03 16:56:36 +08:00
|
|
|
|
2023-01-04 22:31:51 +08:00
|
|
|
// @Tags Website
|
|
|
|
// @Summary Change default server
|
|
|
|
// @Description 操作网站日志
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsiteDefaultUpdate true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/default/server [post]
|
2023-05-30 15:30:57 +08:00
|
|
|
// @x-panel-log {"bodyKeys":["id", "operate"],"paramKeys":[],"BeforeFuntions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"修改默认 server => [domain]","formatEN":"Change default server => [domain]"}
|
2023-01-03 16:56:36 +08:00
|
|
|
func (b *BaseApi) ChangeDefaultServer(c *gin.Context) {
|
|
|
|
var req request.WebsiteDefaultUpdate
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if err := websiteService.ChangeDefaultServer(req.ID); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, nil)
|
|
|
|
}
|
2023-04-06 00:09:58 +08:00
|
|
|
|
|
|
|
// @Tags Website
|
|
|
|
// @Summary Load websit php conf
|
|
|
|
// @Description 获取网站 php 配置
|
|
|
|
// @Accept json
|
|
|
|
// @Param id path integer true "request"
|
|
|
|
// @Success 200 {object} response.PHPConfig
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/php/config/:id [get]
|
|
|
|
func (b *BaseApi) GetWebsitePHPConfig(c *gin.Context) {
|
|
|
|
id, err := helper.GetParamID(c)
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
data, err := websiteService.GetPHPConfig(id)
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, data)
|
|
|
|
}
|
|
|
|
|
|
|
|
// @Tags Website PHP
|
|
|
|
// @Summary Update website php conf
|
|
|
|
// @Description 更新 网站 PHP 配置
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsitePHPConfigUpdate true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
2023-04-12 14:48:30 +08:00
|
|
|
// @Router /websites/php/config [post]
|
2023-05-30 15:30:57 +08:00
|
|
|
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFuntions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"[domain] PHP 配置修改","formatEN":"[domain] PHP conf update"}
|
2023-04-06 00:09:58 +08:00
|
|
|
func (b *BaseApi) UpdateWebsitePHPConfig(c *gin.Context) {
|
|
|
|
var req request.WebsitePHPConfigUpdate
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if err := websiteService.UpdatePHPConfig(req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, nil)
|
|
|
|
}
|
2023-04-12 14:48:30 +08:00
|
|
|
|
|
|
|
// @Tags Website PHP
|
|
|
|
// @Summary Update php conf
|
2023-06-30 23:24:16 +08:00
|
|
|
// @Description 更新 php 配置文件
|
2023-04-12 14:48:30 +08:00
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsitePHPFileUpdate true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/php/update [post]
|
2023-05-30 15:30:57 +08:00
|
|
|
// @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFuntions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"php 配置修改 [domain]","formatEN":"Nginx conf update [domain]"}
|
2023-04-12 14:48:30 +08:00
|
|
|
func (b *BaseApi) UpdatePHPFile(c *gin.Context) {
|
|
|
|
var req request.WebsitePHPFileUpdate
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if err := websiteService.UpdatePHPConfigFile(req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, nil)
|
|
|
|
}
|
2023-04-14 16:01:06 +08:00
|
|
|
|
2023-07-25 17:20:25 +08:00
|
|
|
// @Tags Website PHP
|
|
|
|
// @Summary Update php version
|
|
|
|
// @Description 变更 php 版本
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsitePHPVersionReq true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/php/version [post]
|
|
|
|
// @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFuntions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"php 版本变更 [domain]","formatEN":"php version update [domain]"}
|
|
|
|
func (b *BaseApi) ChangePHPVersion(c *gin.Context) {
|
|
|
|
var req request.WebsitePHPVersionReq
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if err := websiteService.ChangePHPVersion(req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithOutData(c)
|
|
|
|
}
|
|
|
|
|
2023-04-14 16:01:06 +08:00
|
|
|
// @Tags Website
|
|
|
|
// @Summary Get rewrite conf
|
|
|
|
// @Description 获取伪静态配置
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.NginxRewriteReq true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/rewrite [post]
|
|
|
|
func (b *BaseApi) GetRewriteConfig(c *gin.Context) {
|
|
|
|
var req request.NginxRewriteReq
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
res, err := websiteService.GetRewriteConfig(req)
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, res)
|
|
|
|
}
|
|
|
|
|
|
|
|
// @Tags Website
|
|
|
|
// @Summary Update rewrite conf
|
|
|
|
// @Description 更新伪静态配置
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.NginxRewriteUpdate true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/rewrite/update [post]
|
2023-05-30 15:30:57 +08:00
|
|
|
// @x-panel-log {"bodyKeys":["websiteID"],"paramKeys":[],"BeforeFuntions":[{"input_column":"id","input_value":"websiteID","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"伪静态配置修改 [domain]","formatEN":"Nginx conf rewrite update [domain]"}
|
2023-04-14 16:01:06 +08:00
|
|
|
func (b *BaseApi) UpdateRewriteConfig(c *gin.Context) {
|
|
|
|
var req request.NginxRewriteUpdate
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if err := websiteService.UpdateRewriteConfig(req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, nil)
|
|
|
|
}
|
2023-04-17 16:54:34 +08:00
|
|
|
|
|
|
|
// @Tags Website
|
|
|
|
// @Summary Update Site Dir
|
|
|
|
// @Description 更新网站目录
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsiteUpdateDir true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/dir/update [post]
|
2023-05-30 15:30:57 +08:00
|
|
|
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFuntions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新网站 [domain] 目录","formatEN":"Update domain [domain] dir"}
|
2023-04-17 16:54:34 +08:00
|
|
|
func (b *BaseApi) UpdateSiteDir(c *gin.Context) {
|
|
|
|
var req request.WebsiteUpdateDir
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if err := websiteService.UpdateSiteDir(req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithOutData(c)
|
|
|
|
}
|
2023-04-18 18:46:58 +08:00
|
|
|
|
|
|
|
// @Tags Website
|
|
|
|
// @Summary Update Site Dir permission
|
|
|
|
// @Description 更新网站目录权限
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsiteUpdateDirPermission true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/dir/permission [post]
|
2023-05-30 15:30:57 +08:00
|
|
|
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFuntions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新网站 [domain] 目录权限","formatEN":"Update domain [domain] dir permission"}
|
2023-04-18 18:46:58 +08:00
|
|
|
func (b *BaseApi) UpdateSiteDirPermission(c *gin.Context) {
|
|
|
|
var req request.WebsiteUpdateDirPermission
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if err := websiteService.UpdateSitePermission(req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithOutData(c)
|
|
|
|
}
|
2023-04-23 18:15:38 +08:00
|
|
|
|
|
|
|
// @Tags Website
|
|
|
|
// @Summary Get proxy conf
|
|
|
|
// @Description 获取反向代理配置
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsiteProxyReq true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/proxies [post]
|
|
|
|
func (b *BaseApi) GetProxyConfig(c *gin.Context) {
|
|
|
|
var req request.WebsiteProxyReq
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
res, err := websiteService.GetProxies(req.ID)
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, res)
|
|
|
|
}
|
|
|
|
|
|
|
|
// @Tags Website
|
|
|
|
// @Summary Update proxy conf
|
|
|
|
// @Description 修改反向代理配置
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsiteProxyConfig true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/proxies/update [post]
|
2023-05-30 15:30:57 +08:00
|
|
|
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFuntions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"修改网站 [domain] 反向代理配置 ","formatEN":"Update domain [domain] proxy config"}
|
2023-04-23 18:15:38 +08:00
|
|
|
func (b *BaseApi) UpdateProxyConfig(c *gin.Context) {
|
|
|
|
var req request.WebsiteProxyConfig
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
err := websiteService.OperateProxy(req)
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
2023-04-24 17:48:22 +08:00
|
|
|
helper.SuccessWithOutData(c)
|
|
|
|
}
|
|
|
|
|
|
|
|
// @Tags Website
|
|
|
|
// @Summary Update proxy file
|
|
|
|
// @Description 更新反向代理文件
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.NginxProxyUpdate true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/proxy/file [post]
|
2023-05-30 15:30:57 +08:00
|
|
|
// @x-panel-log {"bodyKeys":["websiteID"],"paramKeys":[],"BeforeFuntions":[{"input_column":"id","input_value":"websiteID","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新反向代理文件 [domain]","formatEN":"Nginx conf proxy file update [domain]"}
|
2023-04-24 17:48:22 +08:00
|
|
|
func (b *BaseApi) UpdateProxyConfigFile(c *gin.Context) {
|
|
|
|
var req request.NginxProxyUpdate
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if err := websiteService.UpdateProxyFile(req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithOutData(c)
|
2023-04-23 18:15:38 +08:00
|
|
|
}
|
2023-04-25 18:10:17 +08:00
|
|
|
|
|
|
|
// @Tags Website
|
|
|
|
// @Summary Get AuthBasic conf
|
|
|
|
// @Description 获取密码访问配置
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.NginxAuthReq true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/auths [post]
|
|
|
|
func (b *BaseApi) GetAuthConfig(c *gin.Context) {
|
|
|
|
var req request.NginxAuthReq
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
res, err := websiteService.GetAuthBasics(req)
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, res)
|
|
|
|
}
|
|
|
|
|
|
|
|
// @Tags Website
|
|
|
|
// @Summary Get AuthBasic conf
|
|
|
|
// @Description 更新密码访问配置
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.NginxAuthUpdate true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/auths/update [post]
|
|
|
|
func (b *BaseApi) UpdateAuthConfig(c *gin.Context) {
|
|
|
|
var req request.NginxAuthUpdate
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if err := websiteService.UpdateAuthBasic(req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithOutData(c)
|
|
|
|
}
|
2023-05-26 10:40:21 +08:00
|
|
|
|
|
|
|
// @Tags Website
|
|
|
|
// @Summary Get AntiLeech conf
|
|
|
|
// @Description 获取防盗链配置
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.NginxCommonReq true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/leech [post]
|
|
|
|
func (b *BaseApi) GetAntiLeech(c *gin.Context) {
|
|
|
|
var req request.NginxCommonReq
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
res, err := websiteService.GetAntiLeech(req.WebsiteID)
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, res)
|
|
|
|
}
|
|
|
|
|
|
|
|
// @Tags Website
|
|
|
|
// @Summary Update AntiLeech
|
|
|
|
// @Description 更新防盗链配置
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.NginxAntiLeechUpdate true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/leech/update [post]
|
|
|
|
func (b *BaseApi) UpdateAntiLeech(c *gin.Context) {
|
|
|
|
var req request.NginxAntiLeechUpdate
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if err := websiteService.UpdateAntiLeech(req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithOutData(c)
|
|
|
|
}
|
2023-07-22 22:02:21 +08:00
|
|
|
|
|
|
|
// @Tags Website
|
|
|
|
// @Summary Update redirect conf
|
|
|
|
// @Description 修改重定向配置
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.NginxRedirectReq true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/redirect/update [post]
|
|
|
|
// @x-panel-log {"bodyKeys":["websiteID"],"paramKeys":[],"BeforeFuntions":[{"input_column":"id","input_value":"websiteID","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"修改网站 [domain] 重定向理配置 ","formatEN":"Update domain [domain] redirect config"}
|
|
|
|
func (b *BaseApi) UpdateRedirectConfig(c *gin.Context) {
|
|
|
|
var req request.NginxRedirectReq
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
err := websiteService.OperateRedirect(req)
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithOutData(c)
|
|
|
|
}
|
|
|
|
|
|
|
|
// @Tags Website
|
|
|
|
// @Summary Get redirect conf
|
|
|
|
// @Description 获取重定向配置
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.WebsiteProxyReq true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/redirect [post]
|
|
|
|
func (b *BaseApi) GetRedirectConfig(c *gin.Context) {
|
|
|
|
var req request.WebsiteRedirectReq
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
res, err := websiteService.GetRedirect(req.WebsiteID)
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithData(c, res)
|
|
|
|
}
|
|
|
|
|
|
|
|
// @Tags Website
|
|
|
|
// @Summary Update redirect file
|
|
|
|
// @Description 更新重定向文件
|
|
|
|
// @Accept json
|
|
|
|
// @Param request body request.NginxRedirectUpdate true "request"
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /websites/redirect/file [post]
|
|
|
|
// @x-panel-log {"bodyKeys":["websiteID"],"paramKeys":[],"BeforeFuntions":[{"input_column":"id","input_value":"websiteID","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新重定向文件 [domain]","formatEN":"Nginx conf redirect file update [domain]"}
|
|
|
|
func (b *BaseApi) UpdateRedirectConfigFile(c *gin.Context) {
|
|
|
|
var req request.NginxRedirectUpdate
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if err := websiteService.UpdateRedirectFile(req); err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
helper.SuccessWithOutData(c)
|
|
|
|
}
|