刚开始,userInfo里面的id我默认以为是User表的id,但是后面稍微看了一下返回的数据,userId跟replyId一致,我就知道userInfo里的id指的是Reply的id(应该是命名冲突,先查Reply有没有id,没有,再查User的id,有的话直接就用了)
{"code": 0,"message": "操作成功","data": {"pageInfo": {"current": 1,"total": 3,"pages": 1},"list": [{"replyId": 2,"content": "123456","userId": 1,"toReplyId": 1,"threadId": 1,"isDelete": false,"createTime": "2024-10-29T16:20:54","userInfo": {"userId": 2,"nickName": "123456"}},{"replyId": 3,"content": "123456","userId": 2,"toReplyId": 1,"threadId": 1,"isDelete": false,"createTime": "2024-10-29T16:50:49","userInfo": {"userId": 3,"nickName": null}},{"replyId": 4,"content": "12345","userId": 2,"toReplyId": 1,"threadId": 1,"isDelete": false,"createTime": "2024-10-29T16:55:00","userInfo": {"userId": 4,"nickName": null}}]}
}
当时我突发奇想,指定表名能成功吗?
当然是不行的:
{"code": 0,"message": "操作成功","data": {"pageInfo": {"current": 1,"total": 3,"pages": 1},"list": [{"replyId": 2,"content": "123456","userId": 1,"toReplyId": 1,"threadId": 1,"isDelete": false,"createTime": "2024-10-29T16:20:54","userInfo": {"userId": null,"nickName": "123456"}},{"replyId": 3,"content": "123456","userId": 2,"toReplyId": 1,"threadId": 1,"isDelete": false,"createTime": "2024-10-29T16:50:49","userInfo": null},{"replyId": 4,"content": "12345","userId": 2,"toReplyId": 1,"threadId": 1,"isDelete": false,"createTime": "2024-10-29T16:55:00","userInfo": null}]}
}
到后面想到了表里不是有user_id吗,直接用就可以了:
{"code": 0,"message": "操作成功","data": {"pageInfo": {"current": 1,"total": 3,"pages": 1},"list": [{"replyId": 2,"content": "123456","userId": 1,"toReplyId": 1,"threadId": 1,"isDelete": false,"createTime": "2024-10-29T16:20:54","userInfo": {"userId": 1,"nickName": "123456"}},{"replyId": 3,"content": "123456","userId": 2,"toReplyId": 1,"threadId": 1,"isDelete": false,"createTime": "2024-10-29T16:50:49","userInfo": {"userId": 2,"nickName": null}},{"replyId": 4,"content": "12345","userId": 2,"toReplyId": 1,"threadId": 1,"isDelete": false,"createTime": "2024-10-29T16:55:00","userInfo": {"userId": 2,"nickName": null}}]}
}