refactor: The business group must retain at least one team
This commit is contained in:
parent
cc380c85b9
commit
b108c9f11a
|
@ -1,6 +1,7 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
@ -173,7 +174,17 @@ func (bg *BusiGroup) AddMembers(members []BusiGroupMember, username string) erro
|
||||||
|
|
||||||
func (bg *BusiGroup) DelMembers(members []BusiGroupMember, username string) error {
|
func (bg *BusiGroup) DelMembers(members []BusiGroupMember, username string) error {
|
||||||
for i := 0; i < len(members); i++ {
|
for i := 0; i < len(members); i++ {
|
||||||
err := BusiGroupMemberDel("busi_group_id = ? and user_group_id = ?", members[i].BusiGroupId, members[i].UserGroupId)
|
num, err := BusiGroupMemberCount("busi_group_id = ? and user_group_id <> ?", members[i].BusiGroupId, members[i].UserGroupId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if num == 0 {
|
||||||
|
// 说明这是最后一个user-group,如果再删了,就没人可以管理这个busi-group了
|
||||||
|
return fmt.Errorf("The business group must retain at least one team")
|
||||||
|
}
|
||||||
|
|
||||||
|
err = BusiGroupMemberDel("busi_group_id = ? and user_group_id = ?", members[i].BusiGroupId, members[i].UserGroupId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ var (
|
||||||
"No permission. Only admins can assign BG": "没有权限!只有管理员才能分配业务组",
|
"No permission. Only admins can assign BG": "没有权限!只有管理员才能分配业务组",
|
||||||
"No permission to operate the targets: %s": "没有权限操作这些监控对象:%s",
|
"No permission to operate the targets: %s": "没有权限操作这些监控对象:%s",
|
||||||
"No permission. You are not admin of BG(%s)": "没有权限操作,您并非业务组(%s)的管理员",
|
"No permission. You are not admin of BG(%s)": "没有权限操作,您并非业务组(%s)的管理员",
|
||||||
|
"The business group must retain at least one team": "业务组下要保留至少一个团队",
|
||||||
}
|
}
|
||||||
langDict = map[string]map[string]string{
|
langDict = map[string]map[string]string{
|
||||||
"zh": dict,
|
"zh": dict,
|
||||||
|
|
Loading…
Reference in New Issue