DengBiao pirms 1 gada
vecāks
revīzija
2717fda967
2 mainītis faili ar 14 papildinājumiem un 13 dzēšanām
  1. +3
    -3
      internal/logic/app/group_app.go
  2. +11
    -10
      internal/logic/domain/group/model/group.go

+ 3
- 3
internal/logic/app/group_app.go Parādīt failu

@@ -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)


+ 11
- 10
internal/logic/domain/group/model/group.go Parādīt failu

@@ -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 {


Notiek ielāde…
Atcelt
Saglabāt