추가
This commit is contained in:
30
backend/api/employee/list.get.ts
Normal file
30
backend/api/employee/list.get.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { query } from '../../utils/db'
|
||||
|
||||
/**
|
||||
* 사원 목록 조회
|
||||
* GET /api/employee/list
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const queryParams = getQuery(event)
|
||||
const activeOnly = queryParams.activeOnly !== 'false'
|
||||
|
||||
let sql = `
|
||||
SELECT * FROM wr_employee_info
|
||||
${activeOnly ? 'WHERE is_active = true' : ''}
|
||||
ORDER BY employee_name
|
||||
`
|
||||
|
||||
const employees = await query(sql)
|
||||
|
||||
return employees.map((e: any) => ({
|
||||
employeeId: e.employee_id,
|
||||
employeeNumber: e.employee_number,
|
||||
employeeName: e.employee_name,
|
||||
employeeEmail: e.employee_email,
|
||||
employeePhone: e.employee_phone,
|
||||
employeePosition: e.employee_position,
|
||||
joinDate: e.join_date,
|
||||
isActive: e.is_active,
|
||||
createdAt: e.created_at
|
||||
}))
|
||||
})
|
||||
Reference in New Issue
Block a user