f# Answer List
Answer Object중 publisehd=True인 Answer들에 한하여 Answer들을 돌려줍니다.
Default는 최신순의 유저를 가리지 않은 Answer Object가 Pagination이 되어있습니다.
Filtering: ...url/?<parameter>=<value> 에 parameter 과 value를 넣어 각종 필터링을 실행할 수 있습니다.
Ordering: 또한, 모든 포스트에 대해 ?ordering=modified_at, 혹은 ?ordering=-modified_at을 통해 오래된 순, 최신순 필터링을 실행할 수 있습니다.
필터는 &를 통해 Chain 으로 여러개를 덧붙여 실행할 수 있습니다.
Pagination: page를 통해 다음 페이지를 Access 할 수 있습니다. 한 페이지에는 5개의 post가 나옵니다.
next 를 통해 다음 5개의 post가 있는 페이지, previous 를 통해 이전 5개의 post가 있는 페이지를 부를 수 있습니다.
URL
/post/answer/
/post/answer/?<parameter>=<value>
Query Parameter를 붙일 시 url의 끝에 /
가 들어가지 않습니다. / 가 붙으면 internal server error 가 반환됩니다.
Filter Query Parameters
Parameter | Description | Type | uri |
---|---|---|---|
user | User's Answer - 유저가 작성한 답 | Int | /post/answer/?user=1 |
topic | Answer's Question's Topic matches - value로 전달된 pk값에 해당하는 Topic을 가진 Question에 달린 답변 | Int | /post/answer/?topic=1 |
bookmarked_by | Bookmarked by user - value로 전달된 pk 값에 해당하는 유저가 bookmark를 한 답변 | Int | /post/answer/?bookmarked_by=1 |
ordering | ordering by value - value로 전달된 created_at 혹은 modified_at을 통해 순서를 재배열, 앞에 - 를 붙여 순서를 reverse | Str | 오래된 순 - /post/answer/?ordering=created_at 최신순 - /post/answer/?ordering=-created_at |
page | page - 전체 result에서 몇번째 페이지에 해당하는 result를 가지고 올지 요청 | Int | /post/answer/?page=2 |
Or / And 연산
Or 연산을 하고 싶을 때는 필드 뒤에 ,
를 붙여 요청하면 됩니다. (예: /post/answer/?user=1,2,3 = 유저 1 or 유저 2 or 유저 3이 쓴 Answer)
And 연산을 하고 싶을 때는 &를 추가하여 요청하면 됩니다. (예: /post/answer/?user=1&topic=1 = 유저 1이 쓴 Answer 중 Topic 1)
여러 query parameter에 걸친 Or연산은 불가능 합니다 (예: - 유저 1이 쓴 Answer or Topic 2)
Method
GET
Success Response
HTTP Status Code
200
Content
Key | Description | Type |
---|---|---|
count | 총 hit 된 object의 개수 | Int |
next | 다음 페이지로의 url | Str |
previous | 이전 페이지로의 url | Str |
pk | Answer의 pk | Int |
url | 생성된 Answer Detail 링크 | Str |
user | Topic을 만든 유저의 Profile Detail 링크 | Str |
question | Answer가 달린 Question Detail 링크 | int |
content_html | quillJS 텍스트 에디터에서 InnerHTML 을 통해 뽑아낸 html String | str |
content | quillJS 텍스트 에디터에서 .getContent()를 통해 뽑아낸 json데이터 | JSON |
upvote_count | Answer의 좋아요 개수 | Int |
comment_count | Answer의 comment 개수 | Int |
user_upvote_relation | 유저가 추천을 한 경우 해당 추천 action의 정보를 담은 relation의 pk 값입니다. Value의 유무로 upvote 표현방식을 결정할 수 있습니다. | Int |
user_bookmark_relation | 유저가 북마크를 한 경우 해당 북마크 action의 정보를 담은 relation의 pk 값입니다. | Int |
published | True or False | Bool |
created_at | 생성된 날짜 | Date |
modified_at | 마지막으로 수정된 날짜 - 처음 생성되었을 때는 created_at과 같음 | Date |
{
"count": 13,
"next": "http://localhost:8000/post/answer/?page=2",
"previous": null,
"results": [
{
"pk": 43,
"url": "http://localhost:8000/post/answer/43/",
"user": "http://localhost:8000/user/1/profile/main-detail/",
"question": "http://localhost:8000/post/question/4/",
"content_html": "",
"content": {
<quill_js_delta_content>
},
"upvote_count": 0,
"comment_count": 0,
"user_upvote_relation": null,
"user_bookmark_relation": null,
"published": true,
"created_at": "2017-12-06",
"modified_at": "2017-12-06T02:57:00.866122+09:00"
},
{
"pk": 44,
"url": "http://localhost:8000/post/answer/44/",
"user": "http://localhost:8000/user/1/profile/main-detail/",
"question": "http://localhost:8000/post/question/4/",
"content_html": "",
"content": {
<quill_js_delta_content>
},
"upvote_count": 0,
"comment_count": 0,
"user_upvote_relation": null,
"user_bookmark_relation": null,
"published": true,
"created_at": "2017-12-06",
"modified_at": "2017-12-06T02:57:02.303153+09:00"
},
{
"pk": 46,
"url": "http://localhost:8000/post/answer/46/",
"user": "http://localhost:8000/user/1/profile/main-detail/",
"question": "http://localhost:8000/post/question/4/",
"content_html": "",
"content": {
<quill_js_delta_content>
},
"upvote_count": 0,
"comment_count": 0,
"user_upvote_relation": null,
"user_bookmark_relation": null,
"published": true,
"created_at": "2017-12-06",
"modified_at": "2017-12-06T03:08:33.065269+09:00"
},
{
"pk": 47,
"url": "http://localhost:8000/post/answer/47/",
"user": "http://localhost:8000/user/1/profile/main-detail/",
"question": "http://localhost:8000/post/question/4/",
"content_html": "",
"content": {
<quill_js_delta_content>
},
"upvote_count": 0,
"comment_count": 0,
"user_upvote_relation": null,
"user_bookmark_relation": null,
"published": true,
"created_at": "2017-12-06",
"modified_at": "2017-12-06T19:41:37.137058+09:00"
}
]
}
Error Response
Bad Request Error
HTTP Status Code
400
Content
# query parameter를 보냈는데 value를 보내지 않았을 때
{
"message": "query parameter가 존재하나 value가 존재하지 않습니다."
}
Bad Request Error
HTTP Status Code
400
Content
# 잘못된 query parameter로 요청을 보냈을 때
{
"message": "존재하지 않는 query_parameter입니다. 필터가 가능한 query_parameter는 다음과 같습니다: "
"ordering', 'bookmarked_by', 'page', 'user', 'topic"
}