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 => { 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 = { 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, } }