Browse Source

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

pull/184/head
zhengkunwang223 2 years ago committed by ssongliu
parent
commit
11b40b8cf9
  1. 4
      backend/app/service/website_group.go
  2. 1
      backend/constant/errs.go
  3. 1
      backend/i18n/lang/en.yaml
  4. 3
      backend/i18n/lang/zh.yaml

4
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 { 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)) return websiteGroupRepo.DeleteBy(commonRepo.WithByID(id))
} }

1
backend/constant/errs.go

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

1
backend/i18n/lang/en.yaml

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

3
backend/i18n/lang/zh.yaml

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

Loading…
Cancel
Save