51 lines
1.6 KiB
TypeScript

import { NextResponse } from 'next/server'
import axios from 'axios'
import { CommonCode } from '@/types/Inquiry'
import { loggerWrapper } from '@/libs/api-wrapper'
/**
* @api {GET} /api/qna 문의 유형 목록 조회 API
* @apiName GET /api/qna
* @apiGroup Qna
* @apiDescription 문의 유형 목록 조회 API
*
* @apiSuccess {Object} data 문의 유형 목록
* @apiSuccess {String} data.headCd 문의 유형 헤드 코드
* @apiSuccess {String} data.code 문의 유형 코드
* @apiSuccess {String} data.codeJp 문의 유형 이름 - 일본어
* @apiSuccess {String} data.refChr1 문의 유형 참조 - 유형 상위 구분
*
* @apiExample {curl} Example usage:
* curl -X GET http://localhost:3000/api/qna
*
* @apiSuccessExample {json} Success-Response:
* {
* "data": [
* {
* "headCd": "204200",
* "code": "1",
* "codeJp": "1",
* "refChr1": "1"
* }
* ],
* ...
* }
*/
async function getCommonCodeListData(request: Request): Promise<NextResponse> {
const response = await axios.get(`${process.env.NEXT_PUBLIC_INQUIRY_API_URL}/api/system/commonCodeListData`)
const codeList: CommonCode[] = []
response.data.data.apiCommCdList.forEach((item: any) => {
if (item.headCd === '204200' || item.headCd === '204300' || item.headCd === '204400') {
codeList.push({
headCd: item.headCd,
code: item.code,
name: item.codeJp,
refChar1: item.refChr1,
})
}
})
return NextResponse.json({ data: codeList })
}
export const GET = loggerWrapper(getCommonCodeListData)