fix: 解决已经关联网站的分组删除没有校验的BUG

This commit is contained in:
zhengkunwang223 2023-03-02 14:33:38 +08:00 committed by ssongliu
parent 6209472fb2
commit 11b40b8cf9
4 changed files with 8 additions and 1 deletions

View File

@ -53,5 +53,9 @@ func (w WebsiteGroupService) UpdateGroup(update request.WebsiteGroupUpdate) erro
}
func (w WebsiteGroupService) DeleteGroup(id uint) error {
websites, _ := websiteRepo.GetBy(websiteRepo.WithGroupID(id))
if len(websites) > 0 {
return buserr.New(constant.ErrGroupIsUsed)
}
return websiteGroupRepo.DeleteBy(commonRepo.WithByID(id))
}

View File

@ -64,6 +64,7 @@ var (
ErrDomainIsExist = "ErrDomainIsExist"
ErrAliasIsExist = "ErrAliasIsExist"
ErrAppDelete = "ErrAppDelete"
ErrGroupIsUsed = "ErrGroupIsUsed"
)
//ssl

View File

@ -33,6 +33,7 @@ ErrPathNotFound: "Path is not found"
ErrDomainIsExist: "Domain is already exist"
ErrAliasIsExist: "Alias is already exist"
ErrAppDelete: 'Other Website use this App'
ErrGroupIsUsed: 'The group has been associated with a website and cannot be deleted'
#ssl
ErrSSLCannotDelete: "The certificate is being used by the website and cannot be removed"

View File

@ -32,7 +32,8 @@ ErrPathNotFound: "目录不存在"
#website
ErrDomainIsExist: "域名已存在"
ErrAliasIsExist: "代号已存在"
ErrAppDelete: '其他网站使用此应用,不能删除'
ErrAppDelete: '其他网站使用此应用,无法删除'
ErrGroupIsUsed: '分组已经关联网站,无法删除'
#ssl
ErrSSLCannotDelete: "证书正在被网站使用,无法删除"