Browse Source

fix: 解决相同域名和端口可以重复添加的问题 (#2470)

pull/2474/head
zhengkunwang 1 year ago committed by GitHub
parent
commit
7171c13e31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      backend/app/service/website.go

10
backend/app/service/website.go

@ -463,13 +463,15 @@ func (w WebsiteService) CreateWebsiteDomain(create request.WebsiteDomainCreate)
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{}) {
return domainModel, buserr.WithMap(constant.ErrPortInOtherApp, map[string]interface{}{"port": create.Port, "apps": existAppInstall.App.Name}, nil)
}
if common.ScanPort(create.Port) {
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))
@ -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 {
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 {
return domainModel, err
}

Loading…
Cancel
Save