mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-02-07 17:10:07 +08:00
style: 修改website的API和model
This commit is contained in:
parent
2a0f2dcd6a
commit
09ef0ebc80
@ -37,9 +37,9 @@ var (
|
|||||||
|
|
||||||
websiteGroupService = service.ServiceGroupApp.WebsiteGroupService
|
websiteGroupService = service.ServiceGroupApp.WebsiteGroupService
|
||||||
websiteService = service.ServiceGroupApp.WebsiteService
|
websiteService = service.ServiceGroupApp.WebsiteService
|
||||||
websiteDnsAccountService = service.ServiceGroupApp.WebSiteDnsAccountService
|
websiteDnsAccountService = service.ServiceGroupApp.WebsiteDnsAccountService
|
||||||
websiteSSLService = service.ServiceGroupApp.WebSiteSSLService
|
websiteSSLService = service.ServiceGroupApp.WebsiteSSLService
|
||||||
websiteAcmeAccountService = service.ServiceGroupApp.WebSiteAcmeAccountService
|
websiteAcmeAccountService = service.ServiceGroupApp.WebsiteAcmeAccountService
|
||||||
|
|
||||||
nginxService = service.ServiceGroupApp.NginxService
|
nginxService = service.ServiceGroupApp.NginxService
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package v1
|
|||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/request"
|
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
@ -4,19 +4,19 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/request"
|
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||||
"github.com/1Panel-dev/1Panel/backend/global"
|
"github.com/1Panel-dev/1Panel/backend/global"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (b *BaseApi) PageWebsite(c *gin.Context) {
|
func (b *BaseApi) PageWebsite(c *gin.Context) {
|
||||||
var req dto.WebSiteReq
|
var req request.WebsiteSearch
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
total, websites, err := websiteService.PageWebSite(req)
|
total, websites, err := websiteService.PageWebsite(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -37,7 +37,7 @@ func (b *BaseApi) GetWebsiteOptions(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *BaseApi) CreateWebsite(c *gin.Context) {
|
func (b *BaseApi) CreateWebsite(c *gin.Context) {
|
||||||
var req dto.WebSiteCreate
|
var req request.WebsiteCreate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||||
return
|
return
|
||||||
@ -64,7 +64,7 @@ func (b *BaseApi) BackupWebsite(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *BaseApi) RecoverWebsiteByUpload(c *gin.Context) {
|
func (b *BaseApi) RecoverWebsiteByUpload(c *gin.Context) {
|
||||||
var req dto.WebSiteRecoverByFile
|
var req request.WebsiteRecoverByFile
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||||
return
|
return
|
||||||
@ -82,7 +82,7 @@ func (b *BaseApi) RecoverWebsiteByUpload(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *BaseApi) RecoverWebsite(c *gin.Context) {
|
func (b *BaseApi) RecoverWebsite(c *gin.Context) {
|
||||||
var req dto.WebSiteRecover
|
var req request.WebsiteRecover
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||||
return
|
return
|
||||||
@ -99,13 +99,13 @@ func (b *BaseApi) RecoverWebsite(c *gin.Context) {
|
|||||||
helper.SuccessWithData(c, nil)
|
helper.SuccessWithData(c, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BaseApi) DeleteWebSite(c *gin.Context) {
|
func (b *BaseApi) DeleteWebsite(c *gin.Context) {
|
||||||
var req request.WebSiteDel
|
var req request.WebsiteDelete
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := websiteService.DeleteWebSite(req)
|
err := websiteService.DeleteWebsite(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
@ -113,8 +113,8 @@ func (b *BaseApi) DeleteWebSite(c *gin.Context) {
|
|||||||
helper.SuccessWithData(c, nil)
|
helper.SuccessWithData(c, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BaseApi) UpdateWebSite(c *gin.Context) {
|
func (b *BaseApi) UpdateWebsite(c *gin.Context) {
|
||||||
var req dto.WebSiteUpdate
|
var req request.WebsiteUpdate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||||
return
|
return
|
||||||
@ -126,8 +126,7 @@ func (b *BaseApi) UpdateWebSite(c *gin.Context) {
|
|||||||
helper.SuccessWithData(c, nil)
|
helper.SuccessWithData(c, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BaseApi) GetWebSite(c *gin.Context) {
|
func (b *BaseApi) GetWebsite(c *gin.Context) {
|
||||||
|
|
||||||
id, err := helper.GetParamID(c)
|
id, err := helper.GetParamID(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
||||||
@ -141,8 +140,7 @@ func (b *BaseApi) GetWebSite(c *gin.Context) {
|
|||||||
helper.SuccessWithData(c, website)
|
helper.SuccessWithData(c, website)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BaseApi) GetWebSiteNginx(c *gin.Context) {
|
func (b *BaseApi) GetWebsiteNginx(c *gin.Context) {
|
||||||
|
|
||||||
id, err := helper.GetParamID(c)
|
id, err := helper.GetParamID(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
||||||
@ -157,13 +155,11 @@ func (b *BaseApi) GetWebSiteNginx(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *BaseApi) GetWebDomains(c *gin.Context) {
|
func (b *BaseApi) GetWebDomains(c *gin.Context) {
|
||||||
|
|
||||||
websiteId, err := helper.GetIntParamByKey(c, "websiteId")
|
websiteId, err := helper.GetIntParamByKey(c, "websiteId")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
list, err := websiteService.GetWebsiteDomain(websiteId)
|
list, err := websiteService.GetWebsiteDomain(websiteId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
@ -173,14 +169,13 @@ func (b *BaseApi) GetWebDomains(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *BaseApi) DeleteWebDomain(c *gin.Context) {
|
func (b *BaseApi) DeleteWebDomain(c *gin.Context) {
|
||||||
|
var req request.WebsiteDomainDelete
|
||||||
id, err := helper.GetParamID(c)
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
if err != nil {
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := websiteService.DeleteWebsiteDomain(id); err != nil {
|
if err := websiteService.DeleteWebsiteDomain(req.ID); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -188,7 +183,7 @@ func (b *BaseApi) DeleteWebDomain(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *BaseApi) CreateWebDomain(c *gin.Context) {
|
func (b *BaseApi) CreateWebDomain(c *gin.Context) {
|
||||||
var req dto.WebSiteDomainCreate
|
var req request.WebsiteDomainCreate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||||
return
|
return
|
||||||
@ -243,7 +238,7 @@ func (b *BaseApi) GetHTTPSConfig(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *BaseApi) UpdateHTTPSConfig(c *gin.Context) {
|
func (b *BaseApi) UpdateHTTPSConfig(c *gin.Context) {
|
||||||
var req dto.WebsiteHTTPSOp
|
var req request.WebsiteHTTPSOp
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||||
return
|
return
|
||||||
@ -257,7 +252,7 @@ func (b *BaseApi) UpdateHTTPSConfig(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *BaseApi) CreateWebsiteCheck(c *gin.Context) {
|
func (b *BaseApi) CreateWebsiteCheck(c *gin.Context) {
|
||||||
var req dto.WebsiteInstallCheckReq
|
var req request.WebsiteInstallCheckReq
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||||
return
|
return
|
||||||
|
@ -2,7 +2,7 @@ package v1
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
@ -17,7 +17,7 @@ func (b *BaseApi) GetWebGroups(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *BaseApi) CreateWebGroup(c *gin.Context) {
|
func (b *BaseApi) CreateWebGroup(c *gin.Context) {
|
||||||
var req dto.WebSiteGroupCreate
|
var req request.WebsiteGroupCreate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||||
return
|
return
|
||||||
@ -30,7 +30,7 @@ func (b *BaseApi) CreateWebGroup(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *BaseApi) UpdateWebGroup(c *gin.Context) {
|
func (b *BaseApi) UpdateWebGroup(c *gin.Context) {
|
||||||
var req dto.WebSiteGroupUpdate
|
var req request.WebsiteGroupUpdate
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||||
return
|
return
|
||||||
@ -43,13 +43,11 @@ func (b *BaseApi) UpdateWebGroup(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *BaseApi) DeleteWebGroup(c *gin.Context) {
|
func (b *BaseApi) DeleteWebGroup(c *gin.Context) {
|
||||||
|
|
||||||
groupId, err := helper.GetIntParamByKey(c, "groupId")
|
groupId, err := helper.GetIntParamByKey(c, "groupId")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := websiteGroupService.DeleteGroup(groupId); err != nil {
|
if err := websiteGroupService.DeleteGroup(groupId); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
return
|
return
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
type NginxFull struct {
|
type NginxFull struct {
|
||||||
Install model.AppInstall
|
Install model.AppInstall
|
||||||
Website model.WebSite
|
Website model.Website
|
||||||
ConfigDir string
|
ConfigDir string
|
||||||
ConfigFile string
|
ConfigFile string
|
||||||
SiteDir string
|
SiteDir string
|
||||||
@ -25,7 +25,7 @@ type NginxConfig struct {
|
|||||||
type NginxConfigReq struct {
|
type NginxConfigReq struct {
|
||||||
Scope NginxKey `json:"scope"`
|
Scope NginxKey `json:"scope"`
|
||||||
Operate NginxOp `json:"operate"`
|
Operate NginxOp `json:"operate"`
|
||||||
WebSiteID uint `json:"webSiteId"`
|
WebsiteID uint `json:"webSiteId"`
|
||||||
Params interface{} `json:"params"`
|
Params interface{} `json:"params"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
100
backend/app/dto/request/website.go
Normal file
100
backend/app/dto/request/website.go
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
package request
|
||||||
|
|
||||||
|
import "github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||||
|
|
||||||
|
type WebsiteSearch struct {
|
||||||
|
dto.PageInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
type WebsiteCreate struct {
|
||||||
|
PrimaryDomain string `json:"primaryDomain" validate:"required"`
|
||||||
|
Type string `json:"type" validate:"required"`
|
||||||
|
Alias string `json:"alias" validate:"required"`
|
||||||
|
Remark string `json:"remark"`
|
||||||
|
OtherDomains string `json:"otherDomains"`
|
||||||
|
Proxy string `json:"proxy"`
|
||||||
|
WebsiteGroupID uint `json:"webSiteGroupID" validate:"required"`
|
||||||
|
|
||||||
|
AppType string `json:"appType" validate:"oneof=new installed"`
|
||||||
|
AppInstall NewAppInstall `json:"appInstall"`
|
||||||
|
AppID uint `json:"appID"`
|
||||||
|
AppInstallID uint `json:"appInstallID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type NewAppInstall struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
AppDetailId uint `json:"appDetailID"`
|
||||||
|
Params map[string]interface{} `json:"params"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WebsiteInstallCheckReq struct {
|
||||||
|
InstallIds []uint `json:"InstallIds" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WebsiteUpdate struct {
|
||||||
|
ID uint `json:"id" validate:"required"`
|
||||||
|
PrimaryDomain string `json:"primaryDomain" validate:"required"`
|
||||||
|
Remark string `json:"remark"`
|
||||||
|
WebsiteGroupID uint `json:"webSiteGroupID" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WebsiteDelete struct {
|
||||||
|
ID uint `json:"id" validate:"required"`
|
||||||
|
DeleteApp bool `json:"deleteApp"`
|
||||||
|
DeleteBackup bool `json:"deleteBackup"`
|
||||||
|
ForceDelete bool `json:"forceDelete"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WebsiteWafReq struct {
|
||||||
|
WebsiteID uint `json:"websiteId" validate:"required"`
|
||||||
|
Key string `json:"key" validate:"required"`
|
||||||
|
Rule string `json:"rule" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WebsiteWafUpdate struct {
|
||||||
|
WebsiteID uint `json:"websiteId" validate:"required"`
|
||||||
|
Key string `json:"key" validate:"required"`
|
||||||
|
Enable bool `json:"enable" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WebsiteRecover struct {
|
||||||
|
WebsiteName string `json:"websiteName" validate:"required"`
|
||||||
|
Type string `json:"type" validate:"required"`
|
||||||
|
BackupName string `json:"backupName" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WebsiteRecoverByFile struct {
|
||||||
|
WebsiteName string `json:"websiteName" validate:"required"`
|
||||||
|
Type string `json:"type" validate:"required"`
|
||||||
|
FileDir string `json:"fileDir" validate:"required"`
|
||||||
|
FileName string `json:"fileName" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WebsiteGroupCreate struct {
|
||||||
|
Name string `json:"name" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WebsiteGroupUpdate struct {
|
||||||
|
ID uint `json:"id" validate:"required"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Default bool `json:"default"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WebsiteDomainCreate struct {
|
||||||
|
WebsiteID uint `json:"websiteId" validate:"required"`
|
||||||
|
Port int `json:"port" validate:"required"`
|
||||||
|
Domain string `json:"domain" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WebsiteDomainDelete struct {
|
||||||
|
ID uint `json:"id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WebsiteHTTPSOp struct {
|
||||||
|
WebsiteID uint `json:"websiteId" validate:"required"`
|
||||||
|
Enable bool `json:"enable" validate:"required"`
|
||||||
|
WebsiteSSLID uint `json:"websiteSSLId"`
|
||||||
|
Type string `json:"type" validate:"oneof=existed auto manual"`
|
||||||
|
PrivateKey string `json:"privateKey"`
|
||||||
|
Certificate string `json:"certificate"`
|
||||||
|
}
|
33
backend/app/dto/response/website.go
Normal file
33
backend/app/dto/response/website.go
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package response
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||||
|
"github.com/1Panel-dev/1Panel/backend/app/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
type WebsiteDTO struct {
|
||||||
|
model.Website
|
||||||
|
}
|
||||||
|
|
||||||
|
type WebsitePreInstallCheck struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
Version string `json:"version"`
|
||||||
|
AppName string `json:"appName"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WebsiteNginxConfig struct {
|
||||||
|
Enable bool `json:"enable"`
|
||||||
|
Params []dto.NginxParam `json:"params"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WebsiteWafConfig struct {
|
||||||
|
Enable bool `json:"enable"`
|
||||||
|
FilePath string `json:"filePath"`
|
||||||
|
Content string `json:"content"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WebsiteHTTPS struct {
|
||||||
|
Enable bool `json:"enable"`
|
||||||
|
SSL model.WebsiteSSL `json:"SSL"`
|
||||||
|
}
|
@ -1,124 +1 @@
|
|||||||
package dto
|
package dto
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/model"
|
|
||||||
)
|
|
||||||
|
|
||||||
type WebSiteReq struct {
|
|
||||||
PageInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
type AppType string
|
|
||||||
|
|
||||||
const (
|
|
||||||
NewApp AppType = "new"
|
|
||||||
InstalledApp AppType = "installed"
|
|
||||||
)
|
|
||||||
|
|
||||||
type WebSiteCreate struct {
|
|
||||||
PrimaryDomain string `json:"primaryDomain" validate:"required"`
|
|
||||||
Type string `json:"type" validate:"required"`
|
|
||||||
Alias string `json:"alias" validate:"required"`
|
|
||||||
Remark string `json:"remark"`
|
|
||||||
OtherDomains string `json:"otherDomains"`
|
|
||||||
Proxy string `json:"proxy"`
|
|
||||||
AppType AppType `json:"appType"`
|
|
||||||
AppInstall NewAppInstall `json:"appInstall"`
|
|
||||||
AppID uint `json:"appID"`
|
|
||||||
AppInstallID uint `json:"appInstallID"`
|
|
||||||
WebSiteGroupID uint `json:"webSiteGroupID" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type WebsiteDTO struct {
|
|
||||||
model.WebSite
|
|
||||||
}
|
|
||||||
|
|
||||||
type WebSiteUpdate struct {
|
|
||||||
ID uint `json:"id" validate:"required"`
|
|
||||||
PrimaryDomain string `json:"primaryDomain" validate:"required"`
|
|
||||||
Remark string `json:"remark"`
|
|
||||||
WebSiteGroupID uint `json:"webSiteGroupID" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type NewAppInstall struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
AppDetailId uint `json:"appDetailID"`
|
|
||||||
Params map[string]interface{} `json:"params"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type WebSiteRecover struct {
|
|
||||||
WebsiteName string `json:"websiteName" validate:"required"`
|
|
||||||
Type string `json:"type" validate:"required"`
|
|
||||||
BackupName string `json:"backupName" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type WebSiteRecoverByFile struct {
|
|
||||||
WebsiteName string `json:"websiteName" validate:"required"`
|
|
||||||
Type string `json:"type" validate:"required"`
|
|
||||||
FileDir string `json:"fileDir" validate:"required"`
|
|
||||||
FileName string `json:"fileName" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type WebSiteDTO struct {
|
|
||||||
model.WebSite
|
|
||||||
}
|
|
||||||
|
|
||||||
type WebSiteGroupCreate struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type WebSiteGroupUpdate struct {
|
|
||||||
ID uint `json:"id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
Default bool `json:"default"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type WebSiteDomainCreate struct {
|
|
||||||
WebSiteID uint `json:"webSiteId"`
|
|
||||||
Port int `json:"port"`
|
|
||||||
Domain string `json:"domain"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type WebsiteHTTPS struct {
|
|
||||||
Enable bool `json:"enable"`
|
|
||||||
SSL model.WebSiteSSL `json:"SSL"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SSlType string
|
|
||||||
|
|
||||||
const (
|
|
||||||
SSLExisted SSlType = "existed"
|
|
||||||
SSLAuto SSlType = "auto"
|
|
||||||
SSLManual SSlType = "manual"
|
|
||||||
)
|
|
||||||
|
|
||||||
type WebsiteHTTPSOp struct {
|
|
||||||
WebsiteID uint `json:"websiteId" validate:"required"`
|
|
||||||
Enable bool `json:"enable" validate:"required"`
|
|
||||||
WebsiteSSLID uint `json:"websiteSSLId"`
|
|
||||||
Type SSlType `json:"type"`
|
|
||||||
PrivateKey string `json:"privateKey"`
|
|
||||||
Certificate string `json:"certificate"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type WebsiteNginxConfig struct {
|
|
||||||
Enable bool `json:"enable"`
|
|
||||||
Params []NginxParam `json:"params"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type WebsitePreInstallCheck struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
Status string `json:"status"`
|
|
||||||
Version string `json:"version"`
|
|
||||||
AppName string `json:"appName"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type WebsiteInstallCheckReq struct {
|
|
||||||
InstallIds []uint `json:"InstallIds"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type WebsiteWafConfig struct {
|
|
||||||
Enable bool `json:"enable"`
|
|
||||||
FilePath string `json:"filePath"`
|
|
||||||
Content string `json:"content"`
|
|
||||||
}
|
|
||||||
|
@ -3,7 +3,7 @@ package dto
|
|||||||
import "github.com/1Panel-dev/1Panel/backend/app/model"
|
import "github.com/1Panel-dev/1Panel/backend/app/model"
|
||||||
|
|
||||||
type WebsiteSSLDTO struct {
|
type WebsiteSSLDTO struct {
|
||||||
model.WebSiteSSL
|
model.WebsiteSSL
|
||||||
}
|
}
|
||||||
|
|
||||||
type SSLProvider string
|
type SSLProvider string
|
||||||
|
@ -2,7 +2,7 @@ package model
|
|||||||
|
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
type WebSite struct {
|
type Website struct {
|
||||||
BaseModel
|
BaseModel
|
||||||
Protocol string `gorm:"type:varchar(64);not null" json:"protocol"`
|
Protocol string `gorm:"type:varchar(64);not null" json:"protocol"`
|
||||||
PrimaryDomain string `gorm:"type:varchar(128);not null" json:"primaryDomain"`
|
PrimaryDomain string `gorm:"type:varchar(128);not null" json:"primaryDomain"`
|
||||||
@ -12,13 +12,13 @@ type WebSite struct {
|
|||||||
Status string `gorm:"type:varchar(64);not null" json:"status"`
|
Status string `gorm:"type:varchar(64);not null" json:"status"`
|
||||||
ExpireDate time.Time `json:"expireDate"`
|
ExpireDate time.Time `json:"expireDate"`
|
||||||
AppInstallID uint `gorm:"type:integer" json:"appInstallId"`
|
AppInstallID uint `gorm:"type:integer" json:"appInstallId"`
|
||||||
WebSiteGroupID uint `gorm:"type:integer" json:"webSiteGroupId"`
|
WebsiteGroupID uint `gorm:"type:integer" json:"webSiteGroupId"`
|
||||||
WebSiteSSLID uint `gorm:"type:integer" json:"webSiteSSLId"`
|
WebsiteSSLID uint `gorm:"type:integer" json:"webSiteSSLId"`
|
||||||
Proxy string `gorm:"type:varchar(128);not null" json:"proxy"`
|
Proxy string `gorm:"type:varchar(128);not null" json:"proxy"`
|
||||||
Domains []WebSiteDomain `json:"domains"`
|
Domains []WebsiteDomain `json:"domains"`
|
||||||
WebSiteSSL WebSiteSSL `json:"webSiteSSL"`
|
WebsiteSSL WebsiteSSL `json:"webSiteSSL"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSite) TableName() string {
|
func (w Website) TableName() string {
|
||||||
return "websites"
|
return "websites"
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
type WebSiteDomain struct {
|
type WebsiteDomain struct {
|
||||||
BaseModel
|
BaseModel
|
||||||
WebSiteID uint `gorm:"type:varchar(64);not null" json:"web_site_id"`
|
WebsiteID uint `gorm:"column:website_id;type:varchar(64);not null;" json:"websiteId"`
|
||||||
Domain string `gorm:"type:varchar(256);not null" json:"domain"`
|
Domain string `gorm:"type:varchar(256);not null" json:"domain"`
|
||||||
Port int `gorm:"type:integer" json:"port"`
|
Port int `gorm:"type:integer" json:"port"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteDomain) TableName() string {
|
func (w WebsiteDomain) TableName() string {
|
||||||
return "website_domains"
|
return "website_domains"
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
type WebSiteGroup struct {
|
type WebsiteGroup struct {
|
||||||
BaseModel
|
BaseModel
|
||||||
Name string `gorm:"type:varchar(64);not null" json:"name"`
|
Name string `gorm:"type:varchar(64);not null" json:"name"`
|
||||||
Default bool `json:"default"`
|
Default bool `json:"default"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteGroup) TableName() string {
|
func (w WebsiteGroup) TableName() string {
|
||||||
return "website_groups"
|
return "website_groups"
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package model
|
|||||||
|
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
type WebSiteSSL struct {
|
type WebsiteSSL struct {
|
||||||
BaseModel
|
BaseModel
|
||||||
PrimaryDomain string `gorm:"type:varchar(256);not null" json:"primaryDomain"`
|
PrimaryDomain string `gorm:"type:varchar(256);not null" json:"primaryDomain"`
|
||||||
PrivateKey string `gorm:"type:longtext;not null" json:"privateKey"`
|
PrivateKey string `gorm:"type:longtext;not null" json:"privateKey"`
|
||||||
@ -19,6 +19,6 @@ type WebSiteSSL struct {
|
|||||||
StartDate time.Time `json:"startDate"`
|
StartDate time.Time `json:"startDate"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteSSL) TableName() string {
|
func (w WebsiteSSL) TableName() string {
|
||||||
return "website_ssls"
|
return "website_ssls"
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,9 @@ type RepoGroup struct {
|
|||||||
GroupRepo
|
GroupRepo
|
||||||
SettingRepo
|
SettingRepo
|
||||||
BackupRepo
|
BackupRepo
|
||||||
WebSiteRepo
|
WebsiteRepo
|
||||||
WebSiteDomainRepo
|
WebsiteDomainRepo
|
||||||
WebSiteGroupRepo
|
WebsiteGroupRepo
|
||||||
WebsiteDnsAccountRepo
|
WebsiteDnsAccountRepo
|
||||||
WebsiteSSLRepo
|
WebsiteSSLRepo
|
||||||
WebsiteAcmeAccountRepo
|
WebsiteAcmeAccountRepo
|
||||||
|
@ -13,80 +13,80 @@ type IWebsiteRepo interface {
|
|||||||
WithDomain(domain string) DBOption
|
WithDomain(domain string) DBOption
|
||||||
WithAlias(alias string) DBOption
|
WithAlias(alias string) DBOption
|
||||||
WithWebsiteSSLID(sslId uint) DBOption
|
WithWebsiteSSLID(sslId uint) DBOption
|
||||||
Page(page, size int, opts ...DBOption) (int64, []model.WebSite, error)
|
Page(page, size int, opts ...DBOption) (int64, []model.Website, error)
|
||||||
GetFirst(opts ...DBOption) (model.WebSite, error)
|
GetFirst(opts ...DBOption) (model.Website, error)
|
||||||
GetBy(opts ...DBOption) ([]model.WebSite, error)
|
GetBy(opts ...DBOption) ([]model.Website, error)
|
||||||
Save(ctx context.Context, app *model.WebSite) error
|
Save(ctx context.Context, app *model.Website) error
|
||||||
DeleteBy(ctx context.Context, opts ...DBOption) error
|
DeleteBy(ctx context.Context, opts ...DBOption) error
|
||||||
Create(ctx context.Context, app *model.WebSite) error
|
Create(ctx context.Context, app *model.Website) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewIWebsiteRepo() IWebsiteRepo {
|
func NewIWebsiteRepo() IWebsiteRepo {
|
||||||
return &WebSiteRepo{}
|
return &WebsiteRepo{}
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebSiteRepo struct {
|
type WebsiteRepo struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WebSiteRepo) WithAppInstallId(appInstallId uint) DBOption {
|
func (w *WebsiteRepo) WithAppInstallId(appInstallId uint) DBOption {
|
||||||
return func(db *gorm.DB) *gorm.DB {
|
return func(db *gorm.DB) *gorm.DB {
|
||||||
return db.Where("app_install_id = ?", appInstallId)
|
return db.Where("app_install_id = ?", appInstallId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WebSiteRepo) WithDomain(domain string) DBOption {
|
func (w *WebsiteRepo) WithDomain(domain string) DBOption {
|
||||||
return func(db *gorm.DB) *gorm.DB {
|
return func(db *gorm.DB) *gorm.DB {
|
||||||
return db.Where("primary_domain = ?", domain)
|
return db.Where("primary_domain = ?", domain)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WebSiteRepo) WithAlias(alias string) DBOption {
|
func (w *WebsiteRepo) WithAlias(alias string) DBOption {
|
||||||
return func(db *gorm.DB) *gorm.DB {
|
return func(db *gorm.DB) *gorm.DB {
|
||||||
return db.Where("alias = ?", alias)
|
return db.Where("alias = ?", alias)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WebSiteRepo) WithWebsiteSSLID(sslId uint) DBOption {
|
func (w *WebsiteRepo) WithWebsiteSSLID(sslId uint) DBOption {
|
||||||
return func(db *gorm.DB) *gorm.DB {
|
return func(db *gorm.DB) *gorm.DB {
|
||||||
return db.Where("web_site_ssl_id = ?", sslId)
|
return db.Where("web_site_ssl_id = ?", sslId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WebSiteRepo) Page(page, size int, opts ...DBOption) (int64, []model.WebSite, error) {
|
func (w *WebsiteRepo) Page(page, size int, opts ...DBOption) (int64, []model.Website, error) {
|
||||||
var websites []model.WebSite
|
var websites []model.Website
|
||||||
db := getDb(opts...).Model(&model.WebSite{})
|
db := getDb(opts...).Model(&model.Website{})
|
||||||
count := int64(0)
|
count := int64(0)
|
||||||
db = db.Count(&count)
|
db = db.Count(&count)
|
||||||
err := db.Debug().Limit(size).Offset(size * (page - 1)).Preload("WebSiteSSL").Find(&websites).Error
|
err := db.Debug().Limit(size).Offset(size * (page - 1)).Preload("WebsiteSSL").Find(&websites).Error
|
||||||
return count, websites, err
|
return count, websites, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WebSiteRepo) GetFirst(opts ...DBOption) (model.WebSite, error) {
|
func (w *WebsiteRepo) GetFirst(opts ...DBOption) (model.Website, error) {
|
||||||
var website model.WebSite
|
var website model.Website
|
||||||
db := getDb(opts...).Model(&model.WebSite{})
|
db := getDb(opts...).Model(&model.Website{})
|
||||||
if err := db.Preload("Domains").First(&website).Error; err != nil {
|
if err := db.Preload("Domains").First(&website).Error; err != nil {
|
||||||
return website, err
|
return website, err
|
||||||
}
|
}
|
||||||
return website, nil
|
return website, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WebSiteRepo) GetBy(opts ...DBOption) ([]model.WebSite, error) {
|
func (w *WebsiteRepo) GetBy(opts ...DBOption) ([]model.Website, error) {
|
||||||
var websites []model.WebSite
|
var websites []model.Website
|
||||||
db := getDb(opts...).Model(&model.WebSite{})
|
db := getDb(opts...).Model(&model.Website{})
|
||||||
if err := db.Find(&websites).Error; err != nil {
|
if err := db.Find(&websites).Error; err != nil {
|
||||||
return websites, err
|
return websites, err
|
||||||
}
|
}
|
||||||
return websites, nil
|
return websites, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WebSiteRepo) Create(ctx context.Context, app *model.WebSite) error {
|
func (w *WebsiteRepo) Create(ctx context.Context, app *model.Website) error {
|
||||||
return getTx(ctx).Omit(clause.Associations).Create(app).Error
|
return getTx(ctx).Omit(clause.Associations).Create(app).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WebSiteRepo) Save(ctx context.Context, app *model.WebSite) error {
|
func (w *WebsiteRepo) Save(ctx context.Context, app *model.Website) error {
|
||||||
return getTx(ctx).Omit(clause.Associations).Save(app).Error
|
return getTx(ctx).Omit(clause.Associations).Save(app).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WebSiteRepo) DeleteBy(ctx context.Context, opts ...DBOption) error {
|
func (w *WebsiteRepo) DeleteBy(ctx context.Context, opts ...DBOption) error {
|
||||||
return getTx(ctx, opts...).Delete(&model.WebSite{}).Error
|
return getTx(ctx, opts...).Delete(&model.Website{}).Error
|
||||||
}
|
}
|
||||||
|
@ -7,64 +7,64 @@ import (
|
|||||||
"gorm.io/gorm/clause"
|
"gorm.io/gorm/clause"
|
||||||
)
|
)
|
||||||
|
|
||||||
type WebSiteDomainRepo struct {
|
type WebsiteDomainRepo struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteDomainRepo) WithWebSiteId(websiteId uint) DBOption {
|
func (w WebsiteDomainRepo) WithWebsiteId(websiteId uint) DBOption {
|
||||||
return func(db *gorm.DB) *gorm.DB {
|
return func(db *gorm.DB) *gorm.DB {
|
||||||
return db.Where("web_site_id = ?", websiteId)
|
return db.Where("website_id = ?", websiteId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteDomainRepo) WithPort(port int) DBOption {
|
func (w WebsiteDomainRepo) WithPort(port int) DBOption {
|
||||||
return func(db *gorm.DB) *gorm.DB {
|
return func(db *gorm.DB) *gorm.DB {
|
||||||
return db.Where("port = ?", port)
|
return db.Where("port = ?", port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (w WebSiteDomainRepo) WithDomain(domain string) DBOption {
|
func (w WebsiteDomainRepo) WithDomain(domain string) DBOption {
|
||||||
return func(db *gorm.DB) *gorm.DB {
|
return func(db *gorm.DB) *gorm.DB {
|
||||||
return db.Where("domain = ?", domain)
|
return db.Where("domain = ?", domain)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (w WebSiteDomainRepo) Page(page, size int, opts ...DBOption) (int64, []model.WebSiteDomain, error) {
|
func (w WebsiteDomainRepo) Page(page, size int, opts ...DBOption) (int64, []model.WebsiteDomain, error) {
|
||||||
var domains []model.WebSiteDomain
|
var domains []model.WebsiteDomain
|
||||||
db := getDb(opts...).Model(&model.WebSiteDomain{})
|
db := getDb(opts...).Model(&model.WebsiteDomain{})
|
||||||
count := int64(0)
|
count := int64(0)
|
||||||
db = db.Count(&count)
|
db = db.Count(&count)
|
||||||
err := db.Debug().Limit(size).Offset(size * (page - 1)).Find(&domains).Error
|
err := db.Debug().Limit(size).Offset(size * (page - 1)).Find(&domains).Error
|
||||||
return count, domains, err
|
return count, domains, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteDomainRepo) GetFirst(opts ...DBOption) (model.WebSiteDomain, error) {
|
func (w WebsiteDomainRepo) GetFirst(opts ...DBOption) (model.WebsiteDomain, error) {
|
||||||
var domain model.WebSiteDomain
|
var domain model.WebsiteDomain
|
||||||
db := getDb(opts...).Model(&model.WebSiteDomain{})
|
db := getDb(opts...).Model(&model.WebsiteDomain{})
|
||||||
if err := db.First(&domain).Error; err != nil {
|
if err := db.First(&domain).Error; err != nil {
|
||||||
return domain, err
|
return domain, err
|
||||||
}
|
}
|
||||||
return domain, nil
|
return domain, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteDomainRepo) GetBy(opts ...DBOption) ([]model.WebSiteDomain, error) {
|
func (w WebsiteDomainRepo) GetBy(opts ...DBOption) ([]model.WebsiteDomain, error) {
|
||||||
var domains []model.WebSiteDomain
|
var domains []model.WebsiteDomain
|
||||||
db := getDb(opts...).Model(&model.WebSiteDomain{})
|
db := getDb(opts...).Model(&model.WebsiteDomain{})
|
||||||
if err := db.Find(&domains).Error; err != nil {
|
if err := db.Find(&domains).Error; err != nil {
|
||||||
return domains, err
|
return domains, err
|
||||||
}
|
}
|
||||||
return domains, nil
|
return domains, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteDomainRepo) BatchCreate(ctx context.Context, domains []model.WebSiteDomain) error {
|
func (w WebsiteDomainRepo) BatchCreate(ctx context.Context, domains []model.WebsiteDomain) error {
|
||||||
return getTx(ctx).Model(&model.WebSiteDomain{}).Create(&domains).Error
|
return getTx(ctx).Model(&model.WebsiteDomain{}).Create(&domains).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteDomainRepo) Create(ctx context.Context, app *model.WebSiteDomain) error {
|
func (w WebsiteDomainRepo) Create(ctx context.Context, app *model.WebsiteDomain) error {
|
||||||
return getTx(ctx).Omit(clause.Associations).Create(app).Error
|
return getTx(ctx).Omit(clause.Associations).Create(app).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteDomainRepo) Save(ctx context.Context, app *model.WebSiteDomain) error {
|
func (w WebsiteDomainRepo) Save(ctx context.Context, app *model.WebsiteDomain) error {
|
||||||
return getTx(ctx).Omit(clause.Associations).Save(app).Error
|
return getTx(ctx).Omit(clause.Associations).Save(app).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteDomainRepo) DeleteBy(ctx context.Context, opts ...DBOption) error {
|
func (w WebsiteDomainRepo) DeleteBy(ctx context.Context, opts ...DBOption) error {
|
||||||
return getTx(ctx, opts...).Delete(&model.WebSiteDomain{}).Error
|
return getTx(ctx, opts...).Delete(&model.WebsiteDomain{}).Error
|
||||||
}
|
}
|
||||||
|
@ -6,39 +6,39 @@ import (
|
|||||||
"gorm.io/gorm/clause"
|
"gorm.io/gorm/clause"
|
||||||
)
|
)
|
||||||
|
|
||||||
type WebSiteGroupRepo struct {
|
type WebsiteGroupRepo struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteGroupRepo) Page(page, size int, opts ...DBOption) (int64, []model.WebSiteGroup, error) {
|
func (w WebsiteGroupRepo) Page(page, size int, opts ...DBOption) (int64, []model.WebsiteGroup, error) {
|
||||||
var groups []model.WebSiteGroup
|
var groups []model.WebsiteGroup
|
||||||
db := getDb(opts...).Model(&model.WebSiteGroup{})
|
db := getDb(opts...).Model(&model.WebsiteGroup{})
|
||||||
count := int64(0)
|
count := int64(0)
|
||||||
db = db.Count(&count)
|
db = db.Count(&count)
|
||||||
err := db.Limit(size).Offset(size * (page - 1)).Order("`default` desc").Find(&groups).Error
|
err := db.Limit(size).Offset(size * (page - 1)).Order("`default` desc").Find(&groups).Error
|
||||||
return count, groups, err
|
return count, groups, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteGroupRepo) GetBy(opts ...DBOption) ([]model.WebSiteGroup, error) {
|
func (w WebsiteGroupRepo) GetBy(opts ...DBOption) ([]model.WebsiteGroup, error) {
|
||||||
var groups []model.WebSiteGroup
|
var groups []model.WebsiteGroup
|
||||||
db := getDb(opts...).Model(&model.WebSiteGroup{})
|
db := getDb(opts...).Model(&model.WebsiteGroup{})
|
||||||
if err := db.Order("`default` desc").Find(&groups).Error; err != nil {
|
if err := db.Order("`default` desc").Find(&groups).Error; err != nil {
|
||||||
return groups, err
|
return groups, err
|
||||||
}
|
}
|
||||||
return groups, nil
|
return groups, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteGroupRepo) Create(app *model.WebSiteGroup) error {
|
func (w WebsiteGroupRepo) Create(app *model.WebsiteGroup) error {
|
||||||
return getDb().Omit(clause.Associations).Create(app).Error
|
return getDb().Omit(clause.Associations).Create(app).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteGroupRepo) Save(app *model.WebSiteGroup) error {
|
func (w WebsiteGroupRepo) Save(app *model.WebsiteGroup) error {
|
||||||
return getDb().Omit(clause.Associations).Save(app).Error
|
return getDb().Omit(clause.Associations).Save(app).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteGroupRepo) DeleteBy(opts ...DBOption) error {
|
func (w WebsiteGroupRepo) DeleteBy(opts ...DBOption) error {
|
||||||
return getDb(opts...).Delete(&model.WebSiteGroup{}).Error
|
return getDb(opts...).Delete(&model.WebsiteGroup{}).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteGroupRepo) CancelDefault() error {
|
func (w WebsiteGroupRepo) CancelDefault() error {
|
||||||
return global.DB.Model(&model.WebSiteGroup{}).Where("`default` = 1").Updates(map[string]interface{}{"default": 0}).Error
|
return global.DB.Model(&model.WebsiteGroup{}).Where("`default` = 1").Updates(map[string]interface{}{"default": 0}).Error
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,11 @@ type ISSLRepo interface {
|
|||||||
WithByAlias(alias string) DBOption
|
WithByAlias(alias string) DBOption
|
||||||
WithByAcmeAccountId(acmeAccountId uint) DBOption
|
WithByAcmeAccountId(acmeAccountId uint) DBOption
|
||||||
WithByDnsAccountId(dnsAccountId uint) DBOption
|
WithByDnsAccountId(dnsAccountId uint) DBOption
|
||||||
Page(page, size int, opts ...DBOption) (int64, []model.WebSiteSSL, error)
|
Page(page, size int, opts ...DBOption) (int64, []model.WebsiteSSL, error)
|
||||||
GetFirst(opts ...DBOption) (model.WebSiteSSL, error)
|
GetFirst(opts ...DBOption) (model.WebsiteSSL, error)
|
||||||
List(opts ...DBOption) ([]model.WebSiteSSL, error)
|
List(opts ...DBOption) ([]model.WebsiteSSL, error)
|
||||||
Create(ctx context.Context, ssl *model.WebSiteSSL) error
|
Create(ctx context.Context, ssl *model.WebsiteSSL) error
|
||||||
Save(ssl model.WebSiteSSL) error
|
Save(ssl model.WebsiteSSL) error
|
||||||
DeleteBy(opts ...DBOption) error
|
DeleteBy(opts ...DBOption) error
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,41 +43,41 @@ func (w WebsiteSSLRepo) WithByDnsAccountId(dnsAccountId uint) DBOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteSSLRepo) Page(page, size int, opts ...DBOption) (int64, []model.WebSiteSSL, error) {
|
func (w WebsiteSSLRepo) Page(page, size int, opts ...DBOption) (int64, []model.WebsiteSSL, error) {
|
||||||
var sslList []model.WebSiteSSL
|
var sslList []model.WebsiteSSL
|
||||||
db := getDb(opts...).Model(&model.WebSiteSSL{})
|
db := getDb(opts...).Model(&model.WebsiteSSL{})
|
||||||
count := int64(0)
|
count := int64(0)
|
||||||
db = db.Count(&count)
|
db = db.Count(&count)
|
||||||
err := db.Limit(size).Offset(size * (page - 1)).Preload("AcmeAccount").Find(&sslList).Error
|
err := db.Limit(size).Offset(size * (page - 1)).Preload("AcmeAccount").Find(&sslList).Error
|
||||||
return count, sslList, err
|
return count, sslList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteSSLRepo) GetFirst(opts ...DBOption) (model.WebSiteSSL, error) {
|
func (w WebsiteSSLRepo) GetFirst(opts ...DBOption) (model.WebsiteSSL, error) {
|
||||||
var website model.WebSiteSSL
|
var website model.WebsiteSSL
|
||||||
db := getDb(opts...).Model(&model.WebSiteSSL{})
|
db := getDb(opts...).Model(&model.WebsiteSSL{})
|
||||||
if err := db.Preload("AcmeAccount").First(&website).Error; err != nil {
|
if err := db.Preload("AcmeAccount").First(&website).Error; err != nil {
|
||||||
return website, err
|
return website, err
|
||||||
}
|
}
|
||||||
return website, nil
|
return website, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteSSLRepo) List(opts ...DBOption) ([]model.WebSiteSSL, error) {
|
func (w WebsiteSSLRepo) List(opts ...DBOption) ([]model.WebsiteSSL, error) {
|
||||||
var websites []model.WebSiteSSL
|
var websites []model.WebsiteSSL
|
||||||
db := getDb(opts...).Model(&model.WebSiteSSL{})
|
db := getDb(opts...).Model(&model.WebsiteSSL{})
|
||||||
if err := db.Preload("AcmeAccount").Find(&websites).Error; err != nil {
|
if err := db.Preload("AcmeAccount").Find(&websites).Error; err != nil {
|
||||||
return websites, err
|
return websites, err
|
||||||
}
|
}
|
||||||
return websites, nil
|
return websites, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteSSLRepo) Create(ctx context.Context, ssl *model.WebSiteSSL) error {
|
func (w WebsiteSSLRepo) Create(ctx context.Context, ssl *model.WebsiteSSL) error {
|
||||||
return getTx(ctx).Create(ssl).Error
|
return getTx(ctx).Create(ssl).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteSSLRepo) Save(ssl model.WebSiteSSL) error {
|
func (w WebsiteSSLRepo) Save(ssl model.WebsiteSSL) error {
|
||||||
return getDb().Save(&ssl).Error
|
return getDb().Save(&ssl).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteSSLRepo) DeleteBy(opts ...DBOption) error {
|
func (w WebsiteSSLRepo) DeleteBy(opts ...DBOption) error {
|
||||||
return getDb(opts...).Delete(&model.WebSiteSSL{}).Error
|
return getDb(opts...).Delete(&model.WebsiteSSL{}).Error
|
||||||
}
|
}
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
package request
|
|
||||||
|
|
||||||
type WebsiteWafReq struct {
|
|
||||||
WebsiteID uint `json:"websiteId" validate:"required"`
|
|
||||||
Key string `json:"key" validate:"required"`
|
|
||||||
Rule string `json:"rule" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type WebsiteWafUpdate struct {
|
|
||||||
WebsiteID uint `json:"websiteId" validate:"required"`
|
|
||||||
Key string `json:"key" validate:"required"`
|
|
||||||
Enable bool `json:"enable" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type WebSiteDel struct {
|
|
||||||
ID uint `json:"id" validate:"required"`
|
|
||||||
DeleteApp bool `json:"deleteApp"`
|
|
||||||
DeleteBackup bool `json:"deleteBackup"`
|
|
||||||
ForceDelete bool `json:"forceDelete"`
|
|
||||||
}
|
|
@ -30,9 +30,9 @@ type ServiceGroup struct {
|
|||||||
|
|
||||||
WebsiteGroupService
|
WebsiteGroupService
|
||||||
WebsiteService
|
WebsiteService
|
||||||
WebSiteDnsAccountService
|
WebsiteDnsAccountService
|
||||||
WebSiteSSLService
|
WebsiteSSLService
|
||||||
WebSiteAcmeAccountService
|
WebsiteAcmeAccountService
|
||||||
|
|
||||||
NginxService
|
NginxService
|
||||||
|
|
||||||
@ -67,8 +67,8 @@ var (
|
|||||||
backupRepo = repo.RepoGroupApp.BackupRepo
|
backupRepo = repo.RepoGroupApp.BackupRepo
|
||||||
|
|
||||||
websiteRepo = repo.NewIWebsiteRepo()
|
websiteRepo = repo.NewIWebsiteRepo()
|
||||||
websiteGroupRepo = repo.RepoGroupApp.WebSiteGroupRepo
|
websiteGroupRepo = repo.RepoGroupApp.WebsiteGroupRepo
|
||||||
websiteDomainRepo = repo.RepoGroupApp.WebSiteDomainRepo
|
websiteDomainRepo = repo.RepoGroupApp.WebsiteDomainRepo
|
||||||
websiteDnsRepo = repo.RepoGroupApp.WebsiteDnsAccountRepo
|
websiteDnsRepo = repo.RepoGroupApp.WebsiteDnsAccountRepo
|
||||||
websiteSSLRepo = repo.NewISSLRepo()
|
websiteSSLRepo = repo.NewISSLRepo()
|
||||||
websiteAcmeRepo = repo.NewIAcmeAccountRepo()
|
websiteAcmeRepo = repo.NewIAcmeAccountRepo()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/request"
|
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getNginxFull(website *model.WebSite) (dto.NginxFull, error) {
|
func getNginxFull(website *model.Website) (dto.NginxFull, error) {
|
||||||
var nginxFull dto.NginxFull
|
var nginxFull dto.NginxFull
|
||||||
nginxInstall, err := getAppInstallByKey("nginx")
|
nginxInstall, err := getAppInstallByKey("nginx")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -62,7 +62,7 @@ func getNginxFull(website *model.WebSite) (dto.NginxFull, error) {
|
|||||||
return nginxFull, nil
|
return nginxFull, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getNginxParamsByKeys(scope string, keys []string, website *model.WebSite) ([]dto.NginxParam, error) {
|
func getNginxParamsByKeys(scope string, keys []string, website *model.Website) ([]dto.NginxParam, error) {
|
||||||
nginxFull, err := getNginxFull(website)
|
nginxFull, err := getNginxFull(website)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -94,7 +94,7 @@ func getNginxParamsByKeys(scope string, keys []string, website *model.WebSite) (
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateNginxConfig(scope string, params []dto.NginxParam, website *model.WebSite) error {
|
func updateNginxConfig(scope string, params []dto.NginxParam, website *model.Website) error {
|
||||||
|
|
||||||
nginxFull, err := getNginxFull(website)
|
nginxFull, err := getNginxFull(website)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -126,7 +126,7 @@ func updateNginxConfig(scope string, params []dto.NginxParam, website *model.Web
|
|||||||
return nginxCheckAndReload(config.OldContent, config.FilePath, nginxFull.Install.ContainerName)
|
return nginxCheckAndReload(config.OldContent, config.FilePath, nginxFull.Install.ContainerName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteNginxConfig(scope string, keys []string, website *model.WebSite) error {
|
func deleteNginxConfig(scope string, keys []string, website *model.Website) error {
|
||||||
nginxFull, err := getNginxFull(website)
|
nginxFull, err := getNginxFull(website)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -6,7 +6,8 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/request"
|
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
||||||
|
"github.com/1Panel-dev/1Panel/backend/app/dto/response"
|
||||||
"github.com/1Panel-dev/1Panel/backend/buserr"
|
"github.com/1Panel-dev/1Panel/backend/buserr"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@ -26,25 +27,25 @@ type WebsiteService struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type IWebsiteService interface {
|
type IWebsiteService interface {
|
||||||
PageWebSite(req dto.WebSiteReq) (int64, []dto.WebSiteDTO, error)
|
PageWebsite(req request.WebsiteSearch) (int64, []response.WebsiteDTO, error)
|
||||||
CreateWebsite(create dto.WebSiteCreate) error
|
CreateWebsite(create request.WebsiteCreate) error
|
||||||
GetWebsiteOptions() ([]string, error)
|
GetWebsiteOptions() ([]string, error)
|
||||||
Backup(domain string) error
|
Backup(domain string) error
|
||||||
Recover(req dto.WebSiteRecover) error
|
Recover(req request.WebsiteRecover) error
|
||||||
RecoverByUpload(req dto.WebSiteRecoverByFile) error
|
RecoverByUpload(req request.WebsiteRecoverByFile) error
|
||||||
UpdateWebsite(req dto.WebSiteUpdate) error
|
UpdateWebsite(req request.WebsiteUpdate) error
|
||||||
DeleteWebSite(req request.WebSiteDel) error
|
DeleteWebsite(req request.WebsiteDelete) error
|
||||||
GetWebsite(id uint) (dto.WebsiteDTO, error)
|
GetWebsite(id uint) (response.WebsiteDTO, error)
|
||||||
CreateWebsiteDomain(create dto.WebSiteDomainCreate) (model.WebSiteDomain, error)
|
CreateWebsiteDomain(create request.WebsiteDomainCreate) (model.WebsiteDomain, error)
|
||||||
GetWebsiteDomain(websiteId uint) ([]model.WebSiteDomain, error)
|
GetWebsiteDomain(websiteId uint) ([]model.WebsiteDomain, error)
|
||||||
DeleteWebsiteDomain(domainId uint) error
|
DeleteWebsiteDomain(domainId uint) error
|
||||||
GetNginxConfigByScope(req dto.NginxConfigReq) (*dto.WebsiteNginxConfig, error)
|
GetNginxConfigByScope(req dto.NginxConfigReq) (*response.WebsiteNginxConfig, error)
|
||||||
UpdateNginxConfigByScope(req dto.NginxConfigReq) error
|
UpdateNginxConfigByScope(req dto.NginxConfigReq) error
|
||||||
GetWebsiteNginxConfig(websiteId uint) (dto.FileInfo, error)
|
GetWebsiteNginxConfig(websiteId uint) (dto.FileInfo, error)
|
||||||
GetWebsiteHTTPS(websiteId uint) (dto.WebsiteHTTPS, error)
|
GetWebsiteHTTPS(websiteId uint) (response.WebsiteHTTPS, error)
|
||||||
OpWebsiteHTTPS(req dto.WebsiteHTTPSOp) (dto.WebsiteHTTPS, error)
|
OpWebsiteHTTPS(req request.WebsiteHTTPSOp) (response.WebsiteHTTPS, error)
|
||||||
PreInstallCheck(req dto.WebsiteInstallCheckReq) ([]dto.WebsitePreInstallCheck, error)
|
PreInstallCheck(req request.WebsiteInstallCheckReq) ([]response.WebsitePreInstallCheck, error)
|
||||||
GetWafConfig(req request.WebsiteWafReq) (dto.WebsiteWafConfig, error)
|
GetWafConfig(req request.WebsiteWafReq) (response.WebsiteWafConfig, error)
|
||||||
UpdateWafConfig(req request.WebsiteWafUpdate) error
|
UpdateWafConfig(req request.WebsiteWafUpdate) error
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,21 +53,21 @@ func NewWebsiteService() IWebsiteService {
|
|||||||
return &WebsiteService{}
|
return &WebsiteService{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteService) PageWebSite(req dto.WebSiteReq) (int64, []dto.WebSiteDTO, error) {
|
func (w WebsiteService) PageWebsite(req request.WebsiteSearch) (int64, []response.WebsiteDTO, error) {
|
||||||
var websiteDTOs []dto.WebSiteDTO
|
var websiteDTOs []response.WebsiteDTO
|
||||||
total, websites, err := websiteRepo.Page(req.Page, req.PageSize)
|
total, websites, err := websiteRepo.Page(req.Page, req.PageSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, nil, err
|
return 0, nil, err
|
||||||
}
|
}
|
||||||
for _, web := range websites {
|
for _, web := range websites {
|
||||||
websiteDTOs = append(websiteDTOs, dto.WebSiteDTO{
|
websiteDTOs = append(websiteDTOs, response.WebsiteDTO{
|
||||||
WebSite: web,
|
Website: web,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return total, websiteDTOs, nil
|
return total, websiteDTOs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteService) CreateWebsite(create dto.WebSiteCreate) error {
|
func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) error {
|
||||||
if exist, _ := websiteRepo.GetBy(websiteRepo.WithDomain(create.PrimaryDomain)); len(exist) > 0 {
|
if exist, _ := websiteRepo.GetBy(websiteRepo.WithDomain(create.PrimaryDomain)); len(exist) > 0 {
|
||||||
return buserr.New(constant.ErrNameIsExist)
|
return buserr.New(constant.ErrNameIsExist)
|
||||||
}
|
}
|
||||||
@ -78,7 +79,7 @@ func (w WebsiteService) CreateWebsite(create dto.WebSiteCreate) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
defaultDate, _ := time.Parse(constant.DateLayout, constant.DefaultDate)
|
defaultDate, _ := time.Parse(constant.DateLayout, constant.DefaultDate)
|
||||||
website := &model.WebSite{
|
website := &model.Website{
|
||||||
PrimaryDomain: create.PrimaryDomain,
|
PrimaryDomain: create.PrimaryDomain,
|
||||||
Type: create.Type,
|
Type: create.Type,
|
||||||
Alias: create.Alias,
|
Alias: create.Alias,
|
||||||
@ -86,14 +87,14 @@ func (w WebsiteService) CreateWebsite(create dto.WebSiteCreate) error {
|
|||||||
Status: constant.WebRunning,
|
Status: constant.WebRunning,
|
||||||
ExpireDate: defaultDate,
|
ExpireDate: defaultDate,
|
||||||
AppInstallID: create.AppInstallID,
|
AppInstallID: create.AppInstallID,
|
||||||
WebSiteGroupID: create.WebSiteGroupID,
|
WebsiteGroupID: create.WebsiteGroupID,
|
||||||
Protocol: constant.ProtocolHTTP,
|
Protocol: constant.ProtocolHTTP,
|
||||||
Proxy: create.Proxy,
|
Proxy: create.Proxy,
|
||||||
}
|
}
|
||||||
|
|
||||||
switch create.Type {
|
switch create.Type {
|
||||||
case constant.Deployment:
|
case constant.Deployment:
|
||||||
if create.AppType == dto.NewApp {
|
if create.AppType == constant.NewApp {
|
||||||
install, err := ServiceGroupApp.Install(create.AppInstall.Name, create.AppInstall.AppDetailId, create.AppInstall.Params)
|
install, err := ServiceGroupApp.Install(create.AppInstall.Name, create.AppInstall.AppDetailId, create.AppInstall.Params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -110,8 +111,8 @@ func (w WebsiteService) CreateWebsite(create dto.WebSiteCreate) error {
|
|||||||
if err := websiteRepo.Create(ctx, website); err != nil {
|
if err := websiteRepo.Create(ctx, website); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var domains []model.WebSiteDomain
|
var domains []model.WebsiteDomain
|
||||||
domains = append(domains, model.WebSiteDomain{Domain: website.PrimaryDomain, WebSiteID: website.ID, Port: 80})
|
domains = append(domains, model.WebsiteDomain{Domain: website.PrimaryDomain, WebsiteID: website.ID, Port: 80})
|
||||||
|
|
||||||
otherDomainArray := strings.Split(create.OtherDomains, "\n")
|
otherDomainArray := strings.Split(create.OtherDomains, "\n")
|
||||||
for _, domain := range otherDomainArray {
|
for _, domain := range otherDomainArray {
|
||||||
@ -123,7 +124,7 @@ func (w WebsiteService) CreateWebsite(create dto.WebSiteCreate) error {
|
|||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if reflect.DeepEqual(domainModel, model.WebSiteDomain{}) {
|
if reflect.DeepEqual(domainModel, model.WebsiteDomain{}) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
domains = append(domains, domainModel)
|
domains = append(domains, domainModel)
|
||||||
@ -170,7 +171,7 @@ func (w WebsiteService) Backup(domain string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteService) RecoverByUpload(req dto.WebSiteRecoverByFile) error {
|
func (w WebsiteService) RecoverByUpload(req request.WebsiteRecoverByFile) error {
|
||||||
if err := handleUnTar(fmt.Sprintf("%s/%s", req.FileDir, req.FileName), req.FileDir); err != nil {
|
if err := handleUnTar(fmt.Sprintf("%s/%s", req.FileDir, req.FileName), req.FileDir); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -179,7 +180,7 @@ func (w WebsiteService) RecoverByUpload(req dto.WebSiteRecoverByFile) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var websiteInfo WebSiteInfo
|
var websiteInfo WebsiteInfo
|
||||||
if err := json.Unmarshal(webJson, &websiteInfo); err != nil {
|
if err := json.Unmarshal(webJson, &websiteInfo); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -198,7 +199,7 @@ func (w WebsiteService) RecoverByUpload(req dto.WebSiteRecoverByFile) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteService) Recover(req dto.WebSiteRecover) error {
|
func (w WebsiteService) Recover(req request.WebsiteRecover) error {
|
||||||
website, err := websiteRepo.GetFirst(websiteRepo.WithDomain(req.WebsiteName))
|
website, err := websiteRepo.GetFirst(websiteRepo.WithDomain(req.WebsiteName))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -220,29 +221,29 @@ func (w WebsiteService) Recover(req dto.WebSiteRecover) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteService) UpdateWebsite(req dto.WebSiteUpdate) error {
|
func (w WebsiteService) UpdateWebsite(req request.WebsiteUpdate) error {
|
||||||
website, err := websiteRepo.GetFirst(commonRepo.WithByID(req.ID))
|
website, err := websiteRepo.GetFirst(commonRepo.WithByID(req.ID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
website.PrimaryDomain = req.PrimaryDomain
|
website.PrimaryDomain = req.PrimaryDomain
|
||||||
website.WebSiteGroupID = req.WebSiteGroupID
|
website.WebsiteGroupID = req.WebsiteGroupID
|
||||||
website.Remark = req.Remark
|
website.Remark = req.Remark
|
||||||
|
|
||||||
return websiteRepo.Save(context.TODO(), &website)
|
return websiteRepo.Save(context.TODO(), &website)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteService) GetWebsite(id uint) (dto.WebsiteDTO, error) {
|
func (w WebsiteService) GetWebsite(id uint) (response.WebsiteDTO, error) {
|
||||||
var res dto.WebsiteDTO
|
var res response.WebsiteDTO
|
||||||
website, err := websiteRepo.GetFirst(commonRepo.WithByID(id))
|
website, err := websiteRepo.GetFirst(commonRepo.WithByID(id))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
res.WebSite = website
|
res.Website = website
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteService) DeleteWebSite(req request.WebSiteDel) error {
|
func (w WebsiteService) DeleteWebsite(req request.WebsiteDelete) error {
|
||||||
website, err := websiteRepo.GetFirst(commonRepo.WithByID(req.ID))
|
website, err := websiteRepo.GetFirst(commonRepo.WithByID(req.ID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -272,7 +273,7 @@ func (w WebsiteService) DeleteWebSite(req request.WebSiteDel) error {
|
|||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := websiteDomainRepo.DeleteBy(ctx, websiteDomainRepo.WithWebSiteId(req.ID)); err != nil {
|
if err := websiteDomainRepo.DeleteBy(ctx, websiteDomainRepo.WithWebsiteId(req.ID)); err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -280,32 +281,32 @@ func (w WebsiteService) DeleteWebSite(req request.WebSiteDel) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteService) CreateWebsiteDomain(create dto.WebSiteDomainCreate) (model.WebSiteDomain, error) {
|
func (w WebsiteService) CreateWebsiteDomain(create request.WebsiteDomainCreate) (model.WebsiteDomain, error) {
|
||||||
var domainModel model.WebSiteDomain
|
var domainModel model.WebsiteDomain
|
||||||
var ports []int
|
var ports []int
|
||||||
var domains []string
|
var domains []string
|
||||||
|
|
||||||
website, err := websiteRepo.GetFirst(commonRepo.WithByID(create.WebSiteID))
|
website, err := websiteRepo.GetFirst(commonRepo.WithByID(create.WebsiteID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return domainModel, err
|
return domainModel, err
|
||||||
}
|
}
|
||||||
if oldDomains, _ := websiteDomainRepo.GetBy(websiteDomainRepo.WithWebSiteId(create.WebSiteID), websiteDomainRepo.WithPort(create.Port)); len(oldDomains) == 0 {
|
if oldDomains, _ := websiteDomainRepo.GetBy(websiteDomainRepo.WithWebsiteId(create.WebsiteID), websiteDomainRepo.WithPort(create.Port)); len(oldDomains) == 0 {
|
||||||
ports = append(ports, create.Port)
|
ports = append(ports, create.Port)
|
||||||
}
|
}
|
||||||
domains = append(domains, create.Domain)
|
domains = append(domains, create.Domain)
|
||||||
if err := addListenAndServerName(website, ports, domains); err != nil {
|
if err := addListenAndServerName(website, ports, domains); err != nil {
|
||||||
return domainModel, err
|
return domainModel, err
|
||||||
}
|
}
|
||||||
domainModel = model.WebSiteDomain{
|
domainModel = model.WebsiteDomain{
|
||||||
Domain: create.Domain,
|
Domain: create.Domain,
|
||||||
Port: create.Port,
|
Port: create.Port,
|
||||||
WebSiteID: create.WebSiteID,
|
WebsiteID: create.WebsiteID,
|
||||||
}
|
}
|
||||||
return domainModel, websiteDomainRepo.Create(context.TODO(), &domainModel)
|
return domainModel, websiteDomainRepo.Create(context.TODO(), &domainModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteService) GetWebsiteDomain(websiteId uint) ([]model.WebSiteDomain, error) {
|
func (w WebsiteService) GetWebsiteDomain(websiteId uint) ([]model.WebsiteDomain, error) {
|
||||||
return websiteDomainRepo.GetBy(websiteDomainRepo.WithWebSiteId(websiteId))
|
return websiteDomainRepo.GetBy(websiteDomainRepo.WithWebsiteId(websiteId))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteService) DeleteWebsiteDomain(domainId uint) error {
|
func (w WebsiteService) DeleteWebsiteDomain(domainId uint) error {
|
||||||
@ -314,20 +315,20 @@ func (w WebsiteService) DeleteWebsiteDomain(domainId uint) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if websiteDomains, _ := websiteDomainRepo.GetBy(websiteDomainRepo.WithWebSiteId(webSiteDomain.WebSiteID)); len(websiteDomains) == 1 {
|
if websiteDomains, _ := websiteDomainRepo.GetBy(websiteDomainRepo.WithWebsiteId(webSiteDomain.WebsiteID)); len(websiteDomains) == 1 {
|
||||||
return fmt.Errorf("can not delete last domain")
|
return fmt.Errorf("can not delete last domain")
|
||||||
}
|
}
|
||||||
website, err := websiteRepo.GetFirst(commonRepo.WithByID(webSiteDomain.WebSiteID))
|
website, err := websiteRepo.GetFirst(commonRepo.WithByID(webSiteDomain.WebsiteID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var ports []int
|
var ports []int
|
||||||
if oldDomains, _ := websiteDomainRepo.GetBy(websiteDomainRepo.WithWebSiteId(webSiteDomain.WebSiteID), websiteDomainRepo.WithPort(webSiteDomain.Port)); len(oldDomains) == 1 {
|
if oldDomains, _ := websiteDomainRepo.GetBy(websiteDomainRepo.WithWebsiteId(webSiteDomain.WebsiteID), websiteDomainRepo.WithPort(webSiteDomain.Port)); len(oldDomains) == 1 {
|
||||||
ports = append(ports, webSiteDomain.Port)
|
ports = append(ports, webSiteDomain.Port)
|
||||||
}
|
}
|
||||||
|
|
||||||
var domains []string
|
var domains []string
|
||||||
if oldDomains, _ := websiteDomainRepo.GetBy(websiteDomainRepo.WithWebSiteId(webSiteDomain.WebSiteID), websiteDomainRepo.WithDomain(webSiteDomain.Domain)); len(oldDomains) == 1 {
|
if oldDomains, _ := websiteDomainRepo.GetBy(websiteDomainRepo.WithWebsiteId(webSiteDomain.WebsiteID), websiteDomainRepo.WithDomain(webSiteDomain.Domain)); len(oldDomains) == 1 {
|
||||||
domains = append(domains, webSiteDomain.Domain)
|
domains = append(domains, webSiteDomain.Domain)
|
||||||
}
|
}
|
||||||
if len(ports) > 0 || len(domains) > 0 {
|
if len(ports) > 0 || len(domains) > 0 {
|
||||||
@ -339,17 +340,17 @@ func (w WebsiteService) DeleteWebsiteDomain(domainId uint) error {
|
|||||||
return websiteDomainRepo.DeleteBy(context.TODO(), commonRepo.WithByID(domainId))
|
return websiteDomainRepo.DeleteBy(context.TODO(), commonRepo.WithByID(domainId))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteService) GetNginxConfigByScope(req dto.NginxConfigReq) (*dto.WebsiteNginxConfig, error) {
|
func (w WebsiteService) GetNginxConfigByScope(req dto.NginxConfigReq) (*response.WebsiteNginxConfig, error) {
|
||||||
keys, ok := dto.ScopeKeyMap[req.Scope]
|
keys, ok := dto.ScopeKeyMap[req.Scope]
|
||||||
if !ok || len(keys) == 0 {
|
if !ok || len(keys) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
website, err := websiteRepo.GetFirst(commonRepo.WithByID(req.WebSiteID))
|
website, err := websiteRepo.GetFirst(commonRepo.WithByID(req.WebsiteID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var config dto.WebsiteNginxConfig
|
var config response.WebsiteNginxConfig
|
||||||
params, err := getNginxParamsByKeys(constant.NginxScopeServer, keys, &website)
|
params, err := getNginxParamsByKeys(constant.NginxScopeServer, keys, &website)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -365,7 +366,7 @@ func (w WebsiteService) UpdateNginxConfigByScope(req dto.NginxConfigReq) error {
|
|||||||
if !ok || len(keys) == 0 {
|
if !ok || len(keys) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
website, err := websiteRepo.GetFirst(commonRepo.WithByID(req.WebSiteID))
|
website, err := websiteRepo.GetFirst(commonRepo.WithByID(req.WebsiteID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -408,54 +409,54 @@ func (w WebsiteService) GetWebsiteNginxConfig(websiteId uint) (dto.FileInfo, err
|
|||||||
return dto.FileInfo{FileInfo: *info}, nil
|
return dto.FileInfo{FileInfo: *info}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteService) GetWebsiteHTTPS(websiteId uint) (dto.WebsiteHTTPS, error) {
|
func (w WebsiteService) GetWebsiteHTTPS(websiteId uint) (response.WebsiteHTTPS, error) {
|
||||||
website, err := websiteRepo.GetFirst(commonRepo.WithByID(websiteId))
|
website, err := websiteRepo.GetFirst(commonRepo.WithByID(websiteId))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return dto.WebsiteHTTPS{}, err
|
return response.WebsiteHTTPS{}, err
|
||||||
}
|
}
|
||||||
var res dto.WebsiteHTTPS
|
var res response.WebsiteHTTPS
|
||||||
if website.WebSiteSSLID == 0 {
|
if website.WebsiteSSLID == 0 {
|
||||||
res.Enable = false
|
res.Enable = false
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
websiteSSL, err := websiteSSLRepo.GetFirst(commonRepo.WithByID(website.WebSiteSSLID))
|
websiteSSL, err := websiteSSLRepo.GetFirst(commonRepo.WithByID(website.WebsiteSSLID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return dto.WebsiteHTTPS{}, err
|
return response.WebsiteHTTPS{}, err
|
||||||
}
|
}
|
||||||
res.SSL = websiteSSL
|
res.SSL = websiteSSL
|
||||||
res.Enable = true
|
res.Enable = true
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteService) OpWebsiteHTTPS(req dto.WebsiteHTTPSOp) (dto.WebsiteHTTPS, error) {
|
func (w WebsiteService) OpWebsiteHTTPS(req request.WebsiteHTTPSOp) (response.WebsiteHTTPS, error) {
|
||||||
website, err := websiteRepo.GetFirst(commonRepo.WithByID(req.WebsiteID))
|
website, err := websiteRepo.GetFirst(commonRepo.WithByID(req.WebsiteID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return dto.WebsiteHTTPS{}, err
|
return response.WebsiteHTTPS{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
res dto.WebsiteHTTPS
|
res response.WebsiteHTTPS
|
||||||
websiteSSL model.WebSiteSSL
|
websiteSSL model.WebsiteSSL
|
||||||
)
|
)
|
||||||
res.Enable = req.Enable
|
res.Enable = req.Enable
|
||||||
|
|
||||||
if req.Type == dto.SSLExisted {
|
if req.Type == constant.SSLExisted {
|
||||||
websiteSSL, err = websiteSSLRepo.GetFirst(commonRepo.WithByID(req.WebsiteSSLID))
|
websiteSSL, err = websiteSSLRepo.GetFirst(commonRepo.WithByID(req.WebsiteSSLID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return dto.WebsiteHTTPS{}, err
|
return response.WebsiteHTTPS{}, err
|
||||||
}
|
}
|
||||||
website.WebSiteSSLID = websiteSSL.ID
|
website.WebsiteSSLID = websiteSSL.ID
|
||||||
if err := websiteRepo.Save(context.TODO(), &website); err != nil {
|
if err := websiteRepo.Save(context.TODO(), &website); err != nil {
|
||||||
return dto.WebsiteHTTPS{}, err
|
return response.WebsiteHTTPS{}, err
|
||||||
}
|
}
|
||||||
res.SSL = websiteSSL
|
res.SSL = websiteSSL
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Type == dto.Manual {
|
if req.Type == constant.SSLManual {
|
||||||
certBlock, _ := pem.Decode([]byte(req.Certificate))
|
certBlock, _ := pem.Decode([]byte(req.Certificate))
|
||||||
cert, err := x509.ParseCertificate(certBlock.Bytes)
|
cert, err := x509.ParseCertificate(certBlock.Bytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return dto.WebsiteHTTPS{}, err
|
return response.WebsiteHTTPS{}, err
|
||||||
}
|
}
|
||||||
websiteSSL.ExpireDate = cert.NotAfter
|
websiteSSL.ExpireDate = cert.NotAfter
|
||||||
websiteSSL.StartDate = cert.NotBefore
|
websiteSSL.StartDate = cert.NotBefore
|
||||||
@ -486,39 +487,39 @@ func (w WebsiteService) OpWebsiteHTTPS(req dto.WebsiteHTTPSOp) (dto.WebsiteHTTPS
|
|||||||
if req.Enable {
|
if req.Enable {
|
||||||
website.Protocol = constant.ProtocolHTTPS
|
website.Protocol = constant.ProtocolHTTPS
|
||||||
if err := applySSL(website, websiteSSL); err != nil {
|
if err := applySSL(website, websiteSSL); err != nil {
|
||||||
return dto.WebsiteHTTPS{}, err
|
return response.WebsiteHTTPS{}, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
website.Protocol = constant.ProtocolHTTP
|
website.Protocol = constant.ProtocolHTTP
|
||||||
website.WebSiteSSLID = 0
|
website.WebsiteSSLID = 0
|
||||||
|
|
||||||
if err := deleteListenAndServerName(website, []int{443}, []string{}); err != nil {
|
if err := deleteListenAndServerName(website, []int{443}, []string{}); err != nil {
|
||||||
return dto.WebsiteHTTPS{}, err
|
return response.WebsiteHTTPS{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := deleteNginxConfig(constant.NginxScopeServer, getKeysFromStaticFile(dto.SSL), &website); err != nil {
|
if err := deleteNginxConfig(constant.NginxScopeServer, getKeysFromStaticFile(dto.SSL), &website); err != nil {
|
||||||
return dto.WebsiteHTTPS{}, err
|
return response.WebsiteHTTPS{}, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tx, ctx := getTxAndContext()
|
tx, ctx := getTxAndContext()
|
||||||
if websiteSSL.ID == 0 {
|
if websiteSSL.ID == 0 {
|
||||||
if err := websiteSSLRepo.Create(ctx, &websiteSSL); err != nil {
|
if err := websiteSSLRepo.Create(ctx, &websiteSSL); err != nil {
|
||||||
return dto.WebsiteHTTPS{}, err
|
return response.WebsiteHTTPS{}, err
|
||||||
}
|
}
|
||||||
website.WebSiteSSLID = websiteSSL.ID
|
website.WebsiteSSLID = websiteSSL.ID
|
||||||
}
|
}
|
||||||
if err := websiteRepo.Save(ctx, &website); err != nil {
|
if err := websiteRepo.Save(ctx, &website); err != nil {
|
||||||
return dto.WebsiteHTTPS{}, err
|
return response.WebsiteHTTPS{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteService) PreInstallCheck(req dto.WebsiteInstallCheckReq) ([]dto.WebsitePreInstallCheck, error) {
|
func (w WebsiteService) PreInstallCheck(req request.WebsiteInstallCheckReq) ([]response.WebsitePreInstallCheck, error) {
|
||||||
var (
|
var (
|
||||||
res []dto.WebsitePreInstallCheck
|
res []response.WebsitePreInstallCheck
|
||||||
checkIds []uint
|
checkIds []uint
|
||||||
showErr = false
|
showErr = false
|
||||||
)
|
)
|
||||||
@ -529,7 +530,7 @@ func (w WebsiteService) PreInstallCheck(req dto.WebsiteInstallCheckReq) ([]dto.W
|
|||||||
}
|
}
|
||||||
appInstall, _ := appInstallRepo.GetFirst(appInstallRepo.WithAppId(app.ID))
|
appInstall, _ := appInstallRepo.GetFirst(appInstallRepo.WithAppId(app.ID))
|
||||||
if reflect.DeepEqual(appInstall, model.AppInstall{}) {
|
if reflect.DeepEqual(appInstall, model.AppInstall{}) {
|
||||||
res = append(res, dto.WebsitePreInstallCheck{
|
res = append(res, response.WebsitePreInstallCheck{
|
||||||
Name: appInstall.Name,
|
Name: appInstall.Name,
|
||||||
AppName: app.Name,
|
AppName: app.Name,
|
||||||
Status: buserr.WithMessage(constant.ErrNotInstall, app.Name, nil).Error(),
|
Status: buserr.WithMessage(constant.ErrNotInstall, app.Name, nil).Error(),
|
||||||
@ -547,7 +548,7 @@ func (w WebsiteService) PreInstallCheck(req dto.WebsiteInstallCheckReq) ([]dto.W
|
|||||||
if len(checkIds) > 0 {
|
if len(checkIds) > 0 {
|
||||||
installList, _ := appInstallRepo.GetBy(commonRepo.WithIdsIn(checkIds))
|
installList, _ := appInstallRepo.GetBy(commonRepo.WithIdsIn(checkIds))
|
||||||
for _, install := range installList {
|
for _, install := range installList {
|
||||||
res = append(res, dto.WebsitePreInstallCheck{
|
res = append(res, response.WebsitePreInstallCheck{
|
||||||
Name: install.Name,
|
Name: install.Name,
|
||||||
Status: install.Status,
|
Status: install.Status,
|
||||||
Version: install.Version,
|
Version: install.Version,
|
||||||
@ -565,8 +566,8 @@ func (w WebsiteService) PreInstallCheck(req dto.WebsiteInstallCheckReq) ([]dto.W
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteService) GetWafConfig(req request.WebsiteWafReq) (dto.WebsiteWafConfig, error) {
|
func (w WebsiteService) GetWafConfig(req request.WebsiteWafReq) (response.WebsiteWafConfig, error) {
|
||||||
var res dto.WebsiteWafConfig
|
var res response.WebsiteWafConfig
|
||||||
website, err := websiteRepo.GetFirst(commonRepo.WithByID(req.WebsiteID))
|
website, err := websiteRepo.GetFirst(commonRepo.WithByID(req.WebsiteID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, nil
|
return res, nil
|
||||||
|
@ -8,10 +8,10 @@ import (
|
|||||||
"github.com/1Panel-dev/1Panel/backend/utils/ssl"
|
"github.com/1Panel-dev/1Panel/backend/utils/ssl"
|
||||||
)
|
)
|
||||||
|
|
||||||
type WebSiteAcmeAccountService struct {
|
type WebsiteAcmeAccountService struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteAcmeAccountService) Page(search dto.PageInfo) (int64, []dto.WebsiteAcmeAccountDTO, error) {
|
func (w WebsiteAcmeAccountService) Page(search dto.PageInfo) (int64, []dto.WebsiteAcmeAccountDTO, error) {
|
||||||
total, accounts, err := websiteAcmeRepo.Page(search.Page, search.PageSize, commonRepo.WithOrderBy("created_at desc"))
|
total, accounts, err := websiteAcmeRepo.Page(search.Page, search.PageSize, commonRepo.WithOrderBy("created_at desc"))
|
||||||
var accountDTOs []dto.WebsiteAcmeAccountDTO
|
var accountDTOs []dto.WebsiteAcmeAccountDTO
|
||||||
for _, account := range accounts {
|
for _, account := range accounts {
|
||||||
@ -22,7 +22,7 @@ func (w WebSiteAcmeAccountService) Page(search dto.PageInfo) (int64, []dto.Websi
|
|||||||
return total, accountDTOs, err
|
return total, accountDTOs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteAcmeAccountService) Create(create dto.WebsiteAcmeAccountCreate) (dto.WebsiteAcmeAccountDTO, error) {
|
func (w WebsiteAcmeAccountService) Create(create dto.WebsiteAcmeAccountCreate) (dto.WebsiteAcmeAccountDTO, error) {
|
||||||
client, err := ssl.NewAcmeClient(create.Email, "")
|
client, err := ssl.NewAcmeClient(create.Email, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return dto.WebsiteAcmeAccountDTO{}, err
|
return dto.WebsiteAcmeAccountDTO{}, err
|
||||||
@ -38,7 +38,7 @@ func (w WebSiteAcmeAccountService) Create(create dto.WebsiteAcmeAccountCreate) (
|
|||||||
return dto.WebsiteAcmeAccountDTO{WebsiteAcmeAccount: acmeAccount}, nil
|
return dto.WebsiteAcmeAccountDTO{WebsiteAcmeAccount: acmeAccount}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteAcmeAccountService) Delete(id uint) error {
|
func (w WebsiteAcmeAccountService) Delete(id uint) error {
|
||||||
if ssls, _ := websiteSSLRepo.List(websiteSSLRepo.WithByAcmeAccountId(id)); len(ssls) > 0 {
|
if ssls, _ := websiteSSLRepo.List(websiteSSLRepo.WithByAcmeAccountId(id)); len(ssls) > 0 {
|
||||||
return buserr.New(constant.ErrAccountCannotDelete)
|
return buserr.New(constant.ErrAccountCannotDelete)
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,10 @@ import (
|
|||||||
"gopkg.in/square/go-jose.v2/json"
|
"gopkg.in/square/go-jose.v2/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
type WebSiteDnsAccountService struct {
|
type WebsiteDnsAccountService struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteDnsAccountService) Page(search dto.PageInfo) (int64, []dto.WebsiteDnsAccountDTO, error) {
|
func (w WebsiteDnsAccountService) Page(search dto.PageInfo) (int64, []dto.WebsiteDnsAccountDTO, error) {
|
||||||
total, accounts, err := websiteDnsRepo.Page(search.Page, search.PageSize, commonRepo.WithOrderBy("created_at desc"))
|
total, accounts, err := websiteDnsRepo.Page(search.Page, search.PageSize, commonRepo.WithOrderBy("created_at desc"))
|
||||||
var accountDTOs []dto.WebsiteDnsAccountDTO
|
var accountDTOs []dto.WebsiteDnsAccountDTO
|
||||||
for _, account := range accounts {
|
for _, account := range accounts {
|
||||||
@ -25,7 +25,7 @@ func (w WebSiteDnsAccountService) Page(search dto.PageInfo) (int64, []dto.Websit
|
|||||||
return total, accountDTOs, err
|
return total, accountDTOs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteDnsAccountService) Create(create dto.WebsiteDnsAccountCreate) (dto.WebsiteDnsAccountCreate, error) {
|
func (w WebsiteDnsAccountService) Create(create dto.WebsiteDnsAccountCreate) (dto.WebsiteDnsAccountCreate, error) {
|
||||||
authorization, err := json.Marshal(create.Authorization)
|
authorization, err := json.Marshal(create.Authorization)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return dto.WebsiteDnsAccountCreate{}, err
|
return dto.WebsiteDnsAccountCreate{}, err
|
||||||
@ -42,7 +42,7 @@ func (w WebSiteDnsAccountService) Create(create dto.WebsiteDnsAccountCreate) (dt
|
|||||||
return create, nil
|
return create, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteDnsAccountService) Update(update dto.WebsiteDnsAccountUpdate) (dto.WebsiteDnsAccountUpdate, error) {
|
func (w WebsiteDnsAccountService) Update(update dto.WebsiteDnsAccountUpdate) (dto.WebsiteDnsAccountUpdate, error) {
|
||||||
authorization, err := json.Marshal(update.Authorization)
|
authorization, err := json.Marshal(update.Authorization)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return dto.WebsiteDnsAccountUpdate{}, err
|
return dto.WebsiteDnsAccountUpdate{}, err
|
||||||
@ -62,7 +62,7 @@ func (w WebSiteDnsAccountService) Update(update dto.WebsiteDnsAccountUpdate) (dt
|
|||||||
return update, nil
|
return update, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteDnsAccountService) Delete(id uint) error {
|
func (w WebsiteDnsAccountService) Delete(id uint) error {
|
||||||
if ssls, _ := websiteSSLRepo.List(websiteSSLRepo.WithByDnsAccountId(id)); len(ssls) > 0 {
|
if ssls, _ := websiteSSLRepo.List(websiteSSLRepo.WithByDnsAccountId(id)); len(ssls) > 0 {
|
||||||
return buserr.New(constant.ErrAccountCannotDelete)
|
return buserr.New(constant.ErrAccountCannotDelete)
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,30 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/model"
|
"github.com/1Panel-dev/1Panel/backend/app/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
type WebsiteGroupService struct {
|
type WebsiteGroupService struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteGroupService) CreateGroup(create dto.WebSiteGroupCreate) error {
|
func (w WebsiteGroupService) CreateGroup(create request.WebsiteGroupCreate) error {
|
||||||
return websiteGroupRepo.Create(&model.WebSiteGroup{
|
return websiteGroupRepo.Create(&model.WebsiteGroup{
|
||||||
Name: create.Name,
|
Name: create.Name,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteGroupService) GetGroups() ([]model.WebSiteGroup, error) {
|
func (w WebsiteGroupService) GetGroups() ([]model.WebsiteGroup, error) {
|
||||||
return websiteGroupRepo.GetBy()
|
return websiteGroupRepo.GetBy()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteGroupService) UpdateGroup(update dto.WebSiteGroupUpdate) error {
|
func (w WebsiteGroupService) UpdateGroup(update request.WebsiteGroupUpdate) error {
|
||||||
|
|
||||||
if update.Default {
|
if update.Default {
|
||||||
if err := websiteGroupRepo.CancelDefault(); err != nil {
|
if err := websiteGroupRepo.CancelDefault(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return websiteGroupRepo.Save(&model.WebSiteGroup{
|
return websiteGroupRepo.Save(&model.WebsiteGroup{
|
||||||
BaseModel: model.BaseModel{
|
BaseModel: model.BaseModel{
|
||||||
ID: update.ID,
|
ID: update.ID,
|
||||||
},
|
},
|
||||||
@ -32,7 +32,7 @@ func (w WebsiteGroupService) UpdateGroup(update dto.WebSiteGroupUpdate) error {
|
|||||||
Default: true,
|
Default: true,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
return websiteGroupRepo.Save(&model.WebSiteGroup{
|
return websiteGroupRepo.Save(&model.WebsiteGroup{
|
||||||
BaseModel: model.BaseModel{
|
BaseModel: model.BaseModel{
|
||||||
ID: update.ID,
|
ID: update.ID,
|
||||||
},
|
},
|
||||||
|
@ -13,10 +13,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type WebSiteSSLService struct {
|
type WebsiteSSLService struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteSSLService) Page(search dto.WebsiteSSLSearch) (int64, []dto.WebsiteSSLDTO, error) {
|
func (w WebsiteSSLService) Page(search dto.WebsiteSSLSearch) (int64, []dto.WebsiteSSLDTO, error) {
|
||||||
total, sslList, err := websiteSSLRepo.Page(search.Page, search.PageSize, commonRepo.WithOrderBy("created_at desc"))
|
total, sslList, err := websiteSSLRepo.Page(search.Page, search.PageSize, commonRepo.WithOrderBy("created_at desc"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, nil, err
|
return 0, nil, err
|
||||||
@ -24,13 +24,13 @@ func (w WebSiteSSLService) Page(search dto.WebsiteSSLSearch) (int64, []dto.Websi
|
|||||||
var sslDTOs []dto.WebsiteSSLDTO
|
var sslDTOs []dto.WebsiteSSLDTO
|
||||||
for _, ssl := range sslList {
|
for _, ssl := range sslList {
|
||||||
sslDTOs = append(sslDTOs, dto.WebsiteSSLDTO{
|
sslDTOs = append(sslDTOs, dto.WebsiteSSLDTO{
|
||||||
WebSiteSSL: ssl,
|
WebsiteSSL: ssl,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return total, sslDTOs, err
|
return total, sslDTOs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteSSLService) Search() ([]dto.WebsiteSSLDTO, error) {
|
func (w WebsiteSSLService) Search() ([]dto.WebsiteSSLDTO, error) {
|
||||||
sslList, err := websiteSSLRepo.List()
|
sslList, err := websiteSSLRepo.List()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -38,13 +38,13 @@ func (w WebSiteSSLService) Search() ([]dto.WebsiteSSLDTO, error) {
|
|||||||
var sslDTOs []dto.WebsiteSSLDTO
|
var sslDTOs []dto.WebsiteSSLDTO
|
||||||
for _, ssl := range sslList {
|
for _, ssl := range sslList {
|
||||||
sslDTOs = append(sslDTOs, dto.WebsiteSSLDTO{
|
sslDTOs = append(sslDTOs, dto.WebsiteSSLDTO{
|
||||||
WebSiteSSL: ssl,
|
WebsiteSSL: ssl,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return sslDTOs, err
|
return sslDTOs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteSSLService) Create(create dto.WebsiteSSLCreate) (dto.WebsiteSSLCreate, error) {
|
func (w WebsiteSSLService) Create(create dto.WebsiteSSLCreate) (dto.WebsiteSSLCreate, error) {
|
||||||
|
|
||||||
var res dto.WebsiteSSLCreate
|
var res dto.WebsiteSSLCreate
|
||||||
acmeAccount, err := websiteAcmeRepo.GetFirst(commonRepo.WithByID(create.AcmeAccountID))
|
acmeAccount, err := websiteAcmeRepo.GetFirst(commonRepo.WithByID(create.AcmeAccountID))
|
||||||
@ -87,7 +87,7 @@ func (w WebSiteSSLService) Create(create dto.WebsiteSSLCreate) (dto.WebsiteSSLCr
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
var websiteSSL model.WebSiteSSL
|
var websiteSSL model.WebsiteSSL
|
||||||
websiteSSL.DnsAccountID = create.DnsAccountID
|
websiteSSL.DnsAccountID = create.DnsAccountID
|
||||||
websiteSSL.AcmeAccountID = acmeAccount.ID
|
websiteSSL.AcmeAccountID = acmeAccount.ID
|
||||||
websiteSSL.Provider = string(create.Provider)
|
websiteSSL.Provider = string(create.Provider)
|
||||||
@ -113,7 +113,7 @@ func (w WebSiteSSLService) Create(create dto.WebsiteSSLCreate) (dto.WebsiteSSLCr
|
|||||||
return create, nil
|
return create, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteSSLService) Renew(sslId uint) error {
|
func (w WebsiteSSLService) Renew(sslId uint) error {
|
||||||
|
|
||||||
websiteSSL, err := websiteSSLRepo.GetFirst(commonRepo.WithByID(sslId))
|
websiteSSL, err := websiteSSLRepo.GetFirst(commonRepo.WithByID(sslId))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -169,7 +169,7 @@ func (w WebSiteSSLService) Renew(sslId uint) error {
|
|||||||
return websiteSSLRepo.Save(websiteSSL)
|
return websiteSSLRepo.Save(websiteSSL)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteSSLService) GetDNSResolve(req dto.WebsiteDNSReq) ([]dto.WebsiteDNSRes, error) {
|
func (w WebsiteSSLService) GetDNSResolve(req dto.WebsiteDNSReq) ([]dto.WebsiteDNSRes, error) {
|
||||||
acmeAccount, err := websiteAcmeRepo.GetFirst(commonRepo.WithByID(req.AcmeAccountID))
|
acmeAccount, err := websiteAcmeRepo.GetFirst(commonRepo.WithByID(req.AcmeAccountID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -195,21 +195,21 @@ func (w WebSiteSSLService) GetDNSResolve(req dto.WebsiteDNSReq) ([]dto.WebsiteDN
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteSSLService) GetWebsiteSSL(websiteId uint) (dto.WebsiteSSLDTO, error) {
|
func (w WebsiteSSLService) GetWebsiteSSL(websiteId uint) (dto.WebsiteSSLDTO, error) {
|
||||||
var res dto.WebsiteSSLDTO
|
var res dto.WebsiteSSLDTO
|
||||||
website, err := websiteRepo.GetFirst(commonRepo.WithByID(websiteId))
|
website, err := websiteRepo.GetFirst(commonRepo.WithByID(websiteId))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
websiteSSL, err := websiteSSLRepo.GetFirst(commonRepo.WithByID(website.WebSiteSSLID))
|
websiteSSL, err := websiteSSLRepo.GetFirst(commonRepo.WithByID(website.WebsiteSSLID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
res.WebSiteSSL = websiteSSL
|
res.WebsiteSSL = websiteSSL
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebSiteSSLService) Delete(id uint) error {
|
func (w WebsiteSSLService) Delete(id uint) error {
|
||||||
if websites, _ := websiteRepo.GetBy(websiteRepo.WithWebsiteSSLID(id)); len(websites) > 0 {
|
if websites, _ := websiteRepo.GetBy(websiteRepo.WithWebsiteSSLID(id)); len(websites) > 0 {
|
||||||
return buserr.New(constant.ErrSSLCannotDelete)
|
return buserr.New(constant.ErrSSLCannotDelete)
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getDomain(domainStr string, websiteID uint) (model.WebSiteDomain, error) {
|
func getDomain(domainStr string, websiteID uint) (model.WebsiteDomain, error) {
|
||||||
domain := model.WebSiteDomain{
|
domain := model.WebsiteDomain{
|
||||||
WebSiteID: websiteID,
|
WebsiteID: websiteID,
|
||||||
}
|
}
|
||||||
domainArray := strings.Split(domainStr, ":")
|
domainArray := strings.Split(domainStr, ":")
|
||||||
if len(domainArray) == 1 {
|
if len(domainArray) == 1 {
|
||||||
@ -39,15 +39,15 @@ func getDomain(domainStr string, websiteID uint) (model.WebSiteDomain, error) {
|
|||||||
portStr := domainArray[1]
|
portStr := domainArray[1]
|
||||||
portN, err := strconv.Atoi(portStr)
|
portN, err := strconv.Atoi(portStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return model.WebSiteDomain{}, err
|
return model.WebsiteDomain{}, err
|
||||||
}
|
}
|
||||||
domain.Port = portN
|
domain.Port = portN
|
||||||
return domain, nil
|
return domain, nil
|
||||||
}
|
}
|
||||||
return model.WebSiteDomain{}, nil
|
return model.WebsiteDomain{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createStaticHtml(website *model.WebSite) error {
|
func createStaticHtml(website *model.Website) error {
|
||||||
nginxInstall, err := getAppInstallByKey("nginx")
|
nginxInstall, err := getAppInstallByKey("nginx")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -73,7 +73,7 @@ func createStaticHtml(website *model.WebSite) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createWebsiteFolder(nginxInstall model.AppInstall, website *model.WebSite) error {
|
func createWebsiteFolder(nginxInstall model.AppInstall, website *model.Website) error {
|
||||||
nginxFolder := path.Join(constant.AppInstallDir, "nginx", nginxInstall.Name)
|
nginxFolder := path.Join(constant.AppInstallDir, "nginx", nginxInstall.Name)
|
||||||
siteFolder := path.Join(nginxFolder, "www", "sites", website.Alias)
|
siteFolder := path.Join(nginxFolder, "www", "sites", website.Alias)
|
||||||
fileOp := files.NewFileOp()
|
fileOp := files.NewFileOp()
|
||||||
@ -97,7 +97,7 @@ func createWebsiteFolder(nginxInstall model.AppInstall, website *model.WebSite)
|
|||||||
return fileOp.CopyDir(path.Join(nginxFolder, "www", "common", "waf", "rules"), path.Join(siteFolder, "waf"))
|
return fileOp.CopyDir(path.Join(nginxFolder, "www", "common", "waf", "rules"), path.Join(siteFolder, "waf"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func configDefaultNginx(website *model.WebSite, domains []model.WebSiteDomain) error {
|
func configDefaultNginx(website *model.Website, domains []model.WebsiteDomain) error {
|
||||||
nginxInstall, err := getAppInstallByKey("nginx")
|
nginxInstall, err := getAppInstallByKey("nginx")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -155,7 +155,7 @@ func configDefaultNginx(website *model.WebSite, domains []model.WebSiteDomain) e
|
|||||||
return opNginx(nginxInstall.ContainerName, constant.NginxReload)
|
return opNginx(nginxInstall.ContainerName, constant.NginxReload)
|
||||||
}
|
}
|
||||||
|
|
||||||
func delNginxConfig(website model.WebSite, force bool) error {
|
func delNginxConfig(website model.Website, force bool) error {
|
||||||
nginxApp, err := appRepo.GetFirst(appRepo.WithKey("nginx"))
|
nginxApp, err := appRepo.GetFirst(appRepo.WithKey("nginx"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -187,7 +187,7 @@ func delNginxConfig(website model.WebSite, force bool) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func addListenAndServerName(website model.WebSite, ports []int, domains []string) error {
|
func addListenAndServerName(website model.Website, ports []int, domains []string) error {
|
||||||
nginxFull, err := getNginxFull(&website)
|
nginxFull, err := getNginxFull(&website)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
@ -207,7 +207,7 @@ func addListenAndServerName(website model.WebSite, ports []int, domains []string
|
|||||||
return nginxCheckAndReload(nginxConfig.OldContent, nginxConfig.FilePath, nginxFull.Install.ContainerName)
|
return nginxCheckAndReload(nginxConfig.OldContent, nginxConfig.FilePath, nginxFull.Install.ContainerName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteListenAndServerName(website model.WebSite, ports []int, domains []string) error {
|
func deleteListenAndServerName(website model.Website, ports []int, domains []string) error {
|
||||||
nginxFull, err := getNginxFull(&website)
|
nginxFull, err := getNginxFull(&website)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
@ -241,7 +241,7 @@ func getKeysFromStaticFile(scope dto.NginxKey) []string {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func createPemFile(website model.WebSite, websiteSSL model.WebSiteSSL) error {
|
func createPemFile(website model.Website, websiteSSL model.WebsiteSSL) error {
|
||||||
nginxApp, err := appRepo.GetFirst(appRepo.WithKey("nginx"))
|
nginxApp, err := appRepo.GetFirst(appRepo.WithKey("nginx"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -283,7 +283,7 @@ func createPemFile(website model.WebSite, websiteSSL model.WebSiteSSL) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func applySSL(website model.WebSite, websiteSSL model.WebSiteSSL) error {
|
func applySSL(website model.Website, websiteSSL model.WebsiteSSL) error {
|
||||||
nginxFull, err := getNginxFull(&website)
|
nginxFull, err := getNginxFull(&website)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
@ -369,7 +369,7 @@ func toMapStr(m map[string]interface{}) map[string]string {
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebSiteInfo struct {
|
type WebsiteInfo struct {
|
||||||
WebsiteName string `json:"websiteName"`
|
WebsiteName string `json:"websiteName"`
|
||||||
WebsiteType string `json:"websiteType"`
|
WebsiteType string `json:"websiteType"`
|
||||||
}
|
}
|
||||||
@ -444,7 +444,7 @@ func handleWebsiteBackup(backupType, baseDir, backupDir, domain, backupName stri
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleWebsiteRecover(website *model.WebSite, fileDir string) error {
|
func handleWebsiteRecover(website *model.Website, fileDir string) error {
|
||||||
nginxInfo, err := appInstallRepo.LoadBaseInfoByKey("nginx")
|
nginxInfo, err := appInstallRepo.LoadBaseInfoByKey("nginx")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -486,7 +486,7 @@ func handleWebsiteRecover(website *model.WebSite, fileDir string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func mysqlOpration(website *model.WebSite, operation, filePath string) error {
|
func mysqlOpration(website *model.Website, operation, filePath string) error {
|
||||||
mysqlInfo, err := appInstallRepo.LoadBaseInfoByKey("mysql")
|
mysqlInfo, err := appInstallRepo.LoadBaseInfoByKey("mysql")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -523,11 +523,11 @@ func mysqlOpration(website *model.WebSite, operation, filePath string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func saveWebsiteJson(website *model.WebSite, tmpDir string) error {
|
func saveWebsiteJson(website *model.Website, tmpDir string) error {
|
||||||
var WebSiteInfo WebSiteInfo
|
var websiteInfo WebsiteInfo
|
||||||
WebSiteInfo.WebsiteType = website.Type
|
websiteInfo.WebsiteType = website.Type
|
||||||
WebSiteInfo.WebsiteName = website.PrimaryDomain
|
websiteInfo.WebsiteName = website.PrimaryDomain
|
||||||
remarkInfo, _ := json.Marshal(WebSiteInfo)
|
remarkInfo, _ := json.Marshal(websiteInfo)
|
||||||
path := fmt.Sprintf("%s/website.json", tmpDir)
|
path := fmt.Sprintf("%s/website.json", tmpDir)
|
||||||
file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE, 0666)
|
file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -6,13 +6,9 @@ const (
|
|||||||
Error = "Error"
|
Error = "Error"
|
||||||
Stopped = "Stopped"
|
Stopped = "Stopped"
|
||||||
Installing = "Installing"
|
Installing = "Installing"
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
ContainerPrefix = "1Panel-"
|
ContainerPrefix = "1Panel-"
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
AppNormal = "Normal"
|
AppNormal = "Normal"
|
||||||
AppTakeDown = "TakeDown"
|
AppTakeDown = "TakeDown"
|
||||||
)
|
)
|
||||||
|
@ -3,20 +3,21 @@ package constant
|
|||||||
const (
|
const (
|
||||||
WebRunning = "Running"
|
WebRunning = "Running"
|
||||||
WebStopped = "Stopped"
|
WebStopped = "Stopped"
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
DateLayout = "2006-01-02"
|
DateLayout = "2006-01-02"
|
||||||
DefaultDate = "1970-01-01"
|
DefaultDate = "1970-01-01"
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
ProtocolHTTP = "HTTP"
|
ProtocolHTTP = "HTTP"
|
||||||
ProtocolHTTPS = "HTTPS"
|
ProtocolHTTPS = "HTTPS"
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
NewApp = "new"
|
||||||
|
InstalledApp = "installed"
|
||||||
|
|
||||||
Deployment = "deployment"
|
Deployment = "deployment"
|
||||||
Static = "static"
|
Static = "static"
|
||||||
Proxy = "proxy"
|
Proxy = "proxy"
|
||||||
|
|
||||||
|
SSLExisted = "existed"
|
||||||
|
SSLAuto = "auto"
|
||||||
|
SSLManual = "manual"
|
||||||
)
|
)
|
||||||
|
@ -185,10 +185,10 @@ var AddTableDatabaseMysql = &gormigrate.Migration{
|
|||||||
var AddTableWebsite = &gormigrate.Migration{
|
var AddTableWebsite = &gormigrate.Migration{
|
||||||
ID: "20201009-add-table-website",
|
ID: "20201009-add-table-website",
|
||||||
Migrate: func(tx *gorm.DB) error {
|
Migrate: func(tx *gorm.DB) error {
|
||||||
if err := tx.AutoMigrate(&model.WebSite{}, &model.WebSiteDomain{}, &model.WebSiteGroup{}, &model.WebsiteDnsAccount{}, &model.WebSiteSSL{}, &model.WebsiteAcmeAccount{}); err != nil {
|
if err := tx.AutoMigrate(&model.Website{}, &model.WebsiteDomain{}, &model.WebsiteGroup{}, &model.WebsiteDnsAccount{}, &model.WebsiteSSL{}, &model.WebsiteAcmeAccount{}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
item := &model.WebSiteGroup{
|
item := &model.WebsiteGroup{
|
||||||
Name: "默认分组",
|
Name: "默认分组",
|
||||||
Default: true,
|
Default: true,
|
||||||
}
|
}
|
||||||
|
@ -15,20 +15,22 @@ func (a *WebsiteRouter) InitWebsiteRouter(Router *gin.RouterGroup) {
|
|||||||
|
|
||||||
baseApi := v1.ApiGroupApp.BaseApi
|
baseApi := v1.ApiGroupApp.BaseApi
|
||||||
{
|
{
|
||||||
|
groupRouter.POST("/search", baseApi.PageWebsite)
|
||||||
groupRouter.POST("", baseApi.CreateWebsite)
|
groupRouter.POST("", baseApi.CreateWebsite)
|
||||||
groupRouter.POST("/check", baseApi.CreateWebsiteCheck)
|
groupRouter.POST("/check", baseApi.CreateWebsiteCheck)
|
||||||
groupRouter.GET("/options", baseApi.GetWebsiteOptions)
|
groupRouter.GET("/options", baseApi.GetWebsiteOptions)
|
||||||
|
groupRouter.POST("/update", baseApi.UpdateWebsite)
|
||||||
|
groupRouter.GET("/:id", baseApi.GetWebsite)
|
||||||
|
groupRouter.POST("/del", baseApi.DeleteWebsite)
|
||||||
groupRouter.POST("/backup/:domain", baseApi.BackupWebsite)
|
groupRouter.POST("/backup/:domain", baseApi.BackupWebsite)
|
||||||
groupRouter.POST("/recover", baseApi.RecoverWebsite)
|
groupRouter.POST("/recover", baseApi.RecoverWebsite)
|
||||||
groupRouter.POST("/recover/byupload", baseApi.RecoverWebsiteByUpload)
|
groupRouter.POST("/recover/byupload", baseApi.RecoverWebsiteByUpload)
|
||||||
groupRouter.POST("/update", baseApi.UpdateWebSite)
|
|
||||||
groupRouter.GET("/:id", baseApi.GetWebSite)
|
|
||||||
groupRouter.GET("/:id/nginx", baseApi.GetWebSiteNginx)
|
|
||||||
groupRouter.POST("/search", baseApi.PageWebsite)
|
|
||||||
groupRouter.POST("/del", baseApi.DeleteWebSite)
|
|
||||||
groupRouter.GET("/domains/:websiteId", baseApi.GetWebDomains)
|
groupRouter.GET("/domains/:websiteId", baseApi.GetWebDomains)
|
||||||
groupRouter.DELETE("/domains/:id", baseApi.DeleteWebDomain)
|
groupRouter.POST("/domains/del", baseApi.DeleteWebDomain)
|
||||||
groupRouter.POST("/domains", baseApi.CreateWebDomain)
|
groupRouter.POST("/domains", baseApi.CreateWebDomain)
|
||||||
|
|
||||||
|
groupRouter.GET("/:id/nginx", baseApi.GetWebsiteNginx)
|
||||||
groupRouter.POST("/config", baseApi.GetNginxConfig)
|
groupRouter.POST("/config", baseApi.GetNginxConfig)
|
||||||
groupRouter.POST("/config/update", baseApi.UpdateNginxConfig)
|
groupRouter.POST("/config/update", baseApi.UpdateNginxConfig)
|
||||||
groupRouter.GET("/:id/https", baseApi.GetHTTPSConfig)
|
groupRouter.GET("/:id/https", baseApi.GetHTTPSConfig)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { CommonModel, ReqPage } from '.';
|
import { CommonModel, ReqPage } from '.';
|
||||||
|
|
||||||
export namespace WebSite {
|
export namespace Website {
|
||||||
export interface WebSite extends CommonModel {
|
export interface Website extends CommonModel {
|
||||||
primaryDomain: string;
|
primaryDomain: string;
|
||||||
type: string;
|
type: string;
|
||||||
alias: string;
|
alias: string;
|
||||||
@ -15,19 +15,6 @@ export namespace WebSite {
|
|||||||
webSiteSSL: SSL;
|
webSiteSSL: SSL;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WebSiteDTO extends CommonModel {
|
|
||||||
primaryDomain: string;
|
|
||||||
type: string;
|
|
||||||
alias: string;
|
|
||||||
remark: string;
|
|
||||||
domains: WebSite.Domain[];
|
|
||||||
appType: string;
|
|
||||||
appInstallId?: number;
|
|
||||||
webSiteGroupId: number;
|
|
||||||
otherDomains: string;
|
|
||||||
appinstall?: NewAppInstall;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NewAppInstall {
|
export interface NewAppInstall {
|
||||||
name: string;
|
name: string;
|
||||||
appDetailId: number;
|
appDetailId: number;
|
||||||
@ -100,6 +87,10 @@ export namespace WebSite {
|
|||||||
domain: string;
|
domain: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DomainDelete {
|
||||||
|
id: number;
|
||||||
|
}
|
||||||
|
|
||||||
export interface NginxConfigReq {
|
export interface NginxConfigReq {
|
||||||
operate: string;
|
operate: string;
|
||||||
websiteId: number;
|
websiteId: number;
|
||||||
|
@ -1,32 +1,34 @@
|
|||||||
import http from '@/api';
|
import http from '@/api';
|
||||||
import { ReqPage, ResPage } from '../interface';
|
import { ReqPage, ResPage } from '../interface';
|
||||||
import { WebSite } from '../interface/website';
|
import { Website } from '../interface/Website';
|
||||||
import { File } from '../interface/file';
|
import { File } from '../interface/file';
|
||||||
|
|
||||||
export const SearchWebSites = (req: WebSite.WebSiteSearch) => {
|
export const SearchWebsites = (req: Website.WebSiteSearch) => {
|
||||||
return http.post<ResPage<WebSite.WebSite>>(`/websites/search`, req);
|
return http.post<ResPage<Website.Website>>(`/websites/search`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CreateWebsite = (req: WebSite.WebSiteCreateReq) => {
|
export const CreateWebsite = (req: Website.WebSiteCreateReq) => {
|
||||||
return http.post<any>(`/websites`, req);
|
return http.post<any>(`/websites`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const BackupWebsite = (id: number) => {
|
export const BackupWebsite = (id: number) => {
|
||||||
return http.post(`/websites/backup/${id}`);
|
return http.post(`/websites/backup/${id}`);
|
||||||
};
|
};
|
||||||
export const RecoverWebsite = (req: WebSite.WebSiteRecover) => {
|
|
||||||
|
export const RecoverWebsite = (req: Website.WebSiteRecover) => {
|
||||||
return http.post(`/websites/recover`, req);
|
return http.post(`/websites/recover`, req);
|
||||||
};
|
};
|
||||||
export const RecoverWebsiteByUpload = (req: WebSite.WebsiteRecoverByUpload) => {
|
|
||||||
|
export const RecoverWebsiteByUpload = (req: Website.WebsiteRecoverByUpload) => {
|
||||||
return http.post(`/websites/recover/byupload`, req);
|
return http.post(`/websites/recover/byupload`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const UpdateWebsite = (req: WebSite.WebSiteUpdateReq) => {
|
export const UpdateWebsite = (req: Website.WebSiteUpdateReq) => {
|
||||||
return http.post<any>(`/websites/update`, req);
|
return http.post<any>(`/websites/update`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const GetWebsite = (id: number) => {
|
export const GetWebsite = (id: number) => {
|
||||||
return http.get<WebSite.WebSiteDTO>(`/websites/${id}`);
|
return http.get<Website.Website>(`/websites/${id}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const GetWebsiteOptions = () => {
|
export const GetWebsiteOptions = () => {
|
||||||
@ -37,19 +39,19 @@ export const GetWebsiteNginx = (id: number) => {
|
|||||||
return http.get<File.File>(`/websites/${id}/nginx`);
|
return http.get<File.File>(`/websites/${id}/nginx`);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DeleteWebsite = (req: WebSite.WebSiteDel) => {
|
export const DeleteWebsite = (req: Website.WebSiteDel) => {
|
||||||
return http.post<any>(`/websites/del`, req);
|
return http.post<any>(`/websites/del`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ListGroups = () => {
|
export const ListGroups = () => {
|
||||||
return http.get<WebSite.Group[]>(`/websites/groups`);
|
return http.get<Website.Group[]>(`/websites/groups`);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CreateGroup = (req: WebSite.GroupOp) => {
|
export const CreateGroup = (req: Website.GroupOp) => {
|
||||||
return http.post<any>(`/websites/groups`, req);
|
return http.post<any>(`/websites/groups`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const UpdateGroup = (req: WebSite.GroupOp) => {
|
export const UpdateGroup = (req: Website.GroupOp) => {
|
||||||
return http.put<any>(`/websites/groups`, req);
|
return http.put<any>(`/websites/groups`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -58,34 +60,34 @@ export const DeleteGroup = (id: number) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const ListDomains = (id: number) => {
|
export const ListDomains = (id: number) => {
|
||||||
return http.get<WebSite.Domain[]>(`/websites/domains/${id}`);
|
return http.get<Website.Domain[]>(`/websites/domains/${id}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DeleteDomain = (id: number) => {
|
export const DeleteDomain = (req: Website.DomainDelete) => {
|
||||||
return http.delete<any>(`/websites/domains/${id}`);
|
return http.post<any>(`/websites/domains/del/`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CreateDomain = (req: WebSite.DomainCreate) => {
|
export const CreateDomain = (req: Website.DomainCreate) => {
|
||||||
return http.post<any>(`/websites/domains`, req);
|
return http.post<any>(`/websites/domains`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const GetNginxConfig = (req: WebSite.NginxConfigReq) => {
|
export const GetNginxConfig = (req: Website.NginxConfigReq) => {
|
||||||
return http.post<WebSite.NginxScopeConfig>(`/websites/config`, req);
|
return http.post<Website.NginxScopeConfig>(`/websites/config`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const UpdateNginxConfig = (req: WebSite.NginxConfigReq) => {
|
export const UpdateNginxConfig = (req: Website.NginxConfigReq) => {
|
||||||
return http.post<any>(`/websites/config/update`, req);
|
return http.post<any>(`/websites/config/update`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SearchDnsAccount = (req: ReqPage) => {
|
export const SearchDnsAccount = (req: ReqPage) => {
|
||||||
return http.post<ResPage<WebSite.DnsAccount>>(`/websites/dns/search`, req);
|
return http.post<ResPage<Website.DnsAccount>>(`/websites/dns/search`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CreateDnsAccount = (req: WebSite.DnsAccountCreate) => {
|
export const CreateDnsAccount = (req: Website.DnsAccountCreate) => {
|
||||||
return http.post<any>(`/websites/dns`, req);
|
return http.post<any>(`/websites/dns`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const UpdateDnsAccount = (req: WebSite.DnsAccountUpdate) => {
|
export const UpdateDnsAccount = (req: Website.DnsAccountUpdate) => {
|
||||||
return http.post<any>(`/websites/dns/update`, req);
|
return http.post<any>(`/websites/dns/update`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -94,11 +96,11 @@ export const DeleteDnsAccount = (id: number) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const SearchAcmeAccount = (req: ReqPage) => {
|
export const SearchAcmeAccount = (req: ReqPage) => {
|
||||||
return http.post<ResPage<WebSite.AcmeAccount>>(`/websites/acme/search`, req);
|
return http.post<ResPage<Website.AcmeAccount>>(`/websites/acme/search`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CreateAcmeAccount = (req: WebSite.AcmeAccountCreate) => {
|
export const CreateAcmeAccount = (req: Website.AcmeAccountCreate) => {
|
||||||
return http.post<WebSite.AcmeAccount>(`/websites/acme`, req);
|
return http.post<Website.AcmeAccount>(`/websites/acme`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DeleteAcmeAccount = (id: number) => {
|
export const DeleteAcmeAccount = (id: number) => {
|
||||||
@ -106,15 +108,15 @@ export const DeleteAcmeAccount = (id: number) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const SearchSSL = (req: ReqPage) => {
|
export const SearchSSL = (req: ReqPage) => {
|
||||||
return http.post<ResPage<WebSite.SSL>>(`/websites/ssl/search`, req);
|
return http.post<ResPage<Website.SSL>>(`/websites/ssl/search`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ListSSL = (req: WebSite.SSLReq) => {
|
export const ListSSL = (req: Website.SSLReq) => {
|
||||||
return http.post<WebSite.SSL[]>(`/websites/ssl/search`, req);
|
return http.post<Website.SSL[]>(`/websites/ssl/search`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CreateSSL = (req: WebSite.SSLCreate) => {
|
export const CreateSSL = (req: Website.SSLCreate) => {
|
||||||
return http.post<WebSite.SSLCreate>(`/websites/ssl`, req);
|
return http.post<Website.SSLCreate>(`/websites/ssl`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DeleteSSL = (id: number) => {
|
export const DeleteSSL = (id: number) => {
|
||||||
@ -122,37 +124,37 @@ export const DeleteSSL = (id: number) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const GetWebsiteSSL = (websiteId: number) => {
|
export const GetWebsiteSSL = (websiteId: number) => {
|
||||||
return http.get<WebSite.SSL>(`/websites/ssl/${websiteId}`);
|
return http.get<Website.SSL>(`/websites/ssl/${websiteId}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ApplySSL = (req: WebSite.SSLApply) => {
|
export const ApplySSL = (req: Website.SSLApply) => {
|
||||||
return http.post<WebSite.SSLApply>(`/websites/ssl/apply`, req);
|
return http.post<Website.SSLApply>(`/websites/ssl/apply`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const RenewSSL = (req: WebSite.SSLRenew) => {
|
export const RenewSSL = (req: Website.SSLRenew) => {
|
||||||
return http.post<any>(`/websites/ssl/renew`, req);
|
return http.post<any>(`/websites/ssl/renew`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const GetDnsResolve = (req: WebSite.DNSResolveReq) => {
|
export const GetDnsResolve = (req: Website.DNSResolveReq) => {
|
||||||
return http.post<WebSite.DNSResolve[]>(`/websites/ssl/resolve`, req);
|
return http.post<Website.DNSResolve[]>(`/websites/ssl/resolve`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const GetHTTPSConfig = (id: number) => {
|
export const GetHTTPSConfig = (id: number) => {
|
||||||
return http.get<WebSite.HTTPSConfig>(`/websites/${id}/https`);
|
return http.get<Website.HTTPSConfig>(`/websites/${id}/https`);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const UpdateHTTPSConfig = (req: WebSite.HTTPSReq) => {
|
export const UpdateHTTPSConfig = (req: Website.HTTPSReq) => {
|
||||||
return http.post<WebSite.HTTPSConfig>(`/websites/${req.websiteId}/https`, req);
|
return http.post<Website.HTTPSConfig>(`/websites/${req.websiteId}/https`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PreCheck = (req: WebSite.CheckReq) => {
|
export const PreCheck = (req: Website.CheckReq) => {
|
||||||
return http.post<WebSite.CheckRes[]>(`/websites/check`, req);
|
return http.post<Website.CheckRes[]>(`/websites/check`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const GetWafConfig = (req: WebSite.WafReq) => {
|
export const GetWafConfig = (req: Website.WafReq) => {
|
||||||
return http.post<WebSite.WafRes>(`/websites/waf/config`, req);
|
return http.post<Website.WafRes>(`/websites/waf/config`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const UpdateWafEnable = (req: WebSite.WafUpdate) => {
|
export const UpdateWafEnable = (req: Website.WafUpdate) => {
|
||||||
return http.post<any>(`/websites/waf/update`, req);
|
return http.post<any>(`/websites/waf/update`, req);
|
||||||
};
|
};
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { WebSite } from '@/api/interface/website';
|
import { Website } from '@/api/interface/website';
|
||||||
import { DeleteAcmeAccount, SearchAcmeAccount } from '@/api/modules/website';
|
import { DeleteAcmeAccount, SearchAcmeAccount } from '@/api/modules/website';
|
||||||
import ComplexTable from '@/components/complex-table/index.vue';
|
import ComplexTable from '@/components/complex-table/index.vue';
|
||||||
import { useDeleteData } from '@/hooks/use-delete-data';
|
import { useDeleteData } from '@/hooks/use-delete-data';
|
||||||
@ -44,7 +44,7 @@ const paginationConfig = reactive({
|
|||||||
const buttons = [
|
const buttons = [
|
||||||
{
|
{
|
||||||
label: i18n.global.t('app.delete'),
|
label: i18n.global.t('app.delete'),
|
||||||
click: function (row: WebSite.AcmeAccount) {
|
click: function (row: Website.AcmeAccount) {
|
||||||
deleteAccount(row.id);
|
deleteAccount(row.id);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -76,7 +76,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { WebSite } from '@/api/interface/website';
|
import { Website } from '@/api/interface/website';
|
||||||
import { CreateSSL, GetDnsResolve, SearchAcmeAccount, SearchDnsAccount } from '@/api/modules/website';
|
import { CreateSSL, GetDnsResolve, SearchAcmeAccount, SearchDnsAccount } from '@/api/modules/website';
|
||||||
import { Rules } from '@/global/form-rules';
|
import { Rules } from '@/global/form-rules';
|
||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
@ -104,9 +104,9 @@ let acmeReq = reactive({
|
|||||||
page: 1,
|
page: 1,
|
||||||
pageSize: 20,
|
pageSize: 20,
|
||||||
});
|
});
|
||||||
let dnsAccounts = ref<WebSite.DnsAccount[]>();
|
let dnsAccounts = ref<Website.DnsAccount[]>();
|
||||||
let acmeAccounts = ref<WebSite.AcmeAccount[]>();
|
let acmeAccounts = ref<Website.AcmeAccount[]>();
|
||||||
// let domains = ref<WebSite.Domain[]>([]);
|
// let domains = ref<Website.Domain[]>([]);
|
||||||
let sslForm = ref<FormInstance>();
|
let sslForm = ref<FormInstance>();
|
||||||
let rules = ref({
|
let rules = ref({
|
||||||
primaryDomain: [Rules.requiredInput],
|
primaryDomain: [Rules.requiredInput],
|
||||||
@ -122,7 +122,7 @@ let ssl = ref({
|
|||||||
acmeAccountId: undefined,
|
acmeAccountId: undefined,
|
||||||
dnsAccountId: undefined,
|
dnsAccountId: undefined,
|
||||||
});
|
});
|
||||||
let dnsResolve = ref<WebSite.DNSResolve[]>([]);
|
let dnsResolve = ref<Website.DNSResolve[]>([]);
|
||||||
let hasResolve = ref(false);
|
let hasResolve = ref(false);
|
||||||
|
|
||||||
const em = defineEmits(['close']);
|
const em = defineEmits(['close']);
|
||||||
@ -168,10 +168,6 @@ const getDnsAccounts = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// const getWebsite = async (id: number) => {
|
|
||||||
// domains.value = (await GetWebsite(id)).data.domains || [];
|
|
||||||
// };
|
|
||||||
|
|
||||||
const getDnsResolve = async (acmeAccountId: number, domains: string[]) => {
|
const getDnsResolve = async (acmeAccountId: number, domains: string[]) => {
|
||||||
hasResolve.value = false;
|
hasResolve.value = false;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import ComplexTable from '@/components/complex-table/index.vue';
|
import ComplexTable from '@/components/complex-table/index.vue';
|
||||||
import Create from './create/index.vue';
|
import Create from './create/index.vue';
|
||||||
import { WebSite } from '@/api/interface/website';
|
import { Website } from '@/api/interface/website';
|
||||||
import { DeleteDnsAccount, SearchDnsAccount } from '@/api/modules/website';
|
import { DeleteDnsAccount, SearchDnsAccount } from '@/api/modules/website';
|
||||||
import { onMounted, reactive, ref } from 'vue';
|
import { onMounted, reactive, ref } from 'vue';
|
||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
@ -47,7 +47,7 @@ const paginationConfig = reactive({
|
|||||||
pageSize: 20,
|
pageSize: 20,
|
||||||
total: 0,
|
total: 0,
|
||||||
});
|
});
|
||||||
let data = ref<WebSite.DnsAccount[]>();
|
let data = ref<Website.DnsAccount[]>();
|
||||||
let createRef = ref();
|
let createRef = ref();
|
||||||
let loading = ref(false);
|
let loading = ref(false);
|
||||||
let open = ref(false);
|
let open = ref(false);
|
||||||
@ -55,7 +55,7 @@ let open = ref(false);
|
|||||||
const buttons = [
|
const buttons = [
|
||||||
{
|
{
|
||||||
label: i18n.global.t('app.delete'),
|
label: i18n.global.t('app.delete'),
|
||||||
click: function (row: WebSite.WebSite) {
|
click: function (row: Website.Website) {
|
||||||
deleteAccount(row.id);
|
deleteAccount(row.id);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -81,7 +81,7 @@ const openCreate = () => {
|
|||||||
createRef.value.acceptParams({ mode: 'add' });
|
createRef.value.acceptParams({ mode: 'add' });
|
||||||
};
|
};
|
||||||
|
|
||||||
const openEdit = (form: WebSite.DnsAccount) => {
|
const openEdit = (form: Website.DnsAccount) => {
|
||||||
createRef.value.acceptParams({ mode: 'edit', form: form });
|
createRef.value.acceptParams({ mode: 'edit', form: form });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ import Renew from './renew/index.vue';
|
|||||||
import Create from './create/index.vue';
|
import Create from './create/index.vue';
|
||||||
import { dateFromat } from '@/utils/util';
|
import { dateFromat } from '@/utils/util';
|
||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
import { WebSite } from '@/api/interface/website';
|
import { Website } from '@/api/interface/website';
|
||||||
import { useDeleteData } from '@/hooks/use-delete-data';
|
import { useDeleteData } from '@/hooks/use-delete-data';
|
||||||
|
|
||||||
const paginationConfig = reactive({
|
const paginationConfig = reactive({
|
||||||
@ -86,13 +86,13 @@ let loading = ref(false);
|
|||||||
const buttons = [
|
const buttons = [
|
||||||
{
|
{
|
||||||
label: i18n.global.t('website.renewSSL'),
|
label: i18n.global.t('website.renewSSL'),
|
||||||
click: function (row: WebSite.WebSite) {
|
click: function (row: Website.Website) {
|
||||||
openRenewSSL(row.id);
|
openRenewSSL(row.id);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: i18n.global.t('app.delete'),
|
label: i18n.global.t('app.delete'),
|
||||||
click: function (row: WebSite.WebSite) {
|
click: function (row: Website.Website) {
|
||||||
deleteSSL(row.id);
|
deleteSSL(row.id);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -29,13 +29,13 @@
|
|||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { WebSite } from '@/api/interface/website';
|
import { Website } from '@/api/interface/website';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
interface InstallRrops {
|
interface InstallRrops {
|
||||||
items: WebSite.CheckRes[];
|
items: Website.CheckRes[];
|
||||||
}
|
}
|
||||||
|
|
||||||
let open = ref(false);
|
let open = ref(false);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { WebSite } from '@/api/interface/website';
|
import { Website } from '@/api/interface/website';
|
||||||
import { GetNginxConfig, UpdateNginxConfig } from '@/api/modules/website';
|
import { GetNginxConfig, UpdateNginxConfig } from '@/api/modules/website';
|
||||||
import { Rules } from '@/global/form-rules';
|
import { Rules } from '@/global/form-rules';
|
||||||
import { ElMessage, FormInstance } from 'element-plus';
|
import { ElMessage, FormInstance } from 'element-plus';
|
||||||
@ -69,7 +69,7 @@ const submit = async (formEl: FormInstance | undefined) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const search = (req: WebSite.NginxConfigReq) => {
|
const search = (req: Website.NginxConfigReq) => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
GetNginxConfig(req)
|
GetNginxConfig(req)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="open"
|
v-model="open"
|
||||||
:destroy-on-close="true"
|
|
||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
:title="$t('website.create')"
|
:title="$t('website.create')"
|
||||||
width="40%"
|
width="40%"
|
||||||
@ -36,7 +35,7 @@ import { ref } from 'vue';
|
|||||||
const domainForm = ref<FormInstance>();
|
const domainForm = ref<FormInstance>();
|
||||||
|
|
||||||
let rules = ref({
|
let rules = ref({
|
||||||
domain: [Rules.requiredInput],
|
domain: [Rules.requiredInput, Rules.domain],
|
||||||
port: [Rules.requiredInput],
|
port: [Rules.requiredInput],
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -50,6 +49,7 @@ let domain = ref({
|
|||||||
|
|
||||||
const em = defineEmits(['close']);
|
const em = defineEmits(['close']);
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
|
domainForm.value?.resetFields();
|
||||||
open.value = false;
|
open.value = false;
|
||||||
em('close', false);
|
em('close', false);
|
||||||
};
|
};
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import ComplexTable from '@/components/complex-table/index.vue';
|
import ComplexTable from '@/components/complex-table/index.vue';
|
||||||
import Domain from './create/index.vue';
|
import Domain from './create/index.vue';
|
||||||
import { WebSite } from '@/api/interface/website';
|
import { Website } from '@/api/interface/website';
|
||||||
import { DeleteDomain, ListDomains } from '@/api/modules/website';
|
import { DeleteDomain, ListDomains } from '@/api/modules/website';
|
||||||
import { computed, onMounted, ref } from 'vue';
|
import { computed, onMounted, ref } from 'vue';
|
||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
@ -29,13 +29,13 @@ const id = computed(() => {
|
|||||||
return props.id;
|
return props.id;
|
||||||
});
|
});
|
||||||
let loading = ref(false);
|
let loading = ref(false);
|
||||||
const data = ref<WebSite.Domain[]>([]);
|
const data = ref<Website.Domain[]>([]);
|
||||||
const domainRef = ref();
|
const domainRef = ref();
|
||||||
|
|
||||||
const buttons = [
|
const buttons = [
|
||||||
{
|
{
|
||||||
label: i18n.global.t('app.delete'),
|
label: i18n.global.t('app.delete'),
|
||||||
click: function (row: WebSite.Domain) {
|
click: function (row: Website.Domain) {
|
||||||
deleteDoamin(row.id);
|
deleteDoamin(row.id);
|
||||||
},
|
},
|
||||||
disabled: () => {
|
disabled: () => {
|
||||||
@ -49,7 +49,7 @@ const openCreate = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const deleteDoamin = async (domainId: number) => {
|
const deleteDoamin = async (domainId: number) => {
|
||||||
await useDeleteData(DeleteDomain, domainId, 'commons.msg.delete');
|
await useDeleteData(DeleteDomain, { id: domainId }, 'commons.msg.delete');
|
||||||
search(id.value);
|
search(id.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { WebSite } from '@/api/interface/website';
|
import { Website } from '@/api/interface/website';
|
||||||
import { GetHTTPSConfig, ListSSL, UpdateHTTPSConfig } from '@/api/modules/website';
|
import { GetHTTPSConfig, ListSSL, UpdateHTTPSConfig } from '@/api/modules/website';
|
||||||
import { ElMessage, FormInstance } from 'element-plus';
|
import { ElMessage, FormInstance } from 'element-plus';
|
||||||
import { computed, onMounted, reactive, ref } from 'vue';
|
import { computed, onMounted, reactive, ref } from 'vue';
|
||||||
@ -104,7 +104,7 @@ const listSSL = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const changeSSl = (sslid: number) => {
|
const changeSSl = (sslid: number) => {
|
||||||
const res = ssls.value.filter((element: WebSite.SSL) => {
|
const res = ssls.value.filter((element: Website.SSL) => {
|
||||||
return element.id == sslid;
|
return element.id == sslid;
|
||||||
});
|
});
|
||||||
websiteSSL.value = res[0];
|
websiteSSL.value = res[0];
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Rules } from '@/global/form-rules';
|
import { Rules } from '@/global/form-rules';
|
||||||
import { WebSite } from '@/api/interface/website';
|
import { Website } from '@/api/interface/website';
|
||||||
import { GetNginxConfig, UpdateNginxConfig } from '@/api/modules/website';
|
import { GetNginxConfig, UpdateNginxConfig } from '@/api/modules/website';
|
||||||
import { ElMessage, FormInstance } from 'element-plus';
|
import { ElMessage, FormInstance } from 'element-plus';
|
||||||
import { computed, onMounted, reactive, ref } from 'vue';
|
import { computed, onMounted, reactive, ref } from 'vue';
|
||||||
@ -60,7 +60,7 @@ let req = reactive({
|
|||||||
let enable = ref(false);
|
let enable = ref(false);
|
||||||
let loading = ref(false);
|
let loading = ref(false);
|
||||||
|
|
||||||
const search = (req: WebSite.NginxConfigReq) => {
|
const search = (req: Website.NginxConfigReq) => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
GetNginxConfig(req)
|
GetNginxConfig(req)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { WebSite } from '@/api/interface/website';
|
import { Website } from '@/api/interface/website';
|
||||||
import { GetWebsite, UpdateWebsite } from '@/api/modules/website';
|
import { GetWebsite, UpdateWebsite } from '@/api/modules/website';
|
||||||
import { Rules } from '@/global/form-rules';
|
import { Rules } from '@/global/form-rules';
|
||||||
import { computed, onMounted, reactive, ref } from 'vue';
|
import { computed, onMounted, reactive, ref } from 'vue';
|
||||||
@ -65,7 +65,7 @@ let rules = ref({
|
|||||||
primaryDomain: [Rules.requiredInput],
|
primaryDomain: [Rules.requiredInput],
|
||||||
webSiteGroupId: [Rules.requiredSelect],
|
webSiteGroupId: [Rules.requiredSelect],
|
||||||
});
|
});
|
||||||
let groups = ref<WebSite.Group[]>([]);
|
let groups = ref<Website.Group[]>([]);
|
||||||
|
|
||||||
const submit = async (formEl: FormInstance | undefined) => {
|
const submit = async (formEl: FormInstance | undefined) => {
|
||||||
if (!formEl) return;
|
if (!formEl) return;
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { WebSite } from '@/api/interface/website';
|
import { Website } from '@/api/interface/website';
|
||||||
import { SaveFileContent } from '@/api/modules/files';
|
import { SaveFileContent } from '@/api/modules/files';
|
||||||
import { GetWafConfig, UpdateWafEnable } from '@/api/modules/website';
|
import { GetWafConfig, UpdateWafEnable } from '@/api/modules/website';
|
||||||
import { Rules } from '@/global/form-rules';
|
import { Rules } from '@/global/form-rules';
|
||||||
@ -57,19 +57,19 @@ const id = computed(() => {
|
|||||||
return props.id;
|
return props.id;
|
||||||
});
|
});
|
||||||
|
|
||||||
let data = ref<WebSite.WafRes>();
|
let data = ref<Website.WafRes>();
|
||||||
let loading = ref(false);
|
let loading = ref(false);
|
||||||
let form = reactive({
|
let form = reactive({
|
||||||
enable: false,
|
enable: false,
|
||||||
cycle: 60,
|
cycle: 60,
|
||||||
frequency: 120,
|
frequency: 120,
|
||||||
});
|
});
|
||||||
let req = ref<WebSite.WafReq>({
|
let req = ref<Website.WafReq>({
|
||||||
websiteId: 0,
|
websiteId: 0,
|
||||||
key: '$CCDeny',
|
key: '$CCDeny',
|
||||||
rule: 'ccrate',
|
rule: 'ccrate',
|
||||||
});
|
});
|
||||||
let enableUpdate = ref<WebSite.WafUpdate>({
|
let enableUpdate = ref<Website.WafUpdate>({
|
||||||
websiteId: 0,
|
websiteId: 0,
|
||||||
key: '$CCDeny',
|
key: '$CCDeny',
|
||||||
enable: false,
|
enable: false,
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { WebSite } from '@/api/interface/website';
|
import { Website } from '@/api/interface/website';
|
||||||
import { GetWafConfig, UpdateWafEnable } from '@/api/modules/website';
|
import { GetWafConfig, UpdateWafEnable } from '@/api/modules/website';
|
||||||
import { computed, onMounted, reactive, ref } from 'vue';
|
import { computed, onMounted, reactive, ref } from 'vue';
|
||||||
import ComplexTable from '@/components/complex-table/index.vue';
|
import ComplexTable from '@/components/complex-table/index.vue';
|
||||||
@ -57,7 +57,7 @@ const id = computed(() => {
|
|||||||
|
|
||||||
let loading = ref(false);
|
let loading = ref(false);
|
||||||
let data = ref([]);
|
let data = ref([]);
|
||||||
let req = ref<WebSite.WafReq>({
|
let req = ref<Website.WafReq>({
|
||||||
websiteId: 0,
|
websiteId: 0,
|
||||||
key: '$fileExtDeny',
|
key: '$fileExtDeny',
|
||||||
rule: 'fileExtBlockList',
|
rule: 'fileExtBlockList',
|
||||||
@ -66,7 +66,7 @@ let fileUpdate = reactive({
|
|||||||
path: '',
|
path: '',
|
||||||
content: '',
|
content: '',
|
||||||
});
|
});
|
||||||
let enableUpdate = ref<WebSite.WafUpdate>({
|
let enableUpdate = ref<Website.WafUpdate>({
|
||||||
websiteId: 0,
|
websiteId: 0,
|
||||||
key: '$fileExtDeny',
|
key: '$fileExtDeny',
|
||||||
enable: false,
|
enable: false,
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { WebSite } from '@/api/interface/website';
|
import { Website } from '@/api/interface/website';
|
||||||
import { GetWafConfig, UpdateWafEnable } from '@/api/modules/website';
|
import { GetWafConfig, UpdateWafEnable } from '@/api/modules/website';
|
||||||
import { computed, onMounted, reactive, ref } from 'vue';
|
import { computed, onMounted, reactive, ref } from 'vue';
|
||||||
import ComplexTable from '@/components/complex-table/index.vue';
|
import ComplexTable from '@/components/complex-table/index.vue';
|
||||||
@ -72,7 +72,7 @@ const key = computed(() => {
|
|||||||
|
|
||||||
let loading = ref(false);
|
let loading = ref(false);
|
||||||
let data = ref([]);
|
let data = ref([]);
|
||||||
let req = ref<WebSite.WafReq>({
|
let req = ref<Website.WafReq>({
|
||||||
websiteId: 0,
|
websiteId: 0,
|
||||||
key: '$ipWhiteAllow',
|
key: '$ipWhiteAllow',
|
||||||
rule: 'ipWhitelist',
|
rule: 'ipWhitelist',
|
||||||
@ -81,7 +81,7 @@ let fileUpdate = reactive({
|
|||||||
path: '',
|
path: '',
|
||||||
content: '',
|
content: '',
|
||||||
});
|
});
|
||||||
let enableUpdate = ref<WebSite.WafUpdate>({
|
let enableUpdate = ref<Website.WafUpdate>({
|
||||||
websiteId: 0,
|
websiteId: 0,
|
||||||
key: '$ipWhiteAllow',
|
key: '$ipWhiteAllow',
|
||||||
enable: false,
|
enable: false,
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { WebSite } from '@/api/interface/website';
|
import { Website } from '@/api/interface/website';
|
||||||
import { GetWafConfig, UpdateWafEnable } from '@/api/modules/website';
|
import { GetWafConfig, UpdateWafEnable } from '@/api/modules/website';
|
||||||
import { computed, onMounted, reactive, ref } from 'vue';
|
import { computed, onMounted, reactive, ref } from 'vue';
|
||||||
import ComplexTable from '@/components/complex-table/index.vue';
|
import ComplexTable from '@/components/complex-table/index.vue';
|
||||||
@ -76,7 +76,7 @@ const key = computed(() => {
|
|||||||
|
|
||||||
let loading = ref(false);
|
let loading = ref(false);
|
||||||
let data = ref([]);
|
let data = ref([]);
|
||||||
let req = ref<WebSite.WafReq>({
|
let req = ref<Website.WafReq>({
|
||||||
websiteId: 0,
|
websiteId: 0,
|
||||||
key: '',
|
key: '',
|
||||||
rule: 'url',
|
rule: 'url',
|
||||||
@ -85,7 +85,7 @@ let fileUpdate = reactive({
|
|||||||
path: '',
|
path: '',
|
||||||
content: '',
|
content: '',
|
||||||
});
|
});
|
||||||
let enableUpdate = ref<WebSite.WafUpdate>({
|
let enableUpdate = ref<Website.WafUpdate>({
|
||||||
websiteId: 0,
|
websiteId: 0,
|
||||||
key: '$UrlDeny',
|
key: '$UrlDeny',
|
||||||
enable: false,
|
enable: false,
|
||||||
|
@ -131,7 +131,7 @@
|
|||||||
|
|
||||||
<script lang="ts" setup name="CreateWebSite">
|
<script lang="ts" setup name="CreateWebSite">
|
||||||
import { App } from '@/api/interface/app';
|
import { App } from '@/api/interface/app';
|
||||||
import { WebSite } from '@/api/interface/website';
|
import { Website } from '@/api/interface/website';
|
||||||
import { GetApp, GetAppDetail, SearchApp, GetAppInstalled } from '@/api/modules/app';
|
import { GetApp, GetAppDetail, SearchApp, GetAppInstalled } from '@/api/modules/app';
|
||||||
import { CreateWebsite, ListGroups, PreCheck } from '@/api/modules/website';
|
import { CreateWebsite, ListGroups, PreCheck } from '@/api/modules/website';
|
||||||
import { Rules } from '@/global/form-rules';
|
import { Rules } from '@/global/form-rules';
|
||||||
@ -177,7 +177,7 @@ let rules = reactive({
|
|||||||
|
|
||||||
let open = ref(false);
|
let open = ref(false);
|
||||||
let loading = ref(false);
|
let loading = ref(false);
|
||||||
let groups = ref<WebSite.Group[]>([]);
|
let groups = ref<Website.Group[]>([]);
|
||||||
let appInstalles = ref<App.AppInstalled[]>([]);
|
let appInstalles = ref<App.AppInstalled[]>([]);
|
||||||
let appReq = reactive({
|
let appReq = reactive({
|
||||||
type: 'website',
|
type: 'website',
|
||||||
|
@ -27,7 +27,7 @@ import { DeleteWebsite } from '@/api/modules/website';
|
|||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage } from 'element-plus';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { WebSite } from '@/api/interface/website';
|
import { Website } from '@/api/interface/website';
|
||||||
|
|
||||||
let key = 1;
|
let key = 1;
|
||||||
let open = ref(false);
|
let open = ref(false);
|
||||||
@ -46,7 +46,7 @@ const handleClose = () => {
|
|||||||
em('close', false);
|
em('close', false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const acceptParams = async (website: WebSite.WebSite) => {
|
const acceptParams = async (website: Website.Website) => {
|
||||||
deleteReq.value = {
|
deleteReq.value = {
|
||||||
id: 0,
|
id: 0,
|
||||||
deleteApp: false,
|
deleteApp: false,
|
||||||
|
@ -86,8 +86,8 @@ import { onMounted, reactive, ref } from '@vue/runtime-core';
|
|||||||
import CreateWebSite from './create/index.vue';
|
import CreateWebSite from './create/index.vue';
|
||||||
import DeleteWebsite from './delete/index.vue';
|
import DeleteWebsite from './delete/index.vue';
|
||||||
import WebSiteGroup from './group/index.vue';
|
import WebSiteGroup from './group/index.vue';
|
||||||
import { SearchWebSites } from '@/api/modules/website';
|
import { SearchWebsites } from '@/api/modules/website';
|
||||||
import { WebSite } from '@/api/interface/website';
|
import { Website } from '@/api/interface/website';
|
||||||
import AppStatus from '@/components/app-status/index.vue';
|
import AppStatus from '@/components/app-status/index.vue';
|
||||||
import NginxConfig from './nginx/index.vue';
|
import NginxConfig from './nginx/index.vue';
|
||||||
import { dateFromat } from '@/utils/util';
|
import { dateFromat } from '@/utils/util';
|
||||||
@ -121,7 +121,7 @@ const search = async () => {
|
|||||||
pageSize: paginationConfig.pageSize,
|
pageSize: paginationConfig.pageSize,
|
||||||
};
|
};
|
||||||
|
|
||||||
SearchWebSites(req).then((res) => {
|
SearchWebsites(req).then((res) => {
|
||||||
data.value = res.data.items;
|
data.value = res.data.items;
|
||||||
paginationConfig.total = res.data.total;
|
paginationConfig.total = res.data.total;
|
||||||
});
|
});
|
||||||
@ -140,13 +140,13 @@ const dialogBackupRef = ref();
|
|||||||
const buttons = [
|
const buttons = [
|
||||||
{
|
{
|
||||||
label: i18n.global.t('website.config'),
|
label: i18n.global.t('website.config'),
|
||||||
click: function (row: WebSite.WebSite) {
|
click: function (row: Website.Website) {
|
||||||
openConfig(row.id);
|
openConfig(row.id);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: i18n.global.t('database.backupList'),
|
label: i18n.global.t('database.backupList'),
|
||||||
click: (row: WebSite.WebSite) => {
|
click: (row: Website.Website) => {
|
||||||
let params = {
|
let params = {
|
||||||
id: row.id,
|
id: row.id,
|
||||||
type: row.type,
|
type: row.type,
|
||||||
@ -157,7 +157,7 @@ const buttons = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: i18n.global.t('database.loadBackup'),
|
label: i18n.global.t('database.loadBackup'),
|
||||||
click: (row: WebSite.WebSite) => {
|
click: (row: Website.Website) => {
|
||||||
let params = {
|
let params = {
|
||||||
websiteName: row.primaryDomain,
|
websiteName: row.primaryDomain,
|
||||||
websiteType: row.type,
|
websiteType: row.type,
|
||||||
@ -167,13 +167,13 @@ const buttons = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: i18n.global.t('app.delete'),
|
label: i18n.global.t('app.delete'),
|
||||||
click: function (row: WebSite.WebSite) {
|
click: function (row: Website.Website) {
|
||||||
openDelete(row);
|
openDelete(row);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const openDelete = (website: WebSite.WebSite) => {
|
const openDelete = (website: Website.Website) => {
|
||||||
deleteRef.value.acceptParams(website);
|
deleteRef.value.acceptParams(website);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user