feat: 점검 작업 중
This commit is contained in:
97
layers/composables/useGetGameMaintenance.ts
Normal file
97
layers/composables/useGetGameMaintenance.ts
Normal file
@@ -0,0 +1,97 @@
|
||||
import type { ReqGameMaintenance, ResGameMaintenance } from '#layers/types/GameMaintenanceType'
|
||||
|
||||
/**
|
||||
* 게임 점검
|
||||
*/
|
||||
const useGetGameMaintenance = () => {
|
||||
const inspectionStore = useInspectionStore()
|
||||
const logPrefix = {
|
||||
exception: '[Exception] /composables/useGetGameMaintenance',
|
||||
failure: '[Failure] /composables/useGetGameMaintenance'
|
||||
}
|
||||
const isGameMaintenance = ref(false) // 게임 서버 점검 여부
|
||||
|
||||
// [Setter] 게임 서버 점검 여부 세팅
|
||||
const setIsGameMaintenance = (status: boolean) => {
|
||||
isGameMaintenance.value = status
|
||||
}
|
||||
|
||||
// 게임 점검이 아닌 경우 일괄 세팅
|
||||
const setGameMaintenanceFalse = () => {
|
||||
setIsGameMaintenance(false)
|
||||
inspectionStore.setGameMaintenanceStatus(false)
|
||||
inspectionStore.setGameMaintenanceData({ ts_start_date: 0, ts_end_date: 0, detail_link: '' })
|
||||
}
|
||||
|
||||
/**
|
||||
* 게임 서버 점검 여부
|
||||
*
|
||||
* @param {ReqGameMaintenance} req
|
||||
* @description https://wiki.smilegate.net/pages/viewpage.action?pageId=362619887
|
||||
*/
|
||||
const checkGameMaintenance = async (req: ReqGameMaintenance) => {
|
||||
let res: ResGameMaintenance = {} as ResGameMaintenance
|
||||
try {
|
||||
const baseApiUrl = req.baseApiUrl || ''
|
||||
|
||||
// Path Variables
|
||||
const category = req.category || 'GAME'
|
||||
const serviceId1 = req.service_id1 || ''
|
||||
const lang = req.lang || 'ko'
|
||||
|
||||
const url = `${baseApiUrl}/v2.0/maintenances/${category}/${serviceId1}/${lang}`
|
||||
|
||||
res = (await commonFetch('GET', url, {})) as ResGameMaintenance
|
||||
|
||||
if (res != null && res.code === 0) {
|
||||
// FIXME: 테스트용 데이터 ---------------------------------------------------
|
||||
/* const config = useRuntimeConfig()
|
||||
if (['local', 'local-gate8', 'dev'].includes(`${config.public.runType}`)) {
|
||||
res.value = {
|
||||
total_count: 1,
|
||||
list: [
|
||||
{
|
||||
start_at: new Date().getTime(),
|
||||
end_at: new Date().getTime(),
|
||||
languages: [{ link: 'https://www.onstove.com', lang: 'ko', title: '', content: '' }],
|
||||
maintenance_no: 0,
|
||||
category: '',
|
||||
service_id1: '',
|
||||
service_id2: [],
|
||||
type: '',
|
||||
description: ''
|
||||
}
|
||||
]
|
||||
}
|
||||
} */
|
||||
// ------------------------------------------------------------------------
|
||||
if (Number(res.value?.total_count) > 0 && res.value?.list != null && res.value?.list.length > 0) {
|
||||
setIsGameMaintenance(true) // 서버 1개 이상 점검일 경우 점검 중으로 간주
|
||||
inspectionStore.setGameMaintenanceData({
|
||||
ts_start_date: res.value?.list[0].start_at || 0,
|
||||
ts_end_date: res.value?.list[0].end_at || 0,
|
||||
detail_link: res.value?.list[0].languages[0].link || ''
|
||||
})
|
||||
inspectionStore.setGameMaintenanceStatus(true)
|
||||
} else {
|
||||
setGameMaintenanceFalse()
|
||||
}
|
||||
} else {
|
||||
// [500] 내부 서버 에러
|
||||
// [70001] 부적절한 엑세스 토큰
|
||||
// [70051] 부적절한 파라미터 요청 - {param_key}
|
||||
// [70052] 데이터를 찾을 수 않음
|
||||
setGameMaintenanceFalse()
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(`${logPrefix.exception}.checkGameMaintenance: `, e)
|
||||
res = { code: -99999, message: `${e}` }
|
||||
setGameMaintenanceFalse()
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
return { isGameMaintenance, checkGameMaintenance }
|
||||
}
|
||||
|
||||
export { useGetGameMaintenance }
|
||||
69
layers/composables/useGetInspectionDataExternal.ts
Normal file
69
layers/composables/useGetInspectionDataExternal.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import type { WebInspectionData, ReqGetInspectionData, ResGetInspectionData } from '#layers/types/InspectionType'
|
||||
|
||||
/**
|
||||
* 웹 점검
|
||||
*/
|
||||
export const useGetInspectionDataExternal = () => {
|
||||
const inspectionStore = useInspectionStore()
|
||||
const logPrefix = {
|
||||
exception: '[Exception] /composables/useGetInspectionDataExternal',
|
||||
failure: '[Failure] /composables/useGetInspectionDataExternal'
|
||||
}
|
||||
const webInspectionData = ref<WebInspectionData | null>(null)
|
||||
const isWebInspection = ref(false) // 웹 점검 여부
|
||||
|
||||
// [Setter] 웹 점검 여부 세팅
|
||||
const setIsWebInspection = (status: boolean) => {
|
||||
isWebInspection.value = status
|
||||
}
|
||||
|
||||
/**
|
||||
* 웹 점검 여부
|
||||
*
|
||||
* @param {ReqGetInspectionData} req
|
||||
* @description https://wiki.smilegate.net/pages/viewpage.action?pageId=563198067
|
||||
*/
|
||||
const getInspectionDataExternal = async (req: ReqGetInspectionData) => {
|
||||
// const config = useRuntimeConfig()
|
||||
const apiUrl = `${req.baseApiUrl}/pub-comm/v3.0/inspection/${req.gameId}`
|
||||
|
||||
try {
|
||||
const response = (await commonFetch('GET', apiUrl)) as ResGetInspectionData
|
||||
|
||||
// FIXME: 테스트용 데이터 ---------------------------------------------------
|
||||
/* if (['local', 'local-gate8', 'dev'].includes(`${config.public.runType}`)) {
|
||||
response.value = {
|
||||
inspection_status: 1,
|
||||
inspection: {
|
||||
inspection_status: 1,
|
||||
start_date: '2025-09-19 10:00:00',
|
||||
end_date: '2025-09-19 12:00:00',
|
||||
ts_start_date: new Date().getTime(),
|
||||
ts_end_date: new Date().getTime(),
|
||||
back_ground_image_type: 'image',
|
||||
back_ground_image_url: 'https://www.onstove.com',
|
||||
inspection_title1: '',
|
||||
inspection_title2: ''
|
||||
}
|
||||
}
|
||||
} */
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if (response?.value && response.value.inspection) {
|
||||
webInspectionData.value = response.value.inspection
|
||||
isWebInspection.value = response.value.inspection_status === 1
|
||||
|
||||
inspectionStore.setWebInspectionData(webInspectionData.value)
|
||||
inspectionStore.setWebInspectionStatus(isWebInspection.value)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(`${logPrefix.exception}.getInspectionDataExternal: `, e)
|
||||
}
|
||||
|
||||
if (webInspectionData.value !== null) {
|
||||
setIsWebInspection(isWebInspection.value)
|
||||
}
|
||||
}
|
||||
|
||||
return { webInspectionData, isWebInspection, getInspectionDataExternal }
|
||||
}
|
||||
Reference in New Issue
Block a user