104 lines
2.8 KiB
TypeScript
104 lines
2.8 KiB
TypeScript
import type {
|
|
getOperateResourcesDataParams,
|
|
OperateResourcesDataResponse,
|
|
OperateComponents,
|
|
getCwmsArticleDataParams,
|
|
CwmsArticleDataResponse,
|
|
CwmsArticleData,
|
|
} from '#layers/types/api/resourcesData'
|
|
|
|
export const useResourcesData = () => {
|
|
/**
|
|
*
|
|
* @param params getOperateResourcesDataParams
|
|
* @returns OperateComponents | null
|
|
* @description 운영 리소스 데이터 조회
|
|
*/
|
|
const getOperateResourcesData = async (
|
|
params: getOperateResourcesDataParams
|
|
): Promise<OperateComponents | null> => {
|
|
const { pageSeq, pageVer, pageVerTmplSeq, langCode, q, qc } = params
|
|
|
|
const config = useRuntimeConfig()
|
|
const stoveApiBaseUrl = config.public.stoveApiUrl
|
|
const apiUrl = `${stoveApiBaseUrl}/pub-comm/v1.0/template/operateResources`
|
|
|
|
const queryParams: Record<string, string | number> = {
|
|
page_seq: pageSeq,
|
|
page_ver: pageVer,
|
|
page_ver_tmpl_seq: pageVerTmplSeq,
|
|
lang_code: langCode,
|
|
q: q || '',
|
|
qc: qc || '',
|
|
_t: Date.now().toString(), // 캐시 무효화를 위한 타임스탬프
|
|
}
|
|
|
|
const response = (await commonFetch('GET', apiUrl, {
|
|
query: queryParams,
|
|
loading: true,
|
|
})) as OperateResourcesDataResponse | null
|
|
|
|
if (response?.code === 0 && 'value' in response) {
|
|
return response.value
|
|
}
|
|
return null
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param articleGroupCode 게시판 그룹 코드 (예: 128093)
|
|
* @param options 옵션 객체
|
|
* @returns 게시판 글 목록 응답
|
|
*/
|
|
const getCwmsArticleData = async (
|
|
articleGroupCode: string,
|
|
articleGroupSeq: number,
|
|
params: getCwmsArticleDataParams
|
|
): Promise<CwmsArticleData | null> => {
|
|
const {
|
|
lang,
|
|
sortTypeCode,
|
|
interactionTypeCodes,
|
|
handleCode,
|
|
contentYn,
|
|
summaryYn,
|
|
headlineTitleYn,
|
|
translationYn,
|
|
page,
|
|
size,
|
|
} = params
|
|
|
|
const config = useRuntimeConfig()
|
|
const stoveApiBaseUrl = config.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 CwmsArticleDataResponse | null
|
|
|
|
if (response?.code === 0 && 'value' in response) {
|
|
return response.value
|
|
}
|
|
return null
|
|
}
|
|
|
|
return {
|
|
getOperateResourcesData,
|
|
getCwmsArticleData,
|
|
}
|
|
}
|