From 2717fda96716b8f3b2e7e2d0e0aa9379ce39f52b Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Thu, 6 Apr 2023 14:41:58 +0800 Subject: [PATCH] update --- internal/logic/app/group_app.go | 6 +++--- internal/logic/domain/group/model/group.go | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/internal/logic/app/group_app.go b/internal/logic/app/group_app.go index 27d8509..a71158f 100644 --- a/internal/logic/app/group_app.go +++ b/internal/logic/app/group_app.go @@ -2,6 +2,7 @@ package app import ( "context" + "database/sql" "errors" "gim/internal/logic/domain/group/model" "gim/internal/logic/domain/group/repo" @@ -206,9 +207,8 @@ func (*groupApp) SetGroupMemberBanned(ctx context.Context, optId, groupId int64, } //2、更新 `group_user` 的 status 状态 - db.DB.Model(model.GroupUser{}).Where("user_id in (?) and group_id = ?", userIds, groupId).Updates(model.GroupUser{Status: int(pb.GroupUserStatusType_GROUP_USER_STATUS_Banned)}) - db.DB.Model(model.GroupUser{}).Where("(user_id) not in (?) and group_id = ?", userIds, groupId).Updates(model.GroupUser{Status: int(pb.GroupUserStatusType_GROUP_USER_STATUS_NORMAL)}) - + db.DB.Model(model.GroupUser{}).Where("user_id in (?) and group_id = ?", userIds, groupId).Updates(model.GroupUser{Status: sql.NullInt32{Int32: int32(pb.GroupUserStatusType_GROUP_USER_STATUS_Banned), Valid: true}}) + db.DB.Model(model.GroupUser{}).Where("(user_id) not in (?) and group_id = ?", userIds, groupId).Updates(model.GroupUser{Status: sql.NullInt32{Int32: int32(pb.GroupUserStatusType_GROUP_USER_STATUS_NORMAL), Valid: true}}) //3、发送推送消息 for _, u := range userIds { err = group.PushGroupMemberBanned(ctx, optId, u, isAllMemberBanned) diff --git a/internal/logic/domain/group/model/group.go b/internal/logic/domain/group/model/group.go index 3dd68b4..55d7fb7 100644 --- a/internal/logic/domain/group/model/group.go +++ b/internal/logic/domain/group/model/group.go @@ -2,6 +2,7 @@ package model import ( "context" + "database/sql" "fmt" "gim/internal/logic/domain/message/repo" "gim/internal/logic/proxy" @@ -37,16 +38,16 @@ type Group struct { } type GroupUser struct { - Id int64 // 自增主键 - GroupId int64 // 群组id - UserId int64 // 用户id - MemberType int // 群组类型 - Remarks string // 备注 - Extra string // 附加属性 - Status int // 状态 - CreateTime time.Time // 创建时间 - UpdateTime time.Time // 更新时间 - UpdateType int `gorm:"-"` // 更新类型 + Id int64 // 自增主键 + GroupId int64 // 群组id + UserId int64 // 用户id + MemberType int // 群组类型 + Remarks string // 备注 + Extra string // 附加属性 + Status sql.NullInt32 // 状态 + CreateTime time.Time // 创建时间 + UpdateTime time.Time // 更新时间 + UpdateType int `gorm:"-"` // 更新类型 } func (g *Group) ToProto() *pb.Group {