|
@@ -75,17 +75,16 @@ func (service *MessageService) CountUnread(userId string, appId string) (int64,
|
|
|
|
|
|
// 获取指定用户指定分类最新一条消息
|
|
|
func (service *MessageService) LastMessage(userId string, appId string, msgType int64, isRead int64) (*message.Messages, error) {
|
|
|
- sql := "SELECT * FROM message receive_userid=? and isdel=1 and appid=? and msg_type=?"
|
|
|
- valueList := []interface{}{userId, appId, msgType}
|
|
|
- if isRead != -1 {
|
|
|
- sql = sql + " and isRead=?"
|
|
|
- valueList = append(valueList, isRead)
|
|
|
- }
|
|
|
query := map[string]interface{}{
|
|
|
"receive_userid": userId,
|
|
|
"isdel": 1,
|
|
|
"appid": appId,
|
|
|
- "msg_type": msgType,
|
|
|
+ }
|
|
|
+ if isRead != -1 {
|
|
|
+ query["isRead"] = isRead
|
|
|
+ }
|
|
|
+ if msgType != -1 {
|
|
|
+ query["msg_type"] = msgType
|
|
|
}
|
|
|
lastMsg := entity.Mysql.FindOne("message", query, "", "createtime desc")
|
|
|
if lastMsg != nil && len(*lastMsg) > 0 {
|