xyxie 18 цаг өмнө
parent
commit
3d5b6bfc30

+ 9 - 2
models/data_manage/edb_inspection/edb_inspection_message.go

@@ -148,16 +148,23 @@ func GetEdbInspectionMessageByAdminId(adminId int) (items []*EdbInspectionMessag
 	return
 }
 
-func GetEdbInspectionMessageCountByAdminId(adminId int) (count int, err error) {
+func GetEdbInspectionMessageUnreadCountByAdminId(adminId int) (count int, err error) {
 	o := global.DbMap[utils.DbNameIndex]
 	sql := "SELECT COUNT(*) FROM edb_inspection_message WHERE admin_id =? AND is_read = 0 ORDER BY is_read ASC, create_time DESC"
 	err = o.Raw(sql, adminId).Scan(&count).Error
 	return
 }
 
+func GetEdbInspectionMessageCountByAdminId(adminId int) (count int, err error) {
+	o := global.DbMap[utils.DbNameIndex]
+	sql := "SELECT COUNT(*) FROM edb_inspection_message WHERE admin_id =? ORDER BY is_read ASC, create_time DESC"
+	err = o.Raw(sql, adminId).Scan(&count).Error
+	return
+}
+
 func GetEdbInspectionMessagePageByAdminId(adminId, startSize, pageSize int) (items []*EdbInspectionMessage, err error) {
 	o := global.DbMap[utils.DbNameIndex]
-	sql := "SELECT * FROM edb_inspection_message WHERE admin_id =? AND is_read = 0 ORDER BY is_read ASC, create_time DESC LIMIT ?,?"
+	sql := "SELECT * FROM edb_inspection_message WHERE admin_id =? ORDER BY is_read ASC, create_time DESC LIMIT ?,?"
 	err = o.Raw(sql, adminId, startSize, pageSize).Find(&items).Error
 	return
 } 

+ 5 - 1
services/data/edb_inspection_message.go

@@ -84,9 +84,13 @@ func GetInspectionMessageList(adminid int, currentIndex, pageSize int) (resp edb
 		return
 	}
 
+	unreadTotal, err := edb_inspection.GetEdbInspectionMessageUnreadCountByAdminId(adminid)
+	if err != nil {
+		return
+	}
 	resp.List = toEdbInspectionMessageResp(messageList)
 	resp.Paging = paging.GetPaging(currentIndex, pageSize, total)
-	resp.UnreadTotal = total
+	resp.UnreadTotal = unreadTotal
 	return
 }