|
@@ -128,7 +128,8 @@ func (service *MessageService) ClassCountAndMessage(userId string, appId string)
|
|
|
log.Println("123")
|
|
|
defer orm.Close()
|
|
|
//m := []*message.Messages{}
|
|
|
- query, err := orm.QueryInterface("SELECT msg_type,COUNT(CASE WHEN isRead=0 THEN 1 END) as count FROM message receive_userid=? and isdel=1 and appid=? and isRead=0 GROUP BY msg_type ORDER BY FIELD(`msg_type`,\"1\",\"2\",\"3\")", userId, appId)
|
|
|
+ query, err := orm.QueryInterface("SELECT msg_type,COUNT(CASE WHEN isRead=0 THEN 1 END) as count FROM message where receive_userid=? and isdel=1 and appid=? and isRead=0 GROUP BY msg_type ORDER BY FIELD(`msg_type`,\"1\",\"2\",\"3\")", userId, appId)
|
|
|
+ log.Println(query)
|
|
|
if err != nil {
|
|
|
return nil, nil, err
|
|
|
}
|
|
@@ -138,6 +139,7 @@ func (service *MessageService) ClassCountAndMessage(userId string, appId string)
|
|
|
return nil, nil, errors.New("查询未读消息失败")
|
|
|
}
|
|
|
typeCount := []*message.ResCount{}
|
|
|
+ log.Println(query)
|
|
|
// 未读消息分类及数量
|
|
|
if query != nil && len(query) > 0 {
|
|
|
for _, v := range query {
|
|
@@ -152,6 +154,7 @@ func (service *MessageService) ClassCountAndMessage(userId string, appId string)
|
|
|
// 分类下最新一条消息 先查出来所有所有的 然后再取出来最新的一条
|
|
|
err = orm.Select("*").Where("receive_userid=? and isdel=1 and appid=? ", userId, appId).OrderBy("createtime desc").Find(&m1)
|
|
|
if err != nil {
|
|
|
+ log.Println(err,9999999)
|
|
|
return typeCount, m2, errors.New("获取类型下最新消息失败")
|
|
|
}
|
|
|
if m1 != nil && (len(m1) > 0) {
|
|
@@ -176,6 +179,7 @@ func (service *MessageService) ClassCountAndMessage(userId string, appId string)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ log.Println("78945566",typeCount,m2)
|
|
|
return typeCount, m2, nil
|
|
|
}
|
|
|
|