Skip to content

api database

changicho edited this page Nov 29, 2020 · 1 revision

커넥트클래스 데이터베이스 Layer API 문서

응답 방식

{
  success: Boolean,
  message: Error Message, // 실패 시에만 존재
  data: Data, // 성공 시에만 존재
}

Error Message

에러 발생 시 HTTP Status Code 200 반환

const ERROR_CODE = {
  QUESTION_NOT_FOUND: '질문을 찾을 수 없습니다.',
  QUESTION_LIKE_NOT_MINUS: '좋아요는 음수가 될 수 없습니다.',

  SLIDE_NOT_FOUND: '슬라이드를 찾을 수 없습니다.',

  STUDY_DATA_NOT_FOUND: '스터디 데이터를 찾을 수 없습니다.',

  STUDY_GROUP_NOT_FOUND: '스터디그룹을 찾을 수 없습니다.',
  STUDY_GROUP_ALREADY_EXISTS: '해당 스터디그룹은 이미 존재합니다.',

  USER_NOT_FOUND: '사용자를 찾을 수 없습니다.',
  USER_ALREADY_EXISTS: '해당 사용자는 이미 존재합니다.',

  STUDY_MEMBER_NOT_FOUND: '스터디멤버를 찾을 수 없습니다.'
};

Question API

GET /question/:studyDataId

/**
 * @api {get} /question/:studyDataId
 * @apiName 스터디데이터의 모든 질문 가져오기
 * @apiGroup Database/Question
 *
 * @apiParam {String} studyDataId 스터디데이터 ID
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Array} data 질문 데이터
 *
 * @apiError STUDY_DATA_NOT_FOUND 해당 스터디데이터가 없는 경우
 */

성공 응답 예시

{
  success: true,
  data: [
    {
      id: String,
      user: String,
      title: String,
      content: String,
      like: Int,
      slideOrder: Int,
      slideImageURL: String,
      createdAt: Date,
      updatedAt: Date
    },
    // ...
  ]
}

POST /question

/**
 * @api {post} /question/
 * @apiName 새로운 질문 만들기
 * @apiGroup Database/Question
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Object} data 추가한 질문 데이터
 *
 * @apiError STUDY_DATA_NOT_FOUND 해당 스터디데이터가 없는 경우
 */

Body Request 예시

{
  user: String
  title: String,
  content: String,
  slideOrder: Int,
  slideImageURL: String,
  studyDataId: String
}

성공 응답 예시

{
  success: true,
  data: {
      id: String,
      user: String,
      title: String,
      content: String,
      like: Int,
      slideOrder: Int,
      slideImageURL: String,
      createdAt: Date,
      updatedAt: Date
  }
}

POST /question/like/:studyDataId/:questionId

/**
 * @api {post} /question/like/:studyDataId/:questionId
 * @apiName 질문 좋아요 올리기
 * @apiGroup Database/Question
 *
 * @apiParam {String} studyDataId 스터디데이터 ID
 * @apiParam {String} questionId 질문 ID
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Object} data 좋아요 변경한 질문 데이터
 *
 * @apiError STUDY_DATA_NOT_FOUND 해당 스터디데이터가 없는 경우
 * @apiError QUESTION_NOT_FOUND 해당 질문이 없는 경우
 */

성공 응답 예시

{
  success: true,
  data: {
      id: String,
      user: String,
      title: String,
      content: String,
      like: Int,
      slideOrder: Int,
      slideImageURL: String,
      createdAt: Date,
      updatedAt: Date
  }
}

DELETE /question/like/:studyDataId/:questionId

/**
 * @api {delete} /question/like/:studyDataId/:questionId
 * @apiName 질문 좋아요 내리기
 * @apiGroup Database/Question
 *
 * @apiParam {String} studyDataId 스터디데이터 ID
 * @apiParam {String} questionId 질문 ID
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Object} data 좋아요 변경한 질문 데이터
 *
 * @apiError STUDY_DATA_NOT_FOUND 해당 스터디데이터가 없는 경우
 * @apiError QUESTION_NOT_FOUND 해당 질문이 없는 경우
 * @apiError QUESTION_LIKE_NOT_MINUS 질문 좋아요를 음수로 바꾸려고 시도했을 때
 */

성공 응답 예시

{
  success: true,
  data: {
      id: String,
      user: String,
      title: String,
      content: String,
      like: Int,
      slideOrder: Int,
      slideImageURL: String,
      createdAt: Date,
      updatedAt: Date
  }
}

DELETE /question/:studyDataId/:questionId

/**
 * @api {delete} /question/:studyDataId/:questionId
 * @apiName 질문 삭제하기
 * @apiGroup Database/Question
 *
 * @apiParam {String} studyDataId 스터디데이터 ID
 * @apiParam {String} questionId 질문 ID
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Object} data 삭제한 질문 데이터
 *
 * @apiError STUDY_DATA_NOT_FOUND 해당 스터디데이터가 없는 경우
 * @apiError QUESTION_NOT_FOUND 해당 질문이 없는 경우
 */

Response

{
  success: true,
  data: {
      id: String,
      user: String,
      title: String,
      content: String,
      like: Int,
      slideOrder: Int,
      slideImageURL: String,
      createdAt: Date,
      updatedAt: Date
  }
}

StudyData API

GET /studydata/

/**
 * @api {get} /studydata/
 * @apiName 모든 스터디데이터 가져오기
 * @apiGroup Database/StudyData
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Array} data 모든 스터디데이터
 */

성공 응답 예제

{
  success: true,
  data: [
    {
      id: Int,
      week: Int,
      date: Date,
      slideInfo: Array<String>, // 슬라이드 이미지 URL 목록
      studyGroupId: String,
      questions: Array<Question>
      createdAt: Date,
      updatedAt: Date
    },
    // ...
  ]
}

GET /studydata/:id

/**
 * @api {get} /studydata/:id
 * @apiName 스터디데이터 가져오기
 * @apiGroup Database/StudyData
 *
 * @apiParam {String} id 스터디데이터 ID
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Object} data 스터디데이터
 *
 * @apiError STUDY_DATA_NOT_FOUND 존재하지 않는 스터디데이터
 */

성공 응답 예제

{
  success: true,
  data: {
      id: Int,
      week: Int,
      date: Date,
      slideInfo: Array<String>, // 슬라이드 이미지 URL 목록
      studyGroupId: String,
      questions: Array<Question>
      createdAt: Date,
      updatedAt: Date
  }
}

GET /studydata/bystudy/:id

/**
 * @api {get} /studydata/bystudy/:id
 * @apiName 스터디그룹 ID로 스터디데이터 가져오기
 * @apiGroup Database/StudyData
 *
 * @apiParam {String} id 스터디그룹 ID
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Array} data 스터디그룹에 속한 모든 스터디데이터
 */

성공 응답 예제

{
  success: true,
  data: [
    {
        id: Int,
        week: Int,
        date: Date,
        slideInfo: Array<String>, // 슬라이드 이미지 URL 목록
        studyGroupId: String,
        questions: Array<Question>
        createdAt: Date,
        updatedAt: Date
    },
    // ...
  ]
}

POST /studydata

/**
 * @api {post} /studydata/
 * @apiName 스터디데이터 만들기
 * @apiGroup Database/StudyData
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Object} data 추가된 스터디데이터
 *
 * @apiError STUDY_GROUP_NOT_FOUND 스터디그룹이 없는 경우
 */

Body Request 예제

{
  week: Int,
  date: Date,
  slideInfo: Array<String>, // 슬라이드 이미지 URL 목록
  studyGroupId: String
}

성공 응답 예제

{
  success: true,
  data: {
      id: Int,
      week: Int,
      date: Date,
      slideInfo: Array<String>, // 슬라이드 이미지 URL 목록
      studyGroupId: String,
      questions: Array<Question>
      createdAt: Date,
      updatedAt: Date
  }
}

PUT /studydata/:id

/**
 * @api {put} /studydata/:id
 * @apiName 스터디데이터 수정하기
 * @apiGroup Database/StudyData
 *
 * @apiParam {String} id 스터디데이터 ID
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Object} data 수정된 스터디데이터
 *
 * @apiError STUDY_GROUP_NOT_FOUND 스터디그룹이 없는 경우
 * @apiError STUDY_DATA_NOT_FOUND 스터디데이터가 없는 경우
 */

Body Request 예제

{
  week: Int,
  date: Date,
  slideInfo: Array<String>, // 슬라이드 이미지 URL 목록
  studyGroupId: String
}

성공 응답 예제

{
  success: true,
  data: {
      id: Int,
      week: Int,
      date: Date,
      slideInfo: Array<String>, // 슬라이드 이미지 URL 목록
      studyGroupId: String,
      questions: Array<Question>
      createdAt: Date,
      updatedAt: Date
  }
}

DELETE /studydata/:id

/**
 * @api {delete} /studydata/:id
 * @apiName 스터디데이터 삭제하기
 * @apiGroup Database/StudyData
 *
 * @apiParam {String} id 스터디데이터 ID
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Object} data 삭제된 스터디데이터
 *
 * @apiError STUDY_DATA_NOT_FOUND 스터디데이터가 없는 경우
 */

성공 응답 예제

{
  success: true,
  data: {
      id: Int,
      week: Int,
      date: Date,
      slideInfo: Array<String>, // 슬라이드 이미지 URL 목록
      studyGroupId: String,
      questions: Array<Question>
      createdAt: Date,
      updatedAt: Date
  }
}

StudyGroup API

GET /studygroup/

/**
 * @api {get} /studygroup/
 * @apiName 모든 스터디그룹 가져오기
 * @apiGroup Database/StudyGroup
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Array} data 삭제된 스터디데이터
 *
 * @apiError STUDY_DATA_NOT_FOUND 스터디데이터가 없는 경우
 */

성공 응답 예시

{
  success: true,
  data: [
    {
      id: String (uuid)
      title: String,
      category: String,
      password: String,
      salt: String,
      people: Array<String>, // 참여 가능한 유저 ID 목록
      maxPeople: Int,
      owner: String, // 방장 유저 ID
      isPremium: Boolean,
      createdAt: Date,
      updatedAt: Date
    },
    // ...
  ]
}

GET /studygroup/:id

/**
 * @api {get} /studygroup/:id
 * @apiName 스터디그룹 가져오기
 * @apiGroup Database/StudyGroup
 *
 * @apiParam {String} id 스터디그룹 ID
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Object} data 스터디그룹 데이터
 *
 * @apiError STUDY_GROUP_NOT_FOUND 스터디그룹이 없는 경우
 */

성공 응답 예시

{
  success: true,
  data: {
      id: String (uuid)
      title: String,
      category: String,
      password: String,
      salt: String,
      people: Array<String>, // 참여 가능한 유저 ID 목록
      maxPeople: Int,
      owner: String, // 방장 유저 ID
      isPremium: Boolean,
      createdAt: Date,
      updatedAt: Date
  }
}

POST /studygroup

/**
 * @api {post} /studygroup/
 * @apiName 스터디그룹 만들기
 * @apiGroup Database/StudyGroup
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Object} data 생성된 스터디그룹 데이터
 */

Body Request 예시

{
  title: String,
  category: String,
  password: String,
  salt: String,
  maxPeople: Int,
  owner: string,
  isPremium: Boolean
}

성공 응답 예시

{
  success: true,
  data: {
      id: String (uuid)
      title: String,
      category: String,
      password: String,
      salt: String,
      people: Array<String>, // 참여 가능한 유저 ID 목록
      maxPeople: Int,
      owner: String, // 방장 유저 ID
      isPremium: Boolean,
      createdAt: Date,
      updatedAt: Date
  }
}

PUT /studygroup/:id

/**
 * @api {put} /studygroup/:id
 * @apiName 스터디그룹 수정하기
 * @apiGroup Database/StudyGroup
 *
 * @apiParam {String} id 스터디그룹 ID
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Object} data 수정된 스터디그룹 데이터
 *
 * @apiError STUDY_GROUP_NOT_FOUND 스터디그룹이 없는 경우
 */

Body Request 예시

{
  title: String,
  category: String,
  password: String,
  salt: String,
  maxPeople: Int,
  owner: string,
  isPremium: Boolean
}

성공 응답 예시

{
  success: true,
  data: {
      id: String (uuid)
      title: String,
      category: String,
      password: String,
      salt: String,
      people: Array<String>, // 참여 가능한 유저 ID 목록
      maxPeople: Int,
      owner: String, // 방장 유저 ID
      isPremium: Boolean,
      createdAt: Date,
      updatedAt: Date
  }
}

POST /studygroup/people/:id

/**
 * @api {post} /studygroup/people/:id
 * @apiName 스터디그룹 허용 인원 추가하기
 * @apiGroup Database/StudyGroup
 *
 * @apiParam {String} id 스터디그룹 ID
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Object} data 수정된 스터디그룹 데이터
 *
 * @apiError STUDY_GROUP_NOT_FOUND 스터디그룹이 없는 경우
 */

Body Request 예시

{
  userId: String; // 참여할 유저 ID
}

성공 응답 예시

{
  success: true,
  data: {
      id: String (uuid)
      title: String,
      category: String,
      password: String,
      salt: String,
      people: Array<String>, // 참여 가능한 유저 ID 목록
      maxPeople: Int,
      owner: String, // 방장 유저 ID
      isPremium: Boolean,
      createdAt: Date,
      updatedAt: Date
  }
}

DELETE /studygroup/people/:id

/**
 * @api {delete} /studygroup/people/:id
 * @apiName 스터디그룹 허용 인원 제거하기
 * @apiGroup Database/StudyGroup
 *
 * @apiParam {String} id 스터디그룹 ID
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Object} data 수정된 스터디그룹 데이터
 *
 * @apiError STUDY_GROUP_NOT_FOUND 스터디그룹이 없는 경우
 */

Body Request 예시

Body {
  userId: String // 퇴장할 유저 ID
}

성공 응답 예시

{
  success: true,
  data: {
      id: String (uuid)
      title: String,
      category: String,
      password: String,
      salt: String,
      people: Array<String>, // 참여 가능한 유저 ID 목록
      maxPeople: Int,
      owner: String, // 방장 유저 ID
      isPremium: Boolean,
      createdAt: Date,
      updatedAt: Date
  }
}

DELETE /studygroup/:id

/**
 * @api {delete} /studygroup/people/:id
 * @apiName 스터디그룹 삭제하기
 * @apiGroup Database/StudyGroup
 *
 * @apiParam {String} id 스터디그룹 ID
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Object} data 삭제된 스터디그룹 데이터
 *
 * @apiError STUDY_GROUP_NOT_FOUND 스터디그룹이 없는 경우
 */

성공 응답 예시

{
  success: true,
  data: {
      id: String (uuid)
      title: String,
      category: String,
      password: String,
      salt: String,
      people: Array<String>, // 참여 가능한 유저 ID 목록
      maxPeople: Int,
      owner: String, // 방장 유저 ID
      isPremium: Boolean,
      createdAt: Date,
      updatedAt: Date
  }
}

User API

GET /user/

/**
 * @api {get} /user/
 * @apiName 모든 유저 가져오기
 * @apiGroup Database/User
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Array} data 모든 유저 데이터
 */

성공 응답 예시

{
  success: true,
  data: [
    {
      id: "kakaotest1234", // <provider><id> 조합
      nickname: "홍길동",
      email: "[email protected]",
      profileImage: "http://profileimage",
      isPremium: false,
      createdAt: Date,
      updatedAt: Date
    },
    // ...
  ]
}

GET /user/:id

/**
 * @api {get} /user/:id
 * @apiName 유저 가져오기
 * @apiGroup Database/User
 *
 * @apiParam {String} id 유저 ID
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Object} data 해당 id 유저 데이터
 */

성공 응답 예시

{
  success: true,
  data: {
      id: "kakaotest1234", // <provider><id> 조합
      nickname: "홍길동",
      email: "[email protected]",
      profileImage: "http://profileimage",
      isPremium: false,
      createdAt: Date,
      updatedAt: Date
  }
}

POST /user

/**
 * @api {put} /user/:id
 * @apiName 유저 정보 수정하기
 * @apiGroup Database/User
 *
 * @apiParam {String} id 유저 ID
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Object} data 추가된 유저 데이터
 *
 * @apiError USER_NOT_FOUND 해당 id의 유저가 없는 경우
 */

Body Request 예시

{
  provider: "kakao", // OAuth 서비스 종류 (ex.kakao, naver)
  id: "test1234", // 유저 ID
  nickname: "홍길동",
  email: "[email protected]",
  profileImage: "http://profileImage",
  isPremium: false
}

성공 응답 예시

{
  success: true,
  data: {
      id: "kakaotest1234", // <provider><id> 조합
      nickname: "홍길동",
      email: "[email protected]",
      profileImage: "http://profileimage",
      isPremium: false,
      createdAt: Date,
      updatedAt: Date
  }
}

PUT /user/:id

/**
 * @api {put} /user/:id
 * @apiName 유저 정보 수정하기
 * @apiGroup Database/User
 *
 * @apiParam {String} id 유저 ID
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Object} data 추가된 유저 데이터
 *
 * @apiError USER_NOT_FOUND 해당 id의 유저가 없는 경우
 */

Body Request 예시

{
  nickname: "새로운 이름",
  email: "[email protected]",
  profileImage: "http://profileimage",
  isPremium: false
}

성공 응답 예시

{
  success: true,
  data: {
      id: "kakaotest1234", // <provider><id> 조합
      nickname: "홍길동",
      email: "[email protected]",
      profileImage: "http://profileimage",
      isPremium: false,
      createdAt: Date,
      updatedAt: Date
  }
}

DELETE /user/:id

/**
 * @api {delete} /user/:id
 * @apiName 유저 삭제하기
 * @apiGroup Database/User
 *
 * @apiParam {String} id 유저 ID
 *
 * @apiSuccess {Boolean} success 성공 여부
 * @apiSuccess {Object} data 삭제된 유저 데이터
 *
 * @apiError USER_NOT_FOUND 해당 id의 유저가 없는 경우
 */

성공 응답 예시

{
  success: true,
  data: {
      id: String, // <provider><id> 조합
      nickname: String,
      email: String,
      profileImage: String,
      isPremium: Boolean,
      createdAt: Date,
      updatedAt: Date
  }
}
Clone this wiki locally