sys messaged
This commit is contained in:
@@ -212,7 +212,9 @@ func GetMessageGroupByUser(ctx *jxcontext.Context, userID string) (messageGroupR
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
messageGroups, err := dao.GetMessageGroups(db, userID, 0, 0, true, "")
|
||||
messageGroups, err := dao.GetMessageGroups(db, "", model.SysGroupID, 0, false, "")
|
||||
messageGroups2, err := dao.GetMessageGroups(db, userID, 0, 0, true, "")
|
||||
messageGroups = append(messageGroups, messageGroups2...)
|
||||
messageGroupMembers, err := dao.GetMessageGroupMembers(db, 0, 0, userID)
|
||||
for _, v := range messageGroupMembers {
|
||||
if messageGroupList, err := dao.GetMessageGroups(db, "", v.GroupID, 0, false, ""); err == nil {
|
||||
@@ -374,3 +376,23 @@ func DeleteMessageGroup(ctx *jxcontext.Context, groupID int, userID string) (err
|
||||
}
|
||||
return errCode, err
|
||||
}
|
||||
|
||||
func SendSysMessage(ctx *jxcontext.Context, imMessageRecord *model.ImMessageRecord) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
userID = imMessageRecord.UserID
|
||||
)
|
||||
if userID == "" {
|
||||
return fmt.Errorf("系统用户不存在!")
|
||||
}
|
||||
user, err := dao.GetUserByID(db, "user_id", userID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if user.Type != model.UserTypeBoss {
|
||||
return fmt.Errorf("抱歉只有系统管理员才能发系统消息!")
|
||||
}
|
||||
dao.WrapAddIDCULDEntity(imMessageRecord, ctx.GetUserName())
|
||||
err = dao.CreateEntity(db, imMessageRecord)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user