mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-03-16 18:54:43 +08:00
fix: 解决相同域名和端口可以重复添加的问题 (#2470)
This commit is contained in:
parent
c0c65598c8
commit
7171c13e31
@ -463,13 +463,15 @@ func (w WebsiteService) CreateWebsiteDomain(create request.WebsiteDomainCreate)
|
|||||||
return domainModel, err
|
return domainModel, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if existDomains, _ := websiteDomainRepo.GetBy(websiteDomainRepo.WithPort(create.Port)); len(existDomains) == 0 {
|
if existDomains, _ := websiteDomainRepo.GetBy(websiteDomainRepo.WithDomain(create.Domain), websiteDomainRepo.WithPort(create.Port)); len(existDomains) == 0 {
|
||||||
if existAppInstall, _ := appInstallRepo.GetFirst(appInstallRepo.WithPort(create.Port)); !reflect.DeepEqual(existAppInstall, model.AppInstall{}) {
|
if existAppInstall, _ := appInstallRepo.GetFirst(appInstallRepo.WithPort(create.Port)); !reflect.DeepEqual(existAppInstall, model.AppInstall{}) {
|
||||||
return domainModel, buserr.WithMap(constant.ErrPortInOtherApp, map[string]interface{}{"port": create.Port, "apps": existAppInstall.App.Name}, nil)
|
return domainModel, buserr.WithMap(constant.ErrPortInOtherApp, map[string]interface{}{"port": create.Port, "apps": existAppInstall.App.Name}, nil)
|
||||||
}
|
}
|
||||||
if common.ScanPort(create.Port) {
|
if common.ScanPort(create.Port) {
|
||||||
return domainModel, buserr.WithDetail(constant.ErrPortInUsed, create.Port, nil)
|
return domainModel, buserr.WithDetail(constant.ErrPortInUsed, create.Port, nil)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return domainModel, buserr.WithDetail(constant.ErrDomainIsExist, create.Domain, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
website, err := websiteRepo.GetFirst(commonRepo.WithByID(create.WebsiteID))
|
website, err := websiteRepo.GetFirst(commonRepo.WithByID(create.WebsiteID))
|
||||||
@ -479,7 +481,11 @@ func (w WebsiteService) CreateWebsiteDomain(create request.WebsiteDomainCreate)
|
|||||||
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)
|
|
||||||
|
if oldDomains, _ := websiteDomainRepo.GetBy(websiteDomainRepo.WithWebsiteId(create.WebsiteID), websiteDomainRepo.WithDomain(create.Domain)); len(oldDomains) == 0 {
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user