diff --git a/backend/app/service/website_group.go b/backend/app/service/website_group.go index b49aa37c0..ba1143717 100644 --- a/backend/app/service/website_group.go +++ b/backend/app/service/website_group.go @@ -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)) } diff --git a/backend/constant/errs.go b/backend/constant/errs.go index e4a0803fc..91547bbe9 100644 --- a/backend/constant/errs.go +++ b/backend/constant/errs.go @@ -64,6 +64,7 @@ var ( ErrDomainIsExist = "ErrDomainIsExist" ErrAliasIsExist = "ErrAliasIsExist" ErrAppDelete = "ErrAppDelete" + ErrGroupIsUsed = "ErrGroupIsUsed" ) //ssl diff --git a/backend/i18n/lang/en.yaml b/backend/i18n/lang/en.yaml index e730d53a4..67aa865f9 100644 --- a/backend/i18n/lang/en.yaml +++ b/backend/i18n/lang/en.yaml @@ -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" diff --git a/backend/i18n/lang/zh.yaml b/backend/i18n/lang/zh.yaml index f48994cab..e4c51cd4b 100644 --- a/backend/i18n/lang/zh.yaml +++ b/backend/i18n/lang/zh.yaml @@ -32,7 +32,8 @@ ErrPathNotFound: "目录不存在" #website ErrDomainIsExist: "域名已存在" ErrAliasIsExist: "代号已存在" -ErrAppDelete: '其他网站使用此应用,不能删除' +ErrAppDelete: '其他网站使用此应用,无法删除' +ErrGroupIsUsed: '分组已经关联网站,无法删除' #ssl ErrSSLCannotDelete: "证书正在被网站使用,无法删除"