7 ERD & API 설계 - 97kim/mytrip GitHub Wiki

📌 ERD

QuickDBD-export


📌 API 설계

401 Error

{
    "timestamp": "1640077934009",
    "status": 401,
    "error": "Unauthorized",
    "path": "/reviews/38/comments/44" // 에러 발생한 경로
}

403 Error

{
    "timestamp": 1640077573636,
    "status": 403,
    "error": "Forbidden",
    "path": "/reviews/10/comments/11" // 에러 발생한 경로
}

POST /user/signup

  • 회원가입

Request Body

{
    "username": "testuser", // required
    "password": "test123",  // required
}

Response

200 OK
{
    "회원가입을 축하드립니다!"
}

POST /user/login

  • 로그인

Request Body

{
    "username": "testuser", // required
    "password": "test123",  // required
}

Response

200 OK
{
    "token": "HEADER.PAYLOAD.VERIFY SIGNATURE",
    "username": "testuser"
}

POST /user/signup/check

  • 회원가입 시 아이디 유효성 검사

Request Body

{
    "username": "testuser" // required
}

Response

200 OK
{
    "exists": true // or false
}

POST /user

  • 프로필 설정
  • 로그인 필요

Request Body

content-type: form-data

nickname: "nickname" // required X
profileImgUrl: file  // required X

Response

200 OK
{
    "createdAt": "2021-12-08T15:15:25.399",
    "modifiedAt": "2021-12-08T21:36:40.149",
    "id": 1,
    "username": "testuser",
    "nickname": "hello",
    "profileImgUrl": "https://dk9q1cr2zzfmc.cloudfront.net/profile/807657cf-126e-4253-a39d-192aff1b9744default.jpg"
}

DELETE /user

  • 현재 로그인 한 사용자 회원 탈퇴
  • 로그인 필요

Request Body X

Response

200 OK

GET /nearspots?lat={lat}&lng={lng}

  • 위치 기반 근처 여행지 리스트 조회

Request Body X

Response

200 OK
[
    {
        "readcount": 23225,
        "addr1": "서울특별시 종로구 궁정동 55-5",
        "contentid": 1603543,
        "dist": 229,
        "booktour": 0,
        "firstimage2": "http://tong.visitkorea.or.kr/cms/resource/69/1568069_image3_1.jpg",
        "title": "무궁화동산",
        "areacode": 1,
        "createdtime": 20120416153015,
        "mapy": 37.5843076223,
        "contenttypeid": 12,
        "mapx": 126.9721572068,
        "cat2": "A0202",
        "cat3": "A02020700",
        "modifiedtime": 20210330154829,
        "cat1": "A02",
        "mlevel": 6,
        "sigungucode": 23,
        "firstimage": "http://tong.visitkorea.or.kr/cms/resource/69/1568069_image2_1.jpg"
    },
    ... 
]

POST /nearspots

  • 위치 기반 근처 여행지 리스트 필터 적용

Request Body

{
    "lat_give": "37.58549382575489",  // required
    "lng_give": "126.97004739512613", // required
    "type_give": "trip",              // required [trip(여행), food(음식), accommodation(숙소), festival(축제)]
    "quantity_give": "15"             // required [15, 20, 25, 30]
}

Response

200 OK
[
    {
        "readcount": 23225,
        "addr1": "서울특별시 종로구 궁정동 55-5",
        "contentid": 1603543,
        "dist": 229,
        "booktour": 0,
        "firstimage2": "http://tong.visitkorea.or.kr/cms/resource/69/1568069_image3_1.jpg",
        "title": "무궁화동산",
        "areacode": 1,
        "createdtime": 20120416153015,
        "mapy": 37.5843076223,
        "contenttypeid": 12,
        "mapx": 126.9721572068,
        "cat2": "A0202",
        "cat3": "A02020700",
        "modifiedtime": 20210330154829,
        "cat1": "A02",
        "mlevel": 6,
        "sigungucode": 23,
        "firstimage": "http://tong.visitkorea.or.kr/cms/resource/69/1568069_image2_1.jpg"
    },
    ...
]

GET /nearspots/{contentId}

  • 근처 여행지 상세데이터 조회

Request Body X

Response

200 OK
{
    "overview": "조선 태종때 도호부로 승격된 수원은 한성 4진의 하나였다. 한양을 중심으로 동서남북 방향인 광주, 강화, 수원, 개성에 진을 설치하여 수도 한양을 보위케 한것이다. 그 수원땅을 지키고 있는 화성은 유네스코에 의해 세계문화유산으로 등재되면서 역사적 가치를 높이고 있다.또한 다양한 상설 공연을 진행하고, 매년 가을이면 수원화성문화제를 개최하여 수원 화성을 알리고 있다.팔달산(143m)을 중심으로 쌓은 화성(사적)은 총길이가 5,700m에 달한다. 화성은 단순한 하나의 '성'이 아니다. 역사적 의미와 함께 건축학적으로도 귀중한 문화유산이다.화성의 축성은 정조의 한과 효심에서 비롯됐다. 1762년 영조 38년 윤 5월21일 사도세자 (장조:고종때 추존)는 당쟁으로 인하여 한여름 뒤주 속에 갇혀 8일만에 죽었다. 사도세자의 아들 정조는 당시 11세였다. 할아버지 영조의 뒤를 이은 정조는 즉위 13년만에 부친의 고혼을 위로키 위해 묘를 양주 땅 배봉산(지금의 서울시 전농동)에서 수원 화산으로 옮기고 수원을 자신이 이상으로 꿈꾸는 신도시로 건설하고자 정조 18년 정월부터 20년9월까지에 걸쳐 성곽을 축성하였다. 화성은 조선 성곽제도의 최고 완성형이다. 한국성곽 발달사에서도 가장 중요한 비중을 차지한다. 이 성은 석성과 토성의 장점만을 살려 축성됐다. 화성축성에 매달린 선조들은 한국성곽의 약점을 보완하기 위해 중국과 서양의 축성술을 본뜨기도 했다. 이 성에 관련된 사항은 \"화성 성역의궤\"에 자세히 기록돼 있다. 화성의 건축과 관련 빼놓을 수 없는 인물이 바로 다산 정약용이다. 당시 30세였던 다산은 왕실서고 규장각에 비치된 첨단서적들을 섭렵하고 중국에서 들여온『고금도서 집성』5,000권을 참조해 새로운 성곽을 설계했다. 정약용은 거중기를 고안하기도 했다. 기록에 의하면 이 성에는 성문을 비롯, 48개의 시설물이 있었지만 현재 복원된 것을 포함해 41개의 시설물이 남아 있다. 보물 팔달문을 비롯해 팔달산을 둘러싼 시설 가운데 가장 높은 서장대, 화포를 감춰두고 적군에게 총을 쏘도록 축조된 남포루, 선조들의 정취가 가득한 방화수류정 등 200년전 건물엔 조선의 문화 향기가 가득하다. 화성은 1997년 12월4일 이탈리아 나폴리에서 열린 유네스코(UNESCO) 세계유산위원회에서 창덕궁과 함께 세계문화유산으로 등록됐다.",
    "addr1": "경기도 수원시 장안구 수성로 320",
    "contentid": 125555,
    "booktour": 1,
    "firstimage2": "http://tong.visitkorea.or.kr/cms/resource/36/2613036_image3_1.jpg",
    "title": "수원 화성 [유네스코 세계문화유산]",
    "areacode": 31,
    "createdtime": 20040209000000,
    "mapy": 37.2918560775,
    "contenttypeid": 12,
    "mapx": 127.0072872434,
    "zipcode": 16273,
    "cat2": "A0201",
    "cat3": "A02010200",
    "modifiedtime": 20211029152946,
    "cat1": "A02",
    "mlevel": 6,
    "sigungucode": 13,
    "firstimage": "http://tong.visitkorea.or.kr/cms/resource/36/2613036_image2_1.jpg",
    "homepage": "<a href=\"http://www.swcf.or.kr\" target=\"_blank\" title=\"새창: 수원문화재단 홈페이지로 이동\">http://www.swcf.or.kr</a>"
}

GET /nearspots/{contentId}/bookmark

  • 근처 여행지 즐겨찾기 여부 확인
  • 로그인 필요

Request Body X

Response

200 OK
{
    "bookmarkStatus": true
}

POST /nearspots/{contentId}/bookmark

  • 근처 여행지 즐겨찾기
  • 로그인 필요

Request Body

{
    "title": "즐겨찾기한 제목",
    "address": "즐겨찾기한 주소",
    "img_url": "즐겨찾기한 이미지 url"
}

Response

200 OK

DELETE /nearspots/{contentId}/bookmark

  • 근처 여행지 즐겨찾기 해제
  • 로그인 필요

Request Body X

Response

200 OK

GET /themes

  • 테마별 인기 여행지 리스트 조회

Request Body X

Response

200 OK
{
 "cat2": "C0112",
 "cat3": "C01120001",
 "cat1": "C01",
 "trip_theme": "가족",
 "popular_list": [
        {
            "readcount": 26559,
            "contentid": 1904557,
            "firstimage2": "http://tong.visitkorea.or.kr/cms/resource/33/1185433_image3_1.jpg",
            "title": "강릉 경포로 떠나는 누정 시·문학 기행",
            "areacode": 32,
            "createdtime": 20140311131403,
            "mapy": 37.7865588677,
            "contenttypeid": 25,
            "mapx": 128.8850778068,
            "cat2": "C0112",
            "cat3": "C01120001",
            "modifiedtime": 20210901094738,
            "cat1": "C01",
            "mlevel": 6,
            "sigungucode": 1,
            "firstimage": "http://tong.visitkorea.or.kr/cms/resource/33/1185433_image2_1.jpg"
        },
        {
            "readcount": 20408,
            "contentid": 1869491,
            "firstimage2": "http://tong.visitkorea.or.kr/cms/resource/70/1589970_image3_1.jpg",
            "title": "바오밥나무 아래서 어린왕자 만나볼까?",
            "areacode": 31,
            "createdtime": 20131210163619,
            "mapy": 37.0951998733,
            "contenttypeid": 25,
            "mapx": 127.4063399677,
            "cat2": "C0112",
            "cat3": "C01120001",
            "modifiedtime": 20210604164144,
            "cat1": "C01",
            "mlevel": 6,
            "sigungucode": 23,
            "firstimage": "http://tong.visitkorea.or.kr/cms/resource/70/1589970_image2_1.jpg"
        }, 
}

POST /themes

  • 테마별 인기 여행지 리스트 필터 적용

Request Body

{
    "quantity" : "2",
    "cat1": "C01",
    "cat2": "C0112",
    "cat3": "C01120001"
}

Response

200 OK
{
  "readcount": 26559,
  "contentid": 1904557,
  "firstimage2": "http://tong.visitkorea.or.kr/cms/resource/33/1185433_image3_1.jpg",
  "title": "강릉 경포로 떠나는 누정 시·문학 기행",
  "areacode": 32,
  "createdtime": 20140311131403,
  "mapy": 37.7865588677,
  "contenttypeid": 25,
  "mapx": 128.8850778068,
  "cat2": "C0112",
  "cat3": "C01120001",
  "modifiedtime": 20210901094738,
  "cat1": "C01",
  "mlevel": 6,
  "sigungucode": 1,
  "firstimage": "http://tong.visitkorea.or.kr/cms/resource/33/1185433_image2_1.jpg"
}

GET /themes/{contentId}

  • 테마별 인기 여행지 상세데이터 조회

Request Body X

Response

200 OK
{
    "overview": "강원도 삼척은 하나의 거대한 천연동굴밭이다. 대이리 동굴지대에서만 10여개의 크고 작은 석회암 동굴이 발견됐는데 그중에는 동양 최대 규모를 자랑하는 유명 동굴, 환선굴도 있다. 웅장하고 기이한 동굴 내부를 구경하다 보면 어느새 무더위는 사라지고 경외감만 남는다. 세계 유명 동굴과 그 생태 등을 재현한 동굴신비관 역시 빼놓을 수 없는 구경거리다. 동굴탐험을 마치면 천혜의 풍광을 자랑하는 삼척의 해변과 산림도 느껴보자.",
    "contentid": 2401954,
    "firstimage2": "http://tong.visitkorea.or.kr/cms/resource/40/2037140_image3_1.jpg",
    "title": "“동굴아, 여름을 부탁해”...그늘 찾아 떠나는 삼척여행",
    "areacode": 32,
    "createdtime": 20160818092253,
    "mapy": 37.3259535342,
    "contenttypeid": 25,
    "mapx": 129.0205714417,
    "cat2": "C0114",
    "cat3": "C01140001",
    "modifiedtime": 20160927182815,
    "cat1": "C01",
    "mlevel": 6,
    "sigungucode": 4,
    "firstimage": "http://tong.visitkorea.or.kr/cms/resource/40/2037140_image2_1.jpg"
}

GET /themes/{contentId}/bookmark

  • 테마별 인기 여행지 즐겨찾기 여부 확인
  • 로그인 필요

Request Body X

Response

200 OK
{
    "bookmarkStatus": true
}

POST /themes/{contentId}/bookmark

  • 테마별 인기 여행지 즐겨찾기
  • 로그인 필요

Request Body

{
    "title": "즐겨찾기한 제목",
    "img_url": "즐겨찾기한 이미지 url"
}

Response

200 OK

DELETE /themes/{contentId}/bookmark

  • 테마별 인기 여행지 즐겨찾기 해제
  • 로그인 필요

Request Body X

Response

200 OK

GET /reviews?sort={sort}

  • 리뷰 리스트 조회

Request Body X

Response

200 OK
[
    {
        "createdAt": "2021-12-08T19:54:22.337",
        "modifiedAt": "2021-12-08T22:02:30.638",
        "id": 15,
        "title": "아침 공기 좋네요",
        "place": "지리산",
        "review": "아침부터 등산하니 좋다!",
        "reviewImgUrl": "https://dk9q1cr2zzfmc.cloudfront.net/reviewImg/1aa44564-7a26-402b-97c6-ae0de0f625e2testimg.jpeg",
        "likeCnt": 1,
        "user": {
            "createdAt": "2021-12-08T15:15:25.399",
            "modifiedAt": "2021-12-08T21:36:40.149",
            "id": 1,
            "username": "testuser",
            "nickname": "hello",
            "profileImgUrl": "https://dk9q1cr2zzfmc.cloudfront.net/profile/807657cf-126e-4253-a39d-192aff1b9744default.jpg"
        },
        "comments": [],
        "userReviewLikes": [
            {
                "createdAt": "2021-12-08T22:02:30.615",
                "modifiedAt": "2021-12-08T22:02:30.615",
                "id": 18
            }
        ]
    },
    ...
]

GET /reviews/{reviewId}

  • 리뷰 조회

Request Body X

Response

200 OK
{
    "createdAt": "2021-12-08T22:39:35.664",
    "modifiedAt": "2021-12-08T22:43:14.302",
    "id": 27,
    "title": "수정된 제목",
    "place": "수정된 장소",
    "review": "수정된 내용",
    "reviewImgUrl": "https://dk9q1cr2zzfmc.cloudfront.net/reviewImg/a62d26c6-b2b6-4442-a108-5a6f92695c62testimg.jpeg",
    "likeCnt": 0,
    "user": {
        "createdAt": "2021-12-08T15:15:25.399",
        "modifiedAt": "2021-12-08T21:36:40.149",
        "id": 1,
        "username": "testuser",
        "nickname": "hello",
        "profileImgUrl": "https://dk9q1cr2zzfmc.cloudfront.net/profile/807657cf-126e-4253-a39d-192aff1b9744default.jpg"
    },
    "comments": [],
    "userReviewLikes": []
}

POST /review

  • 리뷰 생성
  • 로그인 필요

Request Body

content-type: form-data

review_data: {
                  "title": "test2",
                  "place": "test2",
                  "review": "test2"
              } // required, Blob(application/json)
review_img: file // required X, multipart/form-data

Response

200 OK
{
    "createdAt": "2021-12-08T22:27:04.641",
    "modifiedAt": "2021-12-08T22:27:04.641",
    "id": 25,
    "title": "여행을 떠나요",
    "place": "여수",
    "review": "여수밤바다 들으며 갑시다",
    "reviewImgUrl": "https://dk9q1cr2zzfmc.cloudfront.net/reviewImg/3786c7f2-9bed-4966-b0c9-573261270f53ERD.png",
    "likeCnt": 0,
    "user": {
        "createdAt": "2021-12-08T15:15:25.399",
        "modifiedAt": "2021-12-08T21:36:40.149",
        "id": 1,
        "username": "testuser",
        "nickname": "hello",
        "profileImgUrl": "https://dk9q1cr2zzfmc.cloudfront.net/profile/807657cf-126e-4253-a39d-192aff1b9744default.jpg"
    },
    "comments": null,
    "userReviewLikes": null
}

PUT /reviews/{reviewId}

  • 리뷰 수정
  • 로그인 필요

Request Body

content-type: form-data

review_data: {
                  "title": "test2",
                  "place": "test2",
                  "review": "test2"
              } // required, Blob(application/json)
review_img: file // required X, multipart/form-data

Response

200 OK
{
    "createdAt": "2021-12-08T22:39:35.664",
    "modifiedAt": "2021-12-08T22:43:14.302",
    "id": 27,
    "title": "수정된 제목",
    "place": "수정된 장소",
    "review": "수정된 내용",
    "reviewImgUrl": "https://dk9q1cr2zzfmc.cloudfront.net/reviewImg/a62d26c6-b2b6-4442-a108-5a6f92695c62testimg.jpeg",
    "likeCnt": 0,
    "user": {
        "createdAt": "2021-12-08T15:15:25.399",
        "modifiedAt": "2021-12-08T21:36:40.149",
        "id": 1,
        "username": "testuser",
        "nickname": "hello",
        "profileImgUrl": "https://dk9q1cr2zzfmc.cloudfront.net/profile/807657cf-126e-4253-a39d-192aff1b9744default.jpg"
    },
    "comments": [],
    "userReviewLikes": []
}

DELETE /reviews/{reviewId}

  • 리뷰 삭제
  • 로그인 필요

Request Body X

Response

200 OK

GET /reviews/{reviewId}/like

  • 좋아요 상태 체크
  • 로그인 필요

Request X

Response

200 OK
{
    "likeStatus": false // or true
}

POST /reviews/{reviewId}/like

  • 좋아요
  • 로그인 필요

Request Body X

Response

200 OK

DELETE /reviews/{reviewId}/like

  • 좋아요 해제
  • 로그인 필요

Request Body X

Response

200 OK

GET /reviews/{reviewId}/comments

  • 댓글 조회

Request Body X

Response

200 OK
[
    {
        "createdAt": "2021-12-08T23:29:17.176",
        "modifiedAt": "2021-12-08T23:29:17.176",
        "id": 42,
        "comment": "무플 방지",
        "user": {
            "createdAt": "2021-12-08T15:15:25.399",
            "modifiedAt": "2021-12-08T21:36:40.149",
            "id": 1,
            "username": "testuser",
            "nickname": "hello",
            "profileImgUrl": "https://dk9q1cr2zzfmc.cloudfront.net/profile/807657cf-126e-4253-a39d-192aff1b9744default.jpg"
        }
    },
    ...
]

POST /reviews/{reviewId}/comment

  • 댓글 생성
  • 로그인 필요

Request Body

{
    "comment": "댓글 달아보자" // required
}

Response

200 OK
{
    "createdAt": "2021-12-08T23:37:53.095",
    "modifiedAt": "2021-12-08T23:37:53.095",
    "id": 44,
    "comment": "댓글 달아보자",
    "user": {
        "createdAt": "2021-12-08T15:15:25.399",
        "modifiedAt": "2021-12-08T21:36:40.149",
        "id": 1,
        "username": "testuser",
        "nickname": "hello",
        "profileImgUrl": "https://dk9q1cr2zzfmc.cloudfront.net/profile/807657cf-126e-4253-a39d-192aff1b9744default.jpg"
    }
}

PUT /reviews/{reviewId}/comments/{commentId}

  • 댓글 수정
  • 로그인 필요

Request Body

{
    "comment": "댓글 수정해보자" // required
}

Response

200 OK
{
    "createdAt": "2021-12-08T23:37:53.095",
    "modifiedAt": "2021-12-09T00:08:37.562",
    "id": 44,
    "comment": "댓글 수정해보자",
    "user": {
        "createdAt": "2021-12-08T15:15:25.399",
        "modifiedAt": "2021-12-08T21:36:40.149",
        "id": 1,
        "username": "testuser",
        "nickname": "hello",
        "profileImgUrl": "https://dk9q1cr2zzfmc.cloudfront.net/profile/807657cf-126e-4253-a39d-192aff1b9744default.jpg"
    }
}

DELETE /reviews/{reviewId}/comment/{commentId}

  • 댓글 삭제
  • 로그인 필요

Request Body X

Response

200 OK

📝 API 문서 자동화 - SWAGGER

https://api.kimkj.shop/swagger-ui.html