diff --git a/src/models/busi_group.go b/src/models/busi_group.go index 677512c7..f3cf22d3 100644 --- a/src/models/busi_group.go +++ b/src/models/busi_group.go @@ -1,6 +1,7 @@ package models import ( + "fmt" "time" "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 { 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 { return err } diff --git a/src/webapi/config/i18n.go b/src/webapi/config/i18n.go index 7f49d303..437e3f06 100644 --- a/src/webapi/config/i18n.go +++ b/src/webapi/config/i18n.go @@ -2,43 +2,44 @@ package config var ( dict = map[string]string{ - "just a test": "这只是一个测试", - "just a test: %s": "这只是一个测试: %s", - "InternalServerError": "系统内部错误,请联系管理员", - "Username or password invalid": "登录失败,请检查用户名和密码", - "Username is blank": "用户名不能为空", - "Username has invalid characters": "用户名含有非法字符", - "Nickname has invalid characters": "昵称含有非法字符", - "Phone invalid": "手机号格式非法", - "Email invalid": "邮箱格式非法", - "Incorrect old password": "旧密码错误", - "Username already exists": "用户名已存在", - "No such user": "用户不存在", - "Note has invalid characters": "备注含有非法字符", - "UserGroup already exists": "用户组已存在,不能重复创建", - "No such UserGroup": "用户组不存在", - "No such BusiGroup": "业务组不存在", - "BusiGroup already exists": "业务分组已存在,不能重复创建", - "Some UserGroup id not exists": "有些用户组ID不存在", - "Some alert mutes still in the BusiGroup": "业务组下仍然存在告警屏蔽配置,不能删除", - "Some dashboards still in the BusiGroup": "业务组下仍然存在监控大盘配置,不能删除", - "Some collect rules still in the BusiGroup": "业务组下仍然存在采集规则配置,不能删除", - "Some alert rules still in the BusiGroup": "业务组下仍然存在告警规则配置,不能删除", - "Some alert subscribes still in the BusiGroup": "业务组下仍然存在订阅规则配置,不能删除", - "Some targets still in the BusiGroup": "业务组下仍然存在监控对象,不能删除", - "Some recovery scripts still in the BusiGroup": "业务组下仍然存在自愈脚本,不能删除", - "Name is blank": "名称不能为空", - "Name has invalid characters": "名称含有非法字符", - "Dashboard already exists": "监控大盘已存在", - "No such dashboard": "监控大盘不存在", - "AlertRule already exists": "告警规则已存在,不能重复创建", - "No such AlertRule": "告警规则不存在", - "CollectRule already exists": "采集规则已存在,不能重复创建", - "No such metric description": "该指标释义不存在,可能已被删除", - "No such TargetQuery": "查询条件不存在,可能已被删除", - "No permission. Only admins can assign BG": "没有权限!只有管理员才能分配业务组", - "No permission to operate the targets: %s": "没有权限操作这些监控对象:%s", - "No permission. You are not admin of BG(%s)": "没有权限操作,您并非业务组(%s)的管理员", + "just a test": "这只是一个测试", + "just a test: %s": "这只是一个测试: %s", + "InternalServerError": "系统内部错误,请联系管理员", + "Username or password invalid": "登录失败,请检查用户名和密码", + "Username is blank": "用户名不能为空", + "Username has invalid characters": "用户名含有非法字符", + "Nickname has invalid characters": "昵称含有非法字符", + "Phone invalid": "手机号格式非法", + "Email invalid": "邮箱格式非法", + "Incorrect old password": "旧密码错误", + "Username already exists": "用户名已存在", + "No such user": "用户不存在", + "Note has invalid characters": "备注含有非法字符", + "UserGroup already exists": "用户组已存在,不能重复创建", + "No such UserGroup": "用户组不存在", + "No such BusiGroup": "业务组不存在", + "BusiGroup already exists": "业务分组已存在,不能重复创建", + "Some UserGroup id not exists": "有些用户组ID不存在", + "Some alert mutes still in the BusiGroup": "业务组下仍然存在告警屏蔽配置,不能删除", + "Some dashboards still in the BusiGroup": "业务组下仍然存在监控大盘配置,不能删除", + "Some collect rules still in the BusiGroup": "业务组下仍然存在采集规则配置,不能删除", + "Some alert rules still in the BusiGroup": "业务组下仍然存在告警规则配置,不能删除", + "Some alert subscribes still in the BusiGroup": "业务组下仍然存在订阅规则配置,不能删除", + "Some targets still in the BusiGroup": "业务组下仍然存在监控对象,不能删除", + "Some recovery scripts still in the BusiGroup": "业务组下仍然存在自愈脚本,不能删除", + "Name is blank": "名称不能为空", + "Name has invalid characters": "名称含有非法字符", + "Dashboard already exists": "监控大盘已存在", + "No such dashboard": "监控大盘不存在", + "AlertRule already exists": "告警规则已存在,不能重复创建", + "No such AlertRule": "告警规则不存在", + "CollectRule already exists": "采集规则已存在,不能重复创建", + "No such metric description": "该指标释义不存在,可能已被删除", + "No such TargetQuery": "查询条件不存在,可能已被删除", + "No permission. Only admins can assign BG": "没有权限!只有管理员才能分配业务组", + "No permission to operate the targets: %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{ "zh": dict,