Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions src/libs/axios/base/review.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { axiosInstance } from ".";

/**
* 리뷰등록
* @function
* @parameter payListIdx : number - 리뷰등록 idx
* @parameter title : string - 제목
* @parameter content: string - 내용
* @parameter ondo : number - 온도
* @parameter images : File[] - 이미지
* @returns {Promise}
* @description
* - 리뷰 등록을 위한 API
* - 온도는 전체 온도 나누기 상품 판매의 갯수입니다.
ex) 전체 온도 70도 / 판매갯수 2 => 35도
- 요청결과 200("success") || 400("failure")
*/
export const postReviewByPayListIdx = async ({
payListIdx,
title,
content,
ondo,
images,
}) => {
const response = await axiosInstance.post(
"/review",
{ params: { payList_idx: payListIdx } },
{ title, content, ondo, images }
);

return response;
Copy link
Contributor

Choose a reason for hiding this comment

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

Request Level

  • N : "🔥 이대로 Merge 하면 안돼요~!"
  • M : "🥹 고치면 분명 나아질 게 분명합니다.."
  • S : "🤷 수정하면 좋지 않을까요?"

Description

  • 이 부분만 return값이 response인 이유가 있을까요? 다른 부분은 다 response.data인 것 같은데..

};

/**
* 2.리뷰 목록 조회
* @function
* @parameter page: number - 조회할 리뷰들의 page
* @description 리뷰들의 목록을 보여주는 api
*/

export const getReviewByPage = async ({ page }) => {
const response = await axiosInstance.get("/review", { params: { page } });
return response.data;
};

/**
* 3.리뷰 상세
* @function
* @parameter reviewIdx: number - 조회할 리뷰의 idx
* @description
* - 특정한 하나의 review를 나타내는 API
* - 요청한 특정 리뷰가 상세히 조회됩니다
*/

export const getReviewGetByReviewIdx = async ({ reviewIdx }) => {
const response = await axiosInstance.get("/review/get", {
params: { review_idx: reviewIdx },
});
return response.data;
};
/**
* 4.리뷰 수정
* @function
* @parameter reviewIdx : number - 수정할 리뷰의 idx
* @parameter title : string - 새로운 제목
* @parameter content : string - 새로운 내용
* @parameter ondo : number - 새로운 온도
* @parameter imgUrl: string[] - 새로운 서브 기존 이미지 url[]
* @parameter mainUrl: stirng - 새로운 메인 기존 이미지 url
* @parameter images: File[] - 새로운 이미지 파일 목록
* @description
* - 등록 물품 검색을 위한 API
* - images 는 main_url이 있다면 [0]~[3]sub, main_url이 없다면 [0]main, [1~3]sub
* - 요청결과 200("success") || 400("failure")
*/

export const patchReviewByReviewIdx = async ({
reviewIdx,
title,
content,
ondo,
imgUrl,
mainUrl,
images,
}) => {
const response = await axiosInstance.patch(
"/review",
{ params: { review_idx: reviewIdx } },
{ title, content, ondo, img_url: imgUrl, main_url: mainUrl, images }
);
return response;
Copy link
Contributor

Choose a reason for hiding this comment

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

Request Level

  • N : "🔥 이대로 Merge 하면 안돼요~!"
  • M : "🥹 고치면 분명 나아질 게 분명합니다.."
  • S : "🤷 수정하면 좋지 않을까요?"

Description

  • 이 부분도 return값이 response네요. 하나로 통일시키는게 좋을 것 같습니다.

};
/**
* 5.리뷰 삭제
* @function
* @parameter reviewIdx : number - 삭제할 리뷰의 idx
* @description
* - 등록 물품 검색을 위한 API
* - 요청결과 200("success") || 400("failure")
*/
export const deleteReviewByReviewIdx = async ({ reviewIdx }) => {
const response = await axiosInstance.delete("/review", {
params: { review_idx: reviewIdx },
});
return response;
Copy link
Contributor

Choose a reason for hiding this comment

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

Request Level

  • N : "🔥 이대로 Merge 하면 안돼요~!"
  • M : "🥹 고치면 분명 나아질 게 분명합니다.."
  • S : "🤷 수정하면 좋지 않을까요?"

Description

  • 이 부분도 return값이 response네요. 하나로 통일시키는게 좋을 것 같습니다.

Copy link
Contributor Author

@keeprok keeprok Mar 1, 2024

Choose a reason for hiding this comment

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

api요청에따라 데이터 값만 필요한 조회(목록,상세)부분은 response.data로 해주었고 나머지 3요청들은 header 및데이터 외의 값이 필요한게있다고 해서 response로 주었습니다

};