1.优化拉取公告列表接口/api/notice/noticeList,不需要token鉴权

This commit is contained in:
2026-05-21 15:20:24 +08:00
parent d1dceb44d8
commit 13e7f3439a
2 changed files with 10 additions and 2 deletions

View File

@@ -11,6 +11,11 @@ use support\Response;
class Notice extends MobileBase
{
/** 公告列表:公开接口,无需 auth-token / user-token */
protected array $noNeedLogin = ['noticeList'];
protected array $noNeedAuthToken = ['noticeList'];
public function noticeList(Request $request): Response
{
$response = $this->initializeMobile($request);
@@ -32,8 +37,9 @@ class Notice extends MobileBase
}
}
$readMap = [];
if ($popoutNoticeIds !== []) {
$readRows = UserNoticeRead::where('user_id', $this->auth->id)->whereIn('notice_id', $popoutNoticeIds)->column('notice_id');
$userId = ($this->auth && $this->auth->isLogin()) ? $this->auth->id : 0;
if ($userId > 0 && $popoutNoticeIds !== []) {
$readRows = UserNoticeRead::where('user_id', $userId)->whereIn('notice_id', $popoutNoticeIds)->column('notice_id');
$readMap = array_flip($readRows);
}

View File

@@ -14,6 +14,7 @@
- `POST` 时请求头 `Content-Type: application/json`,参数放在 JSON body
- `GET` 兼容模式下,参数走 URL query string
- **例外**:公告模块 `/api/notice/noticeList``/api/notice/noticeConfirm` **仅支持 `GET`**,参数一律走 URL query string
- **公告列表免鉴权**`GET /api/notice/noticeList` **无需** `auth-token``user-token`;若仍携带 `user-token` 则强弹窗项可返回该用户真实的 `is_read`
- 鉴权类接口 `/api/v1/authToken` 仍为 `GET`
- 时间UTC 时间戳(秒) + 服务端时区配置
- 金额:数字传输(如 `"100.00"`),客户端展示统一保留两位小数(存储仍为 `decimal(18,2)`
@@ -714,6 +715,7 @@
### 6.1 拉取公告列表
- **GET** `/api/notice/noticeList`
- **鉴权**:无需 `auth-token``user-token`(公开接口)
请求参数query string
- `page`int可选默认 1