|
@@ -115,39 +115,37 @@ func UserMsgList(this *message.UserMsgListReq) *message.UserMsgList {
|
|
data := new(message.UserMsgList)
|
|
data := new(message.UserMsgList)
|
|
//获取栏目下的数据
|
|
//获取栏目下的数据
|
|
sData := make(map[string][]*message.Messages)
|
|
sData := make(map[string][]*message.Messages)
|
|
- if this.MobileHome {
|
|
|
|
- if this.SortSize > 0 {
|
|
|
|
- sortData := entity.Mysql.SelectBySql(fmt.Sprintf(`SELECT * FROM (
|
|
|
|
|
|
+ if this.IsColumnNewMsg && this.SortSize > 0 {
|
|
|
|
+ sortData := entity.Mysql.SelectBySql(fmt.Sprintf(`SELECT * FROM (
|
|
SELECT *, ROW_NUMBER() OVER (PARTITION BY msg_type, receive_userid ORDER BY createtime DESC) AS row_num
|
|
SELECT *, ROW_NUMBER() OVER (PARTITION BY msg_type, receive_userid ORDER BY createtime DESC) AS row_num
|
|
FROM message
|
|
FROM message
|
|
WHERE receive_userid = '%s' and isdel = 1 and appid = %s
|
|
WHERE receive_userid = '%s' and isdel = 1 and appid = %s
|
|
) AS message_ranked
|
|
) AS message_ranked
|
|
WHERE row_num <=%d;`, this.UserId, this.Appid, this.SortSize))
|
|
WHERE row_num <=%d;`, this.UserId, this.Appid, this.SortSize))
|
|
- if sortData != nil {
|
|
|
|
- for _, v := range *sortData {
|
|
|
|
- _id := util.Int64All(v["id"])
|
|
|
|
- id := strconv.FormatInt(_id, 10)
|
|
|
|
- var msg = message.Messages{
|
|
|
|
- Id: id,
|
|
|
|
- Appid: common.InterfaceToStr(v["appId"]),
|
|
|
|
- ReceiveUserId: common.InterfaceToStr(v["receive_userid"]),
|
|
|
|
- ReceiveName: common.InterfaceToStr(v["receive_name"]),
|
|
|
|
- SendUserId: common.InterfaceToStr(v["send_userid"]),
|
|
|
|
- SendName: common.InterfaceToStr(v["send_name"]),
|
|
|
|
- Createtime: common.InterfaceToStr(v["createtime"]),
|
|
|
|
- Title: common.InterfaceToStr(v["title"]),
|
|
|
|
- MsgType: int64(util.IntAll(v["msg_type"])),
|
|
|
|
- Link: common.InterfaceToStr(v["link"]),
|
|
|
|
- CiteId: util.Int64All(v["cite_id"]),
|
|
|
|
- Content: common.InterfaceToStr(v["content"]),
|
|
|
|
- IsRead: util.Int64All(v["isRead"]),
|
|
|
|
- MsgLogId: util.Int64All(v["msg_log_id"]),
|
|
|
|
- }
|
|
|
|
- if sData[common.InterfaceToStr(v["msg_type"])] == nil {
|
|
|
|
- sData[common.InterfaceToStr(v["msg_type"])] = []*message.Messages{&msg}
|
|
|
|
- } else {
|
|
|
|
- sData[common.InterfaceToStr(v["msg_type"])] = append(sData[common.InterfaceToStr(v["msg_type"])], &msg)
|
|
|
|
- }
|
|
|
|
|
|
+ if sortData != nil {
|
|
|
|
+ for _, v := range *sortData {
|
|
|
|
+ _id := util.Int64All(v["id"])
|
|
|
|
+ id := strconv.FormatInt(_id, 10)
|
|
|
|
+ var msg = message.Messages{
|
|
|
|
+ Id: id,
|
|
|
|
+ Appid: common.InterfaceToStr(v["appId"]),
|
|
|
|
+ ReceiveUserId: common.InterfaceToStr(v["receive_userid"]),
|
|
|
|
+ ReceiveName: common.InterfaceToStr(v["receive_name"]),
|
|
|
|
+ SendUserId: common.InterfaceToStr(v["send_userid"]),
|
|
|
|
+ SendName: common.InterfaceToStr(v["send_name"]),
|
|
|
|
+ Createtime: common.InterfaceToStr(v["createtime"]),
|
|
|
|
+ Title: common.InterfaceToStr(v["title"]),
|
|
|
|
+ MsgType: int64(util.IntAll(v["msg_type"])),
|
|
|
|
+ Link: common.InterfaceToStr(v["link"]),
|
|
|
|
+ CiteId: util.Int64All(v["cite_id"]),
|
|
|
|
+ Content: common.InterfaceToStr(v["content"]),
|
|
|
|
+ IsRead: util.Int64All(v["isRead"]),
|
|
|
|
+ MsgLogId: util.Int64All(v["msg_log_id"]),
|
|
|
|
+ }
|
|
|
|
+ if sData[common.InterfaceToStr(v["msg_type"])] == nil {
|
|
|
|
+ sData[common.InterfaceToStr(v["msg_type"])] = []*message.Messages{&msg}
|
|
|
|
+ } else {
|
|
|
|
+ sData[common.InterfaceToStr(v["msg_type"])] = append(sData[common.InterfaceToStr(v["msg_type"])], &msg)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -155,28 +153,33 @@ func UserMsgList(this *message.UserMsgListReq) *message.UserMsgList {
|
|
|
|
|
|
//消息栏目下的最新消息
|
|
//消息栏目下的最新消息
|
|
var columnData []*message.AllSortData
|
|
var columnData []*message.AllSortData
|
|
- if this.IsPc || this.MobileHome {
|
|
|
|
|
|
+ if this.IsColumn {
|
|
|
|
+ var msgTypes []string
|
|
|
|
+ columnUnread := make(map[string]int64)
|
|
|
|
+ for _, v := range entity.MessageColumn {
|
|
|
|
+ msgTypes = append(msgTypes, fmt.Sprintf(`"%s"`, common.InterfaceToStr(v["msg_type"])))
|
|
|
|
+ }
|
|
|
|
+ query := entity.Mysql.SelectBySql(fmt.Sprintf("SELECT msg_type,COUNT(CASE WHEN isRead=0 THEN 1 END) as count FROM message where receive_userid=? and isdel=1 and appid=? GROUP BY msg_type ORDER BY FIELD(`msg_type`,%s)", strings.Join(msgTypes, ",")), this.UserId, this.Appid)
|
|
|
|
+ if query != nil && len(*query) > 0 {
|
|
|
|
+ for _, v := range *query {
|
|
|
|
+ columnUnread[common.InterfaceToStr(v["msg_type"])] = common.Int64All(v["count"])
|
|
|
|
+ }
|
|
|
|
+ }
|
|
for _, v := range entity.MessageColumn {
|
|
for _, v := range entity.MessageColumn {
|
|
var column message.AllSortData
|
|
var column message.AllSortData
|
|
column.Name = common.InterfaceToStr(v["name"])
|
|
column.Name = common.InterfaceToStr(v["name"])
|
|
column.Img = common.InterfaceToStr(v["img"])
|
|
column.Img = common.InterfaceToStr(v["img"])
|
|
column.MsgType = common.Int64All(v["msg_type"])
|
|
column.MsgType = common.Int64All(v["msg_type"])
|
|
|
|
+ msgType := common.InterfaceToStr(v["msg_type"])
|
|
//消息未读数
|
|
//消息未读数
|
|
- sQuery := map[string]interface{}{
|
|
|
|
- "receive_userid": this.UserId,
|
|
|
|
- "isdel": 1,
|
|
|
|
- "appid": this.Appid,
|
|
|
|
- "msg_type": column.MsgType,
|
|
|
|
- "isRead": 0,
|
|
|
|
- }
|
|
|
|
- column.UnreadMessages = entity.Mysql.Count("message", sQuery)
|
|
|
|
|
|
+ column.UnreadMessages = columnUnread[msgType]
|
|
unread += column.UnreadMessages
|
|
unread += column.UnreadMessages
|
|
- column.Data = sData[common.InterfaceToStr(v["msg_type"])]
|
|
|
|
|
|
+ column.Data = sData[msgType]
|
|
columnData = append(columnData, &column)
|
|
columnData = append(columnData, &column)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if this.IsPc || !this.MobileHome {
|
|
|
|
|
|
+ if this.IsMsgList {
|
|
data.SortData = columnData
|
|
data.SortData = columnData
|
|
count = entity.Mysql.Count("message", cquery)
|
|
count = entity.Mysql.Count("message", cquery)
|
|
if count > 0 {
|
|
if count > 0 {
|
|
@@ -204,10 +207,12 @@ func UserMsgList(this *message.UserMsgListReq) *message.UserMsgList {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- data.Count = count
|
|
|
|
- data.Unread = unread
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ data.Count = count
|
|
|
|
+ if !this.IsColumn && this.Read == 0 {
|
|
|
|
+ unread = count
|
|
|
|
+ }
|
|
|
|
+ data.Unread = unread
|
|
return data
|
|
return data
|
|
}
|
|
}
|
|
|
|
|
|
@@ -260,7 +265,7 @@ func UserUnreadMsgList(this *message.UserUnreadMsgListReq) (int64, []*message.Me
|
|
}
|
|
}
|
|
|
|
|
|
func MessageGetLast(this *message.UserMsgListReq) *message.Messages {
|
|
func MessageGetLast(this *message.UserMsgListReq) *message.Messages {
|
|
- if this.IsPc || this.MobileHome {
|
|
|
|
|
|
+ if this.IsColumn {
|
|
query := map[string]interface{}{
|
|
query := map[string]interface{}{
|
|
"receive_userid": this.UserId,
|
|
"receive_userid": this.UserId,
|
|
"isdel": 1,
|
|
"isdel": 1,
|