From 9324d8911cb6ffe901c3c2abc190479c08d15b3b Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Thu, 6 Apr 2023 15:09:40 +0800 Subject: [PATCH] update --- internal/logic/app/group_app.go | 6 +++--- internal/logic/domain/group/model/group.go | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/internal/logic/app/group_app.go b/internal/logic/app/group_app.go index e967d7a..4547fee 100644 --- a/internal/logic/app/group_app.go +++ b/internal/logic/app/group_app.go @@ -208,10 +208,10 @@ func (*groupApp) SetGroupMemberBanned(ctx context.Context, optId, groupId int64, //2、更新 `group_user` 的 status 状态 if len(userIds) == 0 { - db.DB.Model(model.GroupUser{}).Where("group_id = ?", groupId).Updates(model.GroupUser{Status: sql.NullInt32{Int32: int32(pb.GroupUserStatusType_GROUP_USER_STATUS_NORMAL), Valid: true}}) + db.DB.Model(model.GroupUser{}).Where("group_id = ?", groupId).Updates(model.GroupUserV2{Status: sql.NullInt32{Int32: int32(pb.GroupUserStatusType_GROUP_USER_STATUS_NORMAL), Valid: true}}) } else { - 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}}) + db.DB.Model(model.GroupUser{}).Where("user_id in (?) and group_id = ?", userIds, groupId).Updates(model.GroupUserV2{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.GroupUserV2{Status: sql.NullInt32{Int32: int32(pb.GroupUserStatusType_GROUP_USER_STATUS_NORMAL), Valid: true}}) } //3、发送推送消息 diff --git a/internal/logic/domain/group/model/group.go b/internal/logic/domain/group/model/group.go index 55d7fb7..7c21c71 100644 --- a/internal/logic/domain/group/model/group.go +++ b/internal/logic/domain/group/model/group.go @@ -38,6 +38,19 @@ 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:"-"` // 更新类型 +} + +type GroupUserV2 struct { Id int64 // 自增主键 GroupId int64 // 群组id UserId int64 // 用户id