weiduxiaoxi
This commit is contained in:
@@ -179,7 +179,16 @@ func CreateMessageGroup(ctx *jxcontext.Context, userID, userID2, groupName strin
|
||||
messageGroupRead2 := messageGroupRead
|
||||
messageGroupRead2.UserID = userID2
|
||||
dao.CreateEntity(db, messageGroupRead)
|
||||
dao.CreateEntity(db, messageGroupRead2)
|
||||
if err = dao.CreateEntity(db, messageGroupRead2); err == nil {
|
||||
if messageGroupReads, err := dao.GetMessageGroupRead(db, userID2, model.SysGroupID); len(messageGroupReads) == 0 && err == nil {
|
||||
messageGroupRead := &model.MessageGroupRead{
|
||||
GroupID: model.SysGroupID,
|
||||
UserID: userID2,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(messageGroupRead, ctx.GetUserName())
|
||||
dao.CreateEntity(db, messageGroupRead)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
userMembers, err := dao.GetUserMember(db, userID, model.MemberTypeNormal)
|
||||
@@ -216,6 +225,16 @@ func CreateMessageGroup(ctx *jxcontext.Context, userID, userID2, groupName strin
|
||||
dao.CreateEntity(db, messageGroupRead)
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
if messageGroupReads, err := dao.GetMessageGroupRead(db, userID, model.SysGroupID); len(messageGroupReads) == 0 && err == nil {
|
||||
messageGroupRead := &model.MessageGroupRead{
|
||||
GroupID: model.SysGroupID,
|
||||
UserID: userID,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(messageGroupRead, ctx.GetUserName())
|
||||
dao.CreateEntity(db, messageGroupRead)
|
||||
}
|
||||
}
|
||||
return messageGroupResult, err
|
||||
}
|
||||
|
||||
@@ -263,6 +282,14 @@ func GetMessageGroupByUser(ctx *jxcontext.Context, userID string) (messageGroupR
|
||||
err = nil
|
||||
return messageGroups, err
|
||||
}
|
||||
//该用户各组的未读消息数
|
||||
var unReadCount int
|
||||
if messageGroupReads, err := dao.GetMessageGroupRead(db, v.UserID, v.GroupID); err == nil && len(messageGroupReads) > 0 {
|
||||
for _, vv := range messageGroupReads {
|
||||
unReadCount += vv.UnReadCount
|
||||
}
|
||||
}
|
||||
v.UnReadMessageCount = unReadCount
|
||||
}
|
||||
return messageGroups, err
|
||||
}
|
||||
@@ -306,7 +333,16 @@ func AddMessageGroup(ctx *jxcontext.Context, groupID int, userID string) (err er
|
||||
UserID: userID,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(messageGroupRead, ctx.GetUserName())
|
||||
dao.CreateEntity(db, messageGroupRead)
|
||||
if err = dao.CreateEntity(db, messageGroupRead); err == nil {
|
||||
if messageGroupReads, err := dao.GetMessageGroupRead(db, userID, model.SysGroupID); len(messageGroupReads) == 0 && err == nil {
|
||||
messageGroupRead := &model.MessageGroupRead{
|
||||
GroupID: model.SysGroupID,
|
||||
UserID: userID,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(messageGroupRead, ctx.GetUserName())
|
||||
dao.CreateEntity(db, messageGroupRead)
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user