From 11b40b8cf9a2e60a4c269ce12c7c7011f9c07538 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 Date: Thu, 2 Mar 2023 14:33:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=B7=B2=E7=BB=8F?= =?UTF-8?q?=E5=85=B3=E8=81=94=E7=BD=91=E7=AB=99=E7=9A=84=E5=88=86=E7=BB=84?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=B2=A1=E6=9C=89=E6=A0=A1=E9=AA=8C=E7=9A=84?= =?UTF-8?q?BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/website_group.go | 4 ++++ backend/constant/errs.go | 1 + backend/i18n/lang/en.yaml | 1 + backend/i18n/lang/zh.yaml | 3 ++- 4 files changed, 8 insertions(+), 1 deletion(-) 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: "证书正在被网站使用,无法删除"