-
항해 99 5기 TIL_63항해 99 2022. 3. 13. 21:38
▶ Today I Learned
<실전 프로젝트 - 뱃지 가져오기>
우리 팀에서 구현하기로 한 기능 중 유저가 뱃지를 획득하는 시스템이 있다.
현재 짜놓은 코드를 보면 아래와 같이 라우터를 통해 get 방식으로 필요한 뱃지를 가져온다.
router.get("/user/:userId/badges", middleware.auth, UserController.get.badges);
여기서 미들웨어를 거쳐 해당 뱃지가 특정 유저에게 존재하는 지 체크하고 User를 담당하는 컨트롤러를 통해 해당 뱃지 정보를 찾아 가져온다음 res.json으로 반환해주게 된다.
이처럼 저장된 뱃지 정보를 가져오는 것은 깔끔히 구현되어있다.
그렇다면 뱃지를 가져오기 위해서는 다음의 작업을 고려하여야 한다.
1) 뱃지 획득을 어떻게 할 것인가?
특정 기준을 충족할 경우 자동으로 지급되어야 한다.
ex) 출석 100회 이상 -> 출석의 왕 뱃지 자동 생성 및 표시
2) 어떻게 저장할 것인가?
가져오는 부분은 문제없으니 어떻게 저장할 것인지 설계가 필요하다.
팀원 분의 말에 따르면 관련된 자료가 생각보다 많지 않았다고 한다.
우선 뱃지라는 키워드를 중점적으로 한글, 영문으로 검색해보고 나오지 않을 경우
'출석체크 도장 구현하기'와 같이 뱃지와 비슷한 역할을 하는 코드들을 구글링해볼 예정이다.
▶ 느낀 점
MVC패턴과 Mysql등이 익숙하진 않지만 팀원 분께서 먼저 짜놓으신 코드를 보며 모르는 부분은 조금씩 찾아보며 이해하고 있다.
다행히 새롭게 맡게 된 뱃지 기능의 큰 흐름은 이해하는 데 무리가 없었다.
아마 저장할 때 sequalize와 mysql에 대한 이해가 좀 더 필요할 것 같다.
현재는 프로젝트의 완성이 우선이니 필요한 부분만 찾아보며 바로바로 적용해보아야겠다.
▶ 공부 시 참고 링크들
https://hardlearner.tistory.com/387
'항해 99' 카테고리의 다른 글
항해 99 5기 TIL_65 (0) 2022.03.16 항해 99 5기 TIL_64 (0) 2022.03.15 항해 99 5기 TIL_62 (0) 2022.03.13 항해 99 5기 TIL_61 (0) 2022.03.12 항해 99 5기 TIL_60 (0) 2022.03.12