# API Details - Message ###### tags: `API Details` ## 使用者取得所有與賣家的訊息 - `_page` 頁數,預設為 1 - `_limit` 查詢筆數 - `_sort` 依...排序,預設為 'updatedAt',另可輸入 'vendorId'、'id' - `_order` 正序/反序,預設為 'DESC',另可輸入 'ASC' ### Response Example ```json { "ok": 1, "data": [ { "id": 1, "clientId": 3, "vendorId": 17, "content": "[{\"client\":[\"hello\",\"你好嗎\",\"衷心感謝\"]},{\"vendor\":[\"hihihi\",\"珍重再見\"]}]", "createdAt": "2021-08-01T17:25:40.000Z", "updatedAt": "2021-08-04T14:21:40.000Z", "Vendor": { "vendorName": "蔬果店", "avatarUrl": "https://i.imgur.com/123.png", "isSuspended": false, "User": { "username": "heyhey", "role": "vendor" } } }, { "id": 2, "clientId": 3, "vendorId": 15, "content": "[{\"client\":[\"hello\",\"你好嗎\",\"衷心感謝\"]},{\"vendor\":[\"hihihi\",\"珍重再見\"]}]", "createdAt": "2021-08-01T17:25:40.000Z", "updatedAt": "2021-08-04T14:21:40.000Z", "Vendor": { "vendorName": "蔬果店", "avatarUrl": "https://i.imgur.com/123.png", "isSuspended": false, "User": { "username": "heyhey", "role": "vendor" } } } ] } ``` ## 使用者取得與單一賣家的訊息 ### Response Example ```json { "ok": 1, "data": { "id": 1, "clientId": 3, "vendorId": 17, "content": "[{\"client\":[\"hello\",\"你好嗎\",\"衷心感謝\"]},{\"vendor\":[\"hihihi\",\"珍重再見\"]}]", "createdAt": "2021-08-01T17:25:40.000Z", "updatedAt": "2021-08-04T14:21:40.000Z", "Vendor": { "vendorName": "蔬果店", "avatarUrl": "https://i.imgur.com/123.png", "isSuspended": false, "User": { "username": "heyhey", "role": "vendor" } } } } ``` ## 賣家取得所有與使用者的訊息 - `_page` 頁數,預設為 1 - `_limit` 查詢筆數 - `_sort` 依...排序,預設為 'updatedAt',另可輸入 'clientId'、'id' - `_order` 正序/反序,預設為 'DESC',另可輸入 'ASC' ### Response Example ```json { "ok": 1, "data": [ { "id": 1, "clientId": 1, "vendorId": 17, "content": "[{\"client\":[\"hello\",\"你好嗎\",\"衷心感謝\"]},{\"vendor\":[\"hihihi\",\"珍重再見\"]}]", "createdAt": "2021-08-01T17:25:40.000Z", "updatedAt": "2021-08-04T14:21:40.000Z", "User": { "username": "heyhey", "nickname": "YoYoYoYo", "avatarURL": "https://i.imgur.com/123.jpg", "role": "member" } }, { "id": 2, "clientId": 2, "vendorId": 20, "content": "[{\"client\":[\"hello\",\"你好嗎\",\"衷心感謝\"]},{\"vendor\":[\"hihihi\",\"珍重再見\"]}]", "createdAt": "2021-08-01T17:25:40.000Z", "updatedAt": "2021-08-04T14:21:40.000Z", "User": { "username": "heyhey", "nickname": "YoYoYoYo", "avatarURL": "https://i.imgur.com/123.jpg", "role": "member" } } ] } ``` ## 賣家取得與單一使用者的訊息 ### Response Example ```json { "ok": 1, "data": { "id": 1, "clientId": 3, "vendorId": 17, "content": "[{\"client\":[\"hello\",\"你好嗎\",\"衷心感謝\"]},{\"vendor\":[\"hihihi\",\"珍重再見\"]}]", "createdAt": "2021-08-01T17:25:40.000Z", "updatedAt": "2021-08-04T14:21:40.000Z", "User": { "username": "heyhey", "nickname": "YoYoYoYo", "avatarURL": "https://i.imgur.com/123.jpg", "role": "member" } } } ``` ## 使用者向賣家傳送訊息 ### Request Example ```json { "content": "這是新訊息" } ``` ### Response Example ```json { "ok": 1, "data": { "id": 5, "clientId": 195, "vendorId": 65, "content": "[{\"client\":[\"hello\",\"你好嗎\",\"衷心感謝\"]},{\"vendor\":[\"hihihi\",\"你好\"]}, {\"client\":[\"這是新訊息\"]}]", "createdAt": "2021-10-01T17:25:40.000Z", "updatedAt": "2021-10-10T08:00:38.622Z" } } ``` ## 賣家向使用者傳送訊息 ### Request Example ```json { "content": "這是新訊息" } ``` ### Response Example ```json { "ok": 1, "data": { "id": 5, "clientId": 195, "vendorId": 65, "content": "[{\"client\":[\"hello\",\"你好嗎\",\"衷心感謝\"]},{\"vendor\":[\"hihihi\",\"這是新訊息\"]}]", "createdAt": "2021-10-01T17:25:40.000Z", "updatedAt": "2021-10-10T08:00:38.622Z" } } ``` ## 使用者取得與管理員的訊息 ### Response Example ```json { "ok": 1, "data": { "id": 1, "userId": 3, "content": "[{\"user\":[\"hello\",\"你好嗎\",\"衷心感謝\"]},{\"admin\":[\"hihihi\",\"珍重再見\"]}]", } } ``` ## 使用者向管理員傳送訊息 ### Request Example ```json { "content": "這是新訊息" } ``` ### Response Example ```json { "ok": 1, "data": { "id": 5, "userId": 195, "content": "[{\"user\":[\"hello\",\"你好嗎\",\"衷心感謝\"]},{\"admin\":[\"hihihi\",\"你好\"]}, {\"user\":[\"這是新訊息\"]}]", "createdAt": "2021-10-01T17:25:40.000Z", "updatedAt": "2021-10-10T08:00:38.622Z" } } ``` ## 管理員取得所有與使用者的訊息 - `_page` 頁數,預設為 1 - `_limit` 查詢筆數 - `_sort` 依...排序,預設為 'updatedAt',另可輸入 'userId'、'id' - `_order` 正序/反序,預設為 'DESC',另可輸入 'ASC' ### Response Example ```json { "ok": 1, "data": [ { "id": 1, "userId": 1, "content": "[{\"user\":[\"hello\",\"你好嗎\",\"衷心感謝\"]},{\"admin\":[\"hihihi\",\"珍重再見\"]}]", }, { "id": 2, "userId": 2, "content": "[{\"user\":[\"hello\",\"你好嗎\",\"衷心感謝\"]},{\"admin\":[\"hihihi\",\"珍重再見\"]}]]", } ] } ``` ## 管理員取得與單一使用者的訊息 ### Response Example ```json { "ok": 1, "data": { "id": 1, "userId": 1, "content": "[{\"user\":[\"hello\",\"你好嗎\",\"衷心感謝\"]},{\"admin\":[\"hihihi\",\"珍重再見\"]}]", } } ``` ## 管理員向使用者傳送訊息 ### Request Example ```json { "content": "這是新訊息" } ``` ### Response Example ```json { "ok": 1, "data": { "id": 5, "userId": 195, "content": "[{\"user\":[\"hello\",\"你好嗎\",\"衷心感謝\"]},{\"admin\":[\"hihihi\",\"這是新訊息\"]}]", "createdAt": "2021-10-01T17:25:40.000Z", "updatedAt": "2021-10-10T08:00:38.622Z" } } ``` ## 使用者向管理員傳送檢舉訊息 ### Request Example ```json { "reportedVendorId": 15, "reportedProductId": 30, "content": "這是檢舉訊息" } ``` ### Response Example ```json { "ok": 1, "message": "Success" } ``` ## 管理員取得所有檢舉訊息 - `_page` 頁數,預設為 1 - `_limit` 查詢筆數 - `_sort` 依...排序,預設為 'updatedAt',另可輸入 'userId'、'id' - `_order` 正序/反序,預設為 'DESC',另可輸入 'ASC' ### Response Example ```json { "ok": 1, "data": [ { "id": 1, "userId": 1, "reportedVendorId": 15, "reportedProductId": 30, "content": "這是檢舉訊息", }, { "id": 2, "userId": 2, "reportedVendorId": 18, "reportedProductId": 31, "content": "這是檢舉訊息", } ] } ``` ## 管理員取得單一檢舉訊息 ### Response Example ```json { "ok": 1, "data": { "id": 1, "userId": 1, "reportedVendorId": 15, "reportedProductId": 30, "content": "這是檢舉訊息", } } ```