获取会话列表

  • 接口说明: 获取会话列表
  • 接口地址: /api/dialog
  • 请求方式: GET

请求参数

参数名称类型是否必须描述
includestring关联数据
page[number]int页码
page[limit]int单页数量
sortstring默认按照创建时间倒序,可选值:最新消息编号dialogMessageId、创建时间createdAt。添加标记‘-’为倒序,如:‘-dialogMessageId’;

include 可关联的数据

关联名称模型类型是否默认描述
senderusersobject发送人
recipientusersobject收信人
sender.groupsgroupsobject发送人用户组
recipient.groupsgroupsobject收信人用户组
dialogMessagedialog_messageobject最新消息

请求示例

  1. /api/dialog?include=sender,recipient,dialogMessage&page[number]=1&page[limit]=10

返回说明

  • 成功,http 状态码: 200
  • 失败,http 状态码: 404

返回结果

关联数据模型字段释义参见请参见相应文档

字段名变量名必填类型描述
linksobjectobject接口链接
data.typedata.typestring固定值 dialog
data.iddata.idint会话 id
data.attributesobjectobject数据属性
最新会话消息 IDattribute. dialog_message_idint最新会话消息 ID
发送人 uidattribute. sender_user_idint发送人 uid
收信人 uidattribute. recipient_user_idint收信人 uid
发送人阅读时间attribute. sender_read_atdatetime发送人阅读时间,null 时未读
收信人阅读时间attribute. recipient_read_atdatetime收信人阅读时间,null 时未读
更新时间attributes.updated_atdatetime更新时间
创建时间attributes.created_atdatetime创建时间
data.relationshipsobjectobject关联关系
includedobjectobject关联数据

返回示例

  1. {
  2. "links": {
  3. "first": "DummySiteUrl/api/dialog?include=sender%2Crecipient%2CdialogMessage",
  4. "last": "DummySiteUrl/api/dialog?include=sender%2Crecipient%2CdialogMessage"
  5. },
  6. "data": [
  7. {
  8. "type": "dialog",
  9. "id": "1",
  10. "attributes": {
  11. "dialog_message_id": 1,
  12. "sender_user_id": 1,
  13. "recipient_user_id": 2,
  14. "sender_read_at": null,
  15. "recipient_read_at": "2020-04-21T11:27:24+08:00",
  16. "updated_at": "2020-02-17T10:14:28+08:00",
  17. "created_at": "2020-02-17T10:14:31+08:00"
  18. },
  19. "relationships": {
  20. "sender": {
  21. "data": {
  22. "type": "users",
  23. "id": "1"
  24. }
  25. },
  26. "recipient": {
  27. "data": {
  28. "type": "users",
  29. "id": "2"
  30. }
  31. },
  32. "dialogMessage": {
  33. "data": {
  34. "type": "dialog_message",
  35. "id": "1"
  36. }
  37. }
  38. }
  39. },
  40. {
  41. "type": "dialog",
  42. "id": "2",
  43. "attributes": {
  44. "dialog_message_id": 2,
  45. "sender_user_id": 1,
  46. "recipient_user_id": 3,
  47. "sender_read_at": null,
  48. "recipient_read_at": "2020-04-21T11:27:24+08:00",
  49. "updated_at": "2020-02-17T10:14:43+08:00",
  50. "created_at": "2020-02-17T10:14:46+08:00"
  51. },
  52. "relationships": {
  53. "sender": {
  54. "data": {
  55. "type": "users",
  56. "id": "1"
  57. }
  58. },
  59. "recipient": {
  60. "data": {
  61. "type": "users",
  62. "id": "3"
  63. }
  64. },
  65. "dialogMessage": {
  66. "data": {
  67. "type": "dialog_message",
  68. "id": "2"
  69. }
  70. }
  71. }
  72. },
  73. {
  74. "type": "dialog",
  75. "id": "3",
  76. "attributes": {
  77. "dialog_message_id": 0,
  78. "sender_user_id": 1,
  79. "recipient_user_id": 4,
  80. "sender_read_at": null,
  81. "recipient_read_at": "2020-04-21T11:27:24+08:00",
  82. "updated_at": "2020-02-17T10:14:56+08:00",
  83. "created_at": "2020-02-17T10:14:57+08:00"
  84. },
  85. "relationships": {
  86. "sender": {
  87. "data": {
  88. "type": "users",
  89. "id": "1"
  90. }
  91. },
  92. "recipient": {
  93. "data": {
  94. "type": "users",
  95. "id": "4"
  96. }
  97. }
  98. }
  99. },
  100. {
  101. "type": "dialog",
  102. "id": "5",
  103. "attributes": {
  104. "dialog_message_id": 0,
  105. "sender_user_id": 1,
  106. "recipient_user_id": 5,
  107. "sender_read_at": null,
  108. "recipient_read_at": "2020-04-21T11:27:24+08:00",
  109. "updated_at": "2020-02-17T11:17:08+08:00",
  110. "created_at": "2020-02-17T11:17:08+08:00"
  111. },
  112. "relationships": {
  113. "sender": {
  114. "data": {
  115. "type": "users",
  116. "id": "1"
  117. }
  118. },
  119. "recipient": {
  120. "data": {
  121. "type": "users",
  122. "id": "5"
  123. }
  124. }
  125. }
  126. },
  127. {
  128. "type": "dialog",
  129. "id": "9",
  130. "attributes": {
  131. "dialog_message_id": 0,
  132. "sender_user_id": 1,
  133. "recipient_user_id": 6,
  134. "sender_read_at": null,
  135. "recipient_read_at": "2020-04-21T11:27:24+08:00",
  136. "updated_at": "2020-02-17T18:12:45+08:00",
  137. "created_at": "2020-02-17T18:12:45+08:00"
  138. },
  139. "relationships": {
  140. "sender": {
  141. "data": {
  142. "type": "users",
  143. "id": "1"
  144. }
  145. },
  146. "recipient": {
  147. "data": {
  148. "type": "users",
  149. "id": "6"
  150. }
  151. }
  152. }
  153. },
  154. {
  155. "type": "dialog",
  156. "id": "10",
  157. "attributes": {
  158. "dialog_message_id": 0,
  159. "sender_user_id": 1,
  160. "recipient_user_id": 8,
  161. "sender_read_at": null,
  162. "recipient_read_at": "2020-04-21T11:27:24+08:00",
  163. "updated_at": "2020-02-17T18:13:18+08:00",
  164. "created_at": "2020-02-17T18:13:18+08:00"
  165. },
  166. "relationships": {
  167. "sender": {
  168. "data": {
  169. "type": "users",
  170. "id": "1"
  171. }
  172. },
  173. "recipient": {
  174. "data": {
  175. "type": "users",
  176. "id": "8"
  177. }
  178. }
  179. }
  180. }
  181. ],
  182. "included": [
  183. {
  184. "type": "users",
  185. "id": "1",
  186. "attributes": {
  187. "id": 1,
  188. "username": "username",
  189. "mobile": "",
  190. "avatarUrl": "DummySiteUrl/storage/avatars/1.png?1578395431",
  191. "threadCount": 0,
  192. "followCount": 4,
  193. "fansCount": 2,
  194. "follow": null,
  195. "status": 0,
  196. "loginAt": "2020-02-18T15:17:13+08:00",
  197. "joinedAt": "2019-12-19T13:51:19+08:00",
  198. "expiredAt": null,
  199. "createdAt": "2019-12-19T13:51:20+08:00",
  200. "updatedAt": "2020-02-18T15:17:13+08:00",
  201. "canEdit": true,
  202. "canDelete": true,
  203. "registerReason": null,
  204. "originalMobile": "",
  205. "registerIp": "172.16.167.1",
  206. "lastLoginIp": "172.16.167.1",
  207. "identity": null,
  208. "realname": null
  209. }
  210. },
  211. {
  212. "type": "users",
  213. "id": "2",
  214. "attributes": {
  215. "id": 2,
  216. "username": "username",
  217. "mobile": "",
  218. "avatarUrl": "",
  219. "threadCount": 0,
  220. "followCount": 1,
  221. "fansCount": 1,
  222. "follow": null,
  223. "status": 0,
  224. "loginAt": "2020-02-06T19:48:34+08:00",
  225. "joinedAt": "2019-12-20T03:48:09+08:00",
  226. "expiredAt": null,
  227. "createdAt": "2019-12-20T03:48:09+08:00",
  228. "updatedAt": "2020-02-06T19:52:14+08:00",
  229. "canEdit": true,
  230. "canDelete": true,
  231. "registerReason": null,
  232. "originalMobile": "",
  233. "registerIp": "172.16.167.1",
  234. "lastLoginIp": "172.16.167.1",
  235. "identity": null,
  236. "realname": null
  237. }
  238. },
  239. {
  240. "type": "users",
  241. "id": "3",
  242. "attributes": {
  243. "id": 3,
  244. "username": "username",
  245. "mobile": "",
  246. "avatarUrl": "",
  247. "threadCount": 0,
  248. "followCount": 0,
  249. "fansCount": 0,
  250. "follow": null,
  251. "status": 0,
  252. "loginAt": null,
  253. "joinedAt": "2019-12-20T03:53:54+08:00",
  254. "expiredAt": null,
  255. "createdAt": "2019-12-20T03:53:55+08:00",
  256. "updatedAt": "2019-12-20T03:53:55+08:00",
  257. "canEdit": true,
  258. "canDelete": true,
  259. "registerReason": null,
  260. "originalMobile": "",
  261. "registerIp": "172.16.167.1",
  262. "lastLoginIp": "",
  263. "identity": null,
  264. "realname": null
  265. }
  266. },
  267. {
  268. "type": "users",
  269. "id": "4",
  270. "attributes": {
  271. "id": 4,
  272. "username": "username",
  273. "mobile": "",
  274. "avatarUrl": "",
  275. "threadCount": 0,
  276. "followCount": 0,
  277. "fansCount": 0,
  278. "follow": null,
  279. "status": 0,
  280. "loginAt": null,
  281. "joinedAt": "2019-12-19T15:33:23+08:00",
  282. "expiredAt": null,
  283. "createdAt": "2019-12-19T15:33:23+08:00",
  284. "updatedAt": "2020-01-02T16:37:51+08:00",
  285. "canEdit": true,
  286. "canDelete": true,
  287. "registerReason": null,
  288. "originalMobile": "",
  289. "registerIp": "172.16.167.1",
  290. "lastLoginIp": "172.16.167.1",
  291. "identity": null,
  292. "realname": null
  293. }
  294. },
  295. {
  296. "type": "users",
  297. "id": "5",
  298. "attributes": {
  299. "id": 5,
  300. "username": "username",
  301. "mobile": "",
  302. "avatarUrl": "",
  303. "threadCount": 0,
  304. "followCount": 0,
  305. "fansCount": 1,
  306. "follow": null,
  307. "status": 0,
  308. "loginAt": null,
  309. "joinedAt": "2019-12-27T18:19:21+08:00",
  310. "expiredAt": null,
  311. "createdAt": "2019-12-27T18:19:21+08:00",
  312. "updatedAt": "2020-01-20T15:53:11+08:00",
  313. "canEdit": true,
  314. "canDelete": true,
  315. "registerReason": null,
  316. "originalMobile": "",
  317. "registerIp": "172.16.167.1",
  318. "lastLoginIp": "",
  319. "identity": null,
  320. "realname": null
  321. }
  322. },
  323. {
  324. "type": "users",
  325. "id": "6",
  326. "attributes": {
  327. "id": 6,
  328. "username": "username",
  329. "mobile": "",
  330. "avatarUrl": "",
  331. "threadCount": 0,
  332. "followCount": 0,
  333. "fansCount": 0,
  334. "follow": null,
  335. "status": 0,
  336. "loginAt": null,
  337. "joinedAt": "2019-12-27T18:21:39+08:00",
  338. "expiredAt": null,
  339. "createdAt": "2019-12-27T18:21:39+08:00",
  340. "updatedAt": "2020-01-20T16:25:50+08:00",
  341. "canEdit": true,
  342. "canDelete": true,
  343. "registerReason": null,
  344. "originalMobile": "",
  345. "registerIp": "172.16.167.1",
  346. "lastLoginIp": "",
  347. "identity": null,
  348. "realname": null
  349. }
  350. },
  351. {
  352. "type": "users",
  353. "id": "8",
  354. "attributes": {
  355. "id": 8,
  356. "username": "username",
  357. "mobile": "",
  358. "avatarUrl": "",
  359. "threadCount": 0,
  360. "followCount": 0,
  361. "fansCount": 0,
  362. "follow": null,
  363. "status": 0,
  364. "loginAt": null,
  365. "joinedAt": "2019-12-31T12:03:15+08:00",
  366. "expiredAt": null,
  367. "createdAt": "2019-12-31T12:03:15+08:00",
  368. "updatedAt": "2019-12-31T12:03:15+08:00",
  369. "canEdit": true,
  370. "canDelete": true,
  371. "registerReason": null,
  372. "originalMobile": "",
  373. "registerIp": "172.16.167.1",
  374. "lastLoginIp": "",
  375. "identity": null,
  376. "realname": null
  377. }
  378. },
  379. {
  380. "type": "dialog_message",
  381. "id": "1",
  382. "attributes": {
  383. "id": 1,
  384. "user_id": 2,
  385. "dialog_id": 1,
  386. "message_text": "11111",
  387. "updated_at": "2020-02-17T10:15:20+08:00",
  388. "created_at": "2020-02-17T10:15:22+08:00"
  389. }
  390. },
  391. {
  392. "type": "dialog_message",
  393. "id": "2",
  394. "attributes": {
  395. "id": 2,
  396. "user_id": 1,
  397. "dialog_id": 2,
  398. "message_text": "22222",
  399. "updated_at": "2020-02-17T10:15:43+08:00",
  400. "created_at": "2020-02-17T10:15:45+08:00"
  401. }
  402. }
  403. ],
  404. "meta": {
  405. "total": 6,
  406. "size": 20
  407. }
  408. }