Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/faq #31

Closed
wants to merge 11 commits into from
Closed

Feature/faq #31

wants to merge 11 commits into from

Conversation

YongJun-Lee-98
Copy link

๐Ÿ’ก Issue

๐Ÿ“Œ Work Description

  • FAQ api ๊ตฌํ˜„
  • json ํ˜•ํƒœ์˜ ๋ฆฌํ„ด
  • pagenation ์ ์šฉ
  • ERROR ๋ฆฌํ„ด ์‹œ WEB์— ์ „๋‹ฌ code์ž์ฒด๋Š”
    code๊ฐ€ ์ „๋‹ฌ๋˜์—ˆ๋‹ค๋Š” ์˜๋ฏธ๋กœ success(200)๋ฅผ ๋ฆฌํ„ด
    "status":{} json๊ฐ’์œผ๋กœ SUCCESS/ERROR ๋ถˆ๋ฆฌ์–ธ ๊ฐ’ ๋ฆฌํ„ด ํ›„
  • json์—์„œ ERROR ๋ฐœ์ƒ ์‹œ = "error":{"์ข…๋ฅ˜", "message"}
  • json์—์„œ ERROR ๋ฏธ๋ฐœ์ƒ ์‹œ "error":None

โœ… ํ…Œ์ŠคํŠธ ํ•ญ๋ชฉ

  • FAQ ๊ธฐ๋Šฅ ํ…Œ์ŠคํŠธ

๐Ÿ“ Reference

ํ”„๋ก ํŠธ ํ˜‘์˜ ๋‚ด์šฉ

  • ์ ์šฉ์‚ฌํ•ญ
  1. api status return 200
  2. pagenation "?page=1&page_size=10" ์˜ ํ˜•ํƒœ๋กœ ์›ํ•˜๋Š” ํŽ˜์ด์ง€์˜ ์–‘

๐Ÿ“š Etc

README.md Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swagger๋ฅผ ์‚ฌ์šฉ ํ•  ์˜ˆ์ •์ด๋ผ README์—์„œ ์‚ฌ์šฉ ์˜ˆ์‹œ๋Š” ์—†์–ด๋„ ๋  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„.. ๊ทธ ํ…Œ์ŠคํŠธ ํ•  ๋•Œ ์ข€ ํŽธํ•˜๊ฒŒ ํ•˜์‹œ๋ผ๊ณ  ๋„ฃ์–ด๋’€๋Š”๋ฐ ์‚ญ์ œํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค
์˜ˆ์‹œ curl๋กœ ํ„ฐ๋ฏธ๋„์—์„œ ๋ณต๋ถ™ํ•ด์„œ ์˜ค๋ฅ˜ ์žˆ๋Š”์ง€ ํ™•์ธ์ฐจ. ํ•ด๋ณด๋˜ ์ฝ”๋“œ์ž…๋‹ˆ๋‹ท

@@ -31,6 +31,11 @@
# Application definition

INSTALLED_APPS = [
# Add User Application
"faq",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋กœ์ปฌ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜๊ณผ ์™ธ๋ถ€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ๊ตฌ๋ถ„๋˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ฐ˜์˜ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค

from faq.views import FAQViewSet

router = DefaultRouter()
router.register(r'faqs', FAQViewSet, basename="faq")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FAQ์˜ router๋Š” faq.urls ๋ชจ๋“ˆ์—์„œ ๊ด€๋ฆฌํ•˜๋Š” ๊ฒŒ ์ข‹์„ ๊ฒƒ ๊ฐ™์€๋ฐ ๋‹ค๋ฅธ๋ถ„๋“ค ์˜๊ฒฌ์€ ์–ด๋– ์‹ ๊ฐ€์š”?

path('admin/', admin.site.urls),
path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swagger์™€ redoc ๋ฌธ์„œ๋Š” Debug ํ™˜๊ฒฝ ํ˜น์€ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์—์„œ๋งŒ ๋ณด์ด๋Š”๊ฒŒ ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if settings.DEBUG:
์‚ฌ์šฉํ•ด์„œ ํ•ด๋‹น ๋‚ด์šฉ ๋ฐ˜์˜ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค

1. id : ๊ฒŒ์‹œ๋ฌผ์˜ ๊ณ ์œ  id
2. Status : ๊ฒŒ์‹œ๋ฌผ์˜ ์ƒํƒœ
"""
id = models.AutoField(primary_key=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apps ๋ชจ๋“ˆ๊ณผ settings์—์„œ ๊ธฐ๋ณธ ID ํ•„๋“œ์— ๋Œ€ํ•œ ์ •์˜๊ฐ€ ์žˆ์–ด์„œ BaseModel์— ๋”ฐ๋กœ ์ •์˜ํ•˜์ง€ ์•Š์•„๋„ ๋  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

def __str__(self):
return self.question

class Notice(BaseModel):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ณต์ง€์‚ฌํ•ญ๋„ FAQ ๋„๋ฉ”์ธ์—์„œ ๊ด€๋ฆฌ ํ•˜์‹œ๋ ค๋Š” ๊ฑด๊ฐ€์š”?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice๋Š” ๋”ฐ๋กœ ๋บ๋Š”๋ฐ ์‹ค์ˆ˜๋กœ ์ฝ”๋“œ๊ฐ€ ๊ฐ™์ด ๋“ค์–ด๊ฐ„๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค
์ˆ˜์ •ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

src/faq/views.py Outdated
from .serializers import FAQSerializer


class FAQPagination(PageNumberPagination):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FAQ ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ๋‹ค๋ฅธ ViewSet์—์„œ๋„ ๋™์ผํ•œ pagination ์„ค์ •์„ ์‚ฌ์šฉํ•  ๊ฒƒ ๊ฐ™์€๋ฐ
๊ธ€๋กœ๋ฒŒ์—์„œ ์ ‘๊ทผํ•ด์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ๋ณ„๋„ ๋ชจ๋“ˆ๋กœ ์ฒ˜๋ฆฌํ•˜๋ฉด ์–ด๋–จ๊นŒ์š”?

settings.py์— ๊ธฐ๋ณธ pagniation ํด๋ž˜์Šค๋ฅผ ์ง€์ •ํ•ด์„œ ์‚ฌ์šฉํ•ด๋„ ๊ดœ์ฐฎ์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ด€๋ จํ•ด์„œ settings.py์— ์ผ๋‹จ ๊ธฐ๋ณธ์„ค์ •(10๊ฐœ)์€ ๋“ฑ๋กํ•ด๋’€๋Š”๋ฐ
๋‹ค์Œ PR์—์„œ ํ•ด๋‹น ๋‚ด์šฉ Default ๊ฐ’ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ์ˆ˜์ •ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋‹ค๋งŒ ํ•œ๋ฒˆ ์š”์ฒญ์—์„œ ์ตœ๋Œ€ ๊ฐ’(max_page_size)์„ ์ง€์ •ํ•˜๋ ค๋ฉด
class๋กœ ๊ตฌ์ƒํ•ด์•ผ ํ•  ๊ฒƒ ๊ฐ™๊ณ 
์š”์ฒญํ•˜๋Š” ์ตœ๋Œ“๊ฐ’์ด ํ•„์š” ์—†๋‹ค๊ณ  ์ƒ๊ฐ๋˜๋ฉด Default์— ์ •์˜ํ•œ๊ฑธ ์‚ฌ์šฉํ•˜๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants