INIT
This commit is contained in:
69
frontend/src/lib/api/cow.api.ts
Normal file
69
frontend/src/lib/api/cow.api.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import apiClient from "../api-client";
|
||||
import { RankingRequest } from "@/types/ranking.types";
|
||||
import { CowDto, CowDetailResponseDto } from "@/types/cow.types";
|
||||
|
||||
/**
|
||||
* 개체(Cow) 관련 API
|
||||
*/
|
||||
export const cowApi = {
|
||||
/**
|
||||
* GET /cow - 전체 개체 목록
|
||||
*/
|
||||
findAll: async (): Promise<CowDto[]> => {
|
||||
return await apiClient.get("/cow");
|
||||
},
|
||||
|
||||
/**
|
||||
* GET /cow/paginated - 페이지네이션 목록
|
||||
*/
|
||||
findAllWithPagination: async (
|
||||
page: number = 1,
|
||||
limit: number = 10
|
||||
): Promise<{ data: CowDto[]; total: number; page: number; limit: number }> => {
|
||||
return await apiClient.get("/cow/paginated", {
|
||||
params: { page, limit },
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* GET /cow/farm/:farmNo - 특정 농장의 개체 목록
|
||||
*/
|
||||
findByFarmNo: async (farmNo: number): Promise<CowDto[]> => {
|
||||
return await apiClient.get(`/cow/farm/${farmNo}`);
|
||||
},
|
||||
|
||||
/**
|
||||
* GET /cow/search - 개체 검색 (개체번호 또는 개체명)
|
||||
*/
|
||||
search: async (
|
||||
keyword: string,
|
||||
farmNo?: number,
|
||||
limit: number = 20
|
||||
): Promise<CowDto[]> => {
|
||||
return await apiClient.get("/cow/search", {
|
||||
params: { keyword, farmNo, limit },
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* GET /cow/:cowNo - 개체 상세 조회
|
||||
*/
|
||||
findOne: async (cowNo: string): Promise<CowDetailResponseDto> => {
|
||||
return await apiClient.get(`/cow/${cowNo}`);
|
||||
},
|
||||
|
||||
/**
|
||||
* POST /cow/ranking - 암소 랭킹 조회 (필터 + 랭킹 통합)
|
||||
*/
|
||||
getRanking: async (rankingRequest: RankingRequest): Promise<any> => {
|
||||
return await apiClient.post("/cow/ranking", rankingRequest);
|
||||
},
|
||||
|
||||
/**
|
||||
* POST /cow/ranking/global - 전체 농가 개체 대상 랭킹 조회
|
||||
*/
|
||||
getGlobalRanking: async (rankingRequest: RankingRequest): Promise<any> => {
|
||||
return await apiClient.post("/cow/ranking/global", rankingRequest);
|
||||
},
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user