44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { queryOne } from '../../utils/db'
|
|
|
|
/**
|
|
* 로그인된 사용자 정보 조회
|
|
* GET /api/auth/me
|
|
*/
|
|
export default defineEventHandler(async (event) => {
|
|
const userId = getCookie(event, 'user_id')
|
|
if (!userId) {
|
|
throw createError({ statusCode: 401, message: '로그인이 필요합니다.' })
|
|
}
|
|
|
|
const employee = await queryOne<any>(`
|
|
SELECT
|
|
employee_id,
|
|
employee_name,
|
|
employee_email,
|
|
employee_phone,
|
|
employee_position,
|
|
company,
|
|
join_date,
|
|
is_active
|
|
FROM wr_employee_info
|
|
WHERE employee_id = $1
|
|
`, [userId])
|
|
|
|
if (!employee) {
|
|
throw createError({ statusCode: 404, message: '사용자를 찾을 수 없습니다.' })
|
|
}
|
|
|
|
return {
|
|
user: {
|
|
employeeId: employee.employee_id,
|
|
employeeName: employee.employee_name,
|
|
employeeEmail: employee.employee_email,
|
|
employeePhone: employee.employee_phone,
|
|
employeePosition: employee.employee_position,
|
|
company: employee.company,
|
|
joinDate: employee.join_date,
|
|
isActive: employee.is_active
|
|
}
|
|
}
|
|
})
|