feat. 이벤트 네비게이션 추가
This commit is contained in:
63
layers/composables/useCwmsArticle.ts
Normal file
63
layers/composables/useCwmsArticle.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import type {
|
||||
getCwmsArticleParams,
|
||||
CwmsArticleResponse,
|
||||
CwmsArticle,
|
||||
} from '#layers/types/api/cwmsArticle'
|
||||
|
||||
export const useCwmsArticle = () => {
|
||||
/**
|
||||
*
|
||||
* @param articleGroupCode 게시판 그룹 코드 (예: 128093)
|
||||
* @param options 옵션 객체
|
||||
* @returns 게시판 글 목록 응답
|
||||
*/
|
||||
const getCwmsArticle = async (
|
||||
articleGroupCode: string,
|
||||
articleGroupSeq: number,
|
||||
params: getCwmsArticleParams
|
||||
): Promise<CwmsArticle | null> => {
|
||||
const {
|
||||
lang,
|
||||
sortTypeCode,
|
||||
interactionTypeCodes,
|
||||
handleCode,
|
||||
contentYn,
|
||||
summaryYn,
|
||||
headlineTitleYn,
|
||||
translationYn,
|
||||
page,
|
||||
size,
|
||||
} = params
|
||||
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const stoveApiBaseUrl = runtimeConfig.public.stoveApiUrl
|
||||
const apiUrl = `${stoveApiBaseUrl}/cwms/v3.0/article_group/${articleGroupCode}/${articleGroupSeq}/article/list`
|
||||
|
||||
const queryParams: Record<string, string | number | boolean> = {
|
||||
lang: lang,
|
||||
sort_type_code: sortTypeCode,
|
||||
interaction_type_code: interactionTypeCodes?.join(','),
|
||||
handle_code: handleCode ? 'Y' : 'N',
|
||||
content_yn: contentYn ? 'Y' : 'N',
|
||||
summary_yn: summaryYn ? 'Y' : 'N',
|
||||
headline_title_yn: headlineTitleYn ? 'Y' : 'N',
|
||||
translation_yn: translationYn ? 'Y' : 'N',
|
||||
page: page,
|
||||
size: size,
|
||||
}
|
||||
|
||||
const response = (await commonFetch('GET', apiUrl, {
|
||||
query: queryParams,
|
||||
loading: true,
|
||||
})) as CwmsArticleResponse | null
|
||||
|
||||
if (response?.code === 0 && 'value' in response) {
|
||||
return response.value
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
getCwmsArticle,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user