feat: add IM admin management
This commit is contained in:
@@ -25,6 +25,7 @@ import (
|
||||
"hotgo/internal/library/hgorm"
|
||||
"hotgo/internal/library/hgorm/handler"
|
||||
"hotgo/internal/library/hgorm/hook"
|
||||
"hotgo/internal/library/imtenant"
|
||||
"hotgo/internal/model/entity"
|
||||
"hotgo/internal/model/input/adminin"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
@@ -467,6 +468,30 @@ func (s *sAdminMember) Edit(ctx context.Context, in *adminin.MemberEditInp) (err
|
||||
return
|
||||
}
|
||||
|
||||
if service.AdminMember().VerifySuperId(ctx, opMemberId) {
|
||||
if in.TenantId > 0 {
|
||||
count, queryErr := imtenant.RegistryDB(ctx).Model(dao.ImTenant.Table()).Safe().Ctx(ctx).
|
||||
Where(dao.ImTenant.Columns().Id, in.TenantId).
|
||||
Where(dao.ImTenant.Columns().State, consts.ImTenantStateActive).
|
||||
Count()
|
||||
if queryErr != nil {
|
||||
return gerror.Wrap(queryErr, "校验IM租户失败")
|
||||
}
|
||||
if count == 0 {
|
||||
return gerror.New("IM租户不存在或未启用")
|
||||
}
|
||||
}
|
||||
} else if deptType := contexts.GetDeptType(ctx); deptType == consts.DeptTypeTenant ||
|
||||
deptType == consts.DeptTypeMerchant || deptType == consts.DeptTypeUser {
|
||||
in.TenantId = contexts.GetTenantId(ctx)
|
||||
if in.TenantId <= 0 {
|
||||
return gerror.New("当前管理员未关联租户")
|
||||
}
|
||||
} else {
|
||||
// 非租户域管理员不能通过浏览器为账号指定租户。
|
||||
in.TenantId = 0
|
||||
}
|
||||
|
||||
cols := dao.AdminMember.Columns()
|
||||
err = s.VerifyUnique(ctx, &adminin.VerifyUniqueInp{
|
||||
Id: in.Id,
|
||||
|
||||
@@ -228,6 +228,7 @@ func (s *sAdminSite) handleLogin(ctx context.Context, mb *entity.AdminMember) (r
|
||||
|
||||
user := &model.Identity{
|
||||
Id: mb.Id,
|
||||
TenantId: mb.TenantId,
|
||||
Pid: mb.Pid,
|
||||
DeptId: dept.Id,
|
||||
DeptType: dept.Type,
|
||||
@@ -319,6 +320,7 @@ func (s *sAdminSite) BindUserContext(ctx context.Context, claims *model.Identity
|
||||
|
||||
user := &model.Identity{
|
||||
Id: mb.Id,
|
||||
TenantId: mb.TenantId,
|
||||
Pid: mb.Pid,
|
||||
DeptId: dept.Id,
|
||||
DeptType: dept.Type,
|
||||
|
||||
Reference in New Issue
Block a user