Explorar el Código

工作桌面商机情报列表、我得未读消息

renjiaojiao hace 1 año
padre
commit
98457bcbce
Se han modificado 1 ficheros con 33 adiciones y 27 borrados
  1. 33 27
      rpc/internal/common/msglistService.go

+ 33 - 27
rpc/internal/common/msglistService.go

@@ -126,23 +126,25 @@ func BitmapUserMsgList(this *message.UserMsgListReq) (*message.UserMsgList, *mes
 		sortUnread, total := BitmapCountUnread(this.UserId, classUnreadCountMap, false)
 		//fmt.Println("*************", total)
 		unread += total
-		for _, v := range entity.MessageColumn {
-			var column message.AllSortData
-			column.Name = common.InterfaceToStr(v["name"])
-			column.Img = fmt.Sprintf("/common-module/msgCenter/%s.png", common.InterfaceToStr(v["img"]))
-			column.MsgType = common.Int64All(v["group_id"])
-			if column.Name == "私信" {
-				column.UnreadMessages = unreadMsg(this)
-			} else if common.IntAll(v["group_id"]) > 0 {
-				//消息未读数
-				msgType := common.InterfaceToStr(v["group_id"])
-				column.UnreadMessages = sortUnread[msgType]
-				column.Data = sData[msgType]
-			}
-			if _, ok := entity.ClassSearchMap[column.MsgType]; ok {
-				column.IsClassSearch = true
+		if this.IsColumn {
+			for _, v := range entity.MessageColumn {
+				var column message.AllSortData
+				column.Name = common.InterfaceToStr(v["name"])
+				column.Img = fmt.Sprintf("/common-module/msgCenter/%s.png", common.InterfaceToStr(v["img"]))
+				column.MsgType = common.Int64All(v["group_id"])
+				if column.Name == "私信" {
+					column.UnreadMessages = unreadMsg(this)
+				} else if common.IntAll(v["group_id"]) > 0 {
+					//消息未读数
+					msgType := common.InterfaceToStr(v["group_id"])
+					column.UnreadMessages = sortUnread[msgType]
+					column.Data = sData[msgType]
+				}
+				if _, ok := entity.ClassSearchMap[column.MsgType]; ok {
+					column.IsClassSearch = true
+				}
+				columnData = append(columnData, &column)
 			}
-			columnData = append(columnData, &column)
 		}
 	}
 	data.SortData = columnData
@@ -432,11 +434,7 @@ func FindUserClassMsg(userId string) (map[int]int, map[int][]int) {
 func GetUserMsgSummary(userId string, isfilterActive bool) (userAllMsg, userReadMsg, userUnreadMsg []uint32, err error) {
 	var count uint64
 	sqlc := ""
-	if isfilterActive {
-		sqlc = fmt.Sprintf("select a2.group_id,bitmapToArray(bitmapAndnot(a1.unreadMsg,a2.msg_bitmap)) as msgArr from (SELECT bitmapAndnot(mus.allMsg,mus.readMsg) as unreadMsg FROM messageCenter.message_user_summary mus WHERE mus.userId = '%s') a1,(select msg_bitmap,group_id from messageCenter.message_summary ms  where group_id = 1 ) a2", userId)
-	} else {
-		sqlc = fmt.Sprintf("SELECT COUNT(*) as count from message_user_summary WHERE userId = '%s'", userId)
-	}
+	sqlc = fmt.Sprintf("SELECT COUNT(*) as count from message_user_summary WHERE userId = '%s'", userId)
 	log.Println("GetUserMsgSummary selcet ", sqlc)
 	row1 := entity.ClickhouseConn.QueryRow(context.Background(), sqlc)
 	err = row1.Scan(&count)
@@ -444,7 +442,13 @@ func GetUserMsgSummary(userId string, isfilterActive bool) (userAllMsg, userRead
 		err = errors.New("用户暂无数据")
 		return
 	}
-	sql := fmt.Sprintf("SELECT bitmapToArray(allMsg) as userAllMsg,bitmapToArray(readMsg) as userReadMsg,bitmapToArray(bitmapAndnot(allMsg,readMsg)) as userunRead from message_user_summary where userId ='%s'", userId)
+	var sql string
+	if isfilterActive {
+		sql = fmt.Sprintf("SELECT a1.userAllMsg,a1.userReadMsg,bitmapToArray(bitmapAndnot(a1.userunRead,a2.msg_bitmap)) as userunRead from (SELECT bitmapToArray(allMsg) as userAllMsg,bitmapToArray(readMsg) as userReadMsg,bitmapAndnot(allMsg,readMsg) as userunRead from message_user_summary where userId ='%s') a1,(select msg_bitmap,group_id from message_summary ms  where group_id = 1 ) a2", userId)
+	} else {
+		sql = fmt.Sprintf("SELECT bitmapToArray(allMsg) as userAllMsg,bitmapToArray(readMsg) as userReadMsg,bitmapToArray(bitmapAndnot(allMsg,readMsg)) as userunRead from message_user_summary where userId ='%s'", userId)
+	}
+	//sql := fmt.Sprintf("SELECT bitmapToArray(allMsg) as userAllMsg,bitmapToArray(readMsg) as userReadMsg,bitmapToArray(bitmapAndnot(allMsg,readMsg)) as userunRead from message_user_summary where userId ='%s'", userId)
 	log.Println("GetUserMsgSummary selcet2 ", sql)
 	row := entity.ClickhouseConn.QueryRow(context.Background(), sql)
 	err = row.Scan(&userAllMsg, &userReadMsg, &userUnreadMsg)
@@ -510,7 +514,7 @@ func WorkDeskList(in *message.WorkingDesktopReq) (res1, res2 []*message.Messages
 			return nil, nil, err
 		}
 		if group.GroupId == int32(in.MsgType) {
-			res1 = GetMsgList(Uint32ArrToIntArr(group.UnreadArr), int(in.PageSize), in.UserId)
+			res1 = GetMsgList(IntArrSort(Uint32ArrToIntArr(group.UnreadArr)), int(in.PageSize), in.UserId)
 		} else {
 			if len(group.UnreadArr) > 0 {
 				needDo[int(group.GroupId)] = group.UnreadArr
@@ -534,19 +538,21 @@ func GetMsgList(arr []int, size int, userId string) []*message.Messages {
 			newMsg = arr
 		}
 	}
+	//fmt.Println("*********8", newMsg)
 	resData := []*message.Messages{}
-	for _, v := range newMsg {
-		msg := GetMsgInfo(int(v), userId)
+	for i := len(newMsg) - 1; i >= 0; i-- {
+		//for _, v := range newMsg {
+		msg := GetMsgInfo(int(newMsg[i]), userId)
 		links4 := common.InterfaceToStr(msg["link"])
 		link4, androidUrl4, iosUrl4, weChatUrl4 := util.LinkSplit(links4)
 		resData = append(resData, &message.Messages{
-			Id:         common.InterfaceToStr(v),
+			Id:         common.InterfaceToStr(newMsg[i]),
 			Createtime: common.InterfaceToStr(msg["send_time"]),
 			Title:      common.InterfaceToStr(msg["title"]),
 			MsgType:    int64(util.IntAll(msg["group_id"])),
 			Link:       link4,
 			Content:    common.InterfaceToStr(msg["content"]),
-			MsgLogId:   int64(v),
+			MsgLogId:   int64(newMsg[i]),
 			Url: map[string]string{
 				"androidUrl": androidUrl4,
 				"iosUrl":     iosUrl4,