fix: 系统消息标记已读

This commit is contained in:
guozhigq
2024-08-25 22:07:42 +08:00
parent 8810a74ebf
commit 8fd3bfae5f
3 changed files with 36 additions and 2 deletions

View File

@ -554,4 +554,8 @@ class Api {
/// 系统通知
static const String messageSystemAPi =
'${HttpString.messageBaseUrl}/x/sys-msg/query_unified_notify';
/// 系统通知标记已读
static const String systemMarkRead =
'${HttpString.messageBaseUrl}/x/sys-msg/update_cursor';
}

View File

@ -298,7 +298,6 @@ class MsgHttp {
});
if (res.data['code'] == 0) {
try {
print(res.data['data']['system_notify_list']);
return {
'status': true,
'data': res.data['data']['system_notify_list']
@ -312,4 +311,23 @@ class MsgHttp {
return {'status': false, 'date': [], 'msg': res.data['message']};
}
}
// 系统消息标记已读
static Future systemMarkRead(int cursor) async {
String csrf = await Request.getCsrf();
var res = await Request().get(Api.systemMarkRead, data: {
'csrf': csrf,
'cursor': cursor,
});
if (res.data['code'] == 0) {
return {
'status': true,
};
} else {
return {
'status': false,
'msg': res.data['message'],
};
}
}
}

View File

@ -8,8 +8,20 @@ class MessageSystemController extends GetxController {
Future queryMessageSystem({String type = 'init'}) async {
var res = await MsgHttp.messageSystem();
if (res['status']) {
systemItems.addAll(res['data']);
if (type == 'init') {
systemItems.value = res['data'];
} else {
systemItems.addAll(res['data']);
}
if (systemItems.isNotEmpty) {
systemMarkRead(systemItems.first.cursor!);
}
}
return res;
}
// 标记已读
void systemMarkRead(int cursor) async {
await MsgHttp.systemMarkRead(cursor);
}
}