This commit is contained in:
2026-01-04 20:58:47 +09:00
parent a87c11597a
commit 0660ed3973
37 changed files with 1723 additions and 885 deletions

View File

@@ -1,20 +1,24 @@
import { insertReturning, queryOne } from '../../utils/db'
import { getClientIp } from '../../utils/ip'
import { getCurrentUserEmail } from '../../utils/user'
interface CreateEmployeeBody {
employeeNumber?: string
employeeName: string
employeeEmail: string
employeePhone?: string
employeePosition?: string
company?: string
joinDate?: string
}
/**
* 원 등록
* 원 등록
* POST /api/employee/create
*/
export default defineEventHandler(async (event) => {
const body = await readBody<CreateEmployeeBody>(event)
const clientIp = getClientIp(event)
const userEmail = await getCurrentUserEmail(event)
if (!body.employeeName || !body.employeeEmail) {
throw createError({ statusCode: 400, message: '이름과 이메일은 필수입니다.' })
@@ -31,17 +35,20 @@ export default defineEventHandler(async (event) => {
const employee = await insertReturning(`
INSERT INTO wr_employee_info (
employee_number, employee_name, employee_email,
employee_phone, employee_position, join_date
) VALUES ($1, $2, $3, $4, $5, $6)
employee_name, employee_email, employee_phone,
employee_position, company, join_date,
created_ip, created_email, updated_ip, updated_email
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $7, $8)
RETURNING *
`, [
body.employeeNumber || null,
body.employeeName,
body.employeeEmail.toLowerCase(),
body.employeePhone || null,
body.employeePosition || null,
body.joinDate || null
body.company || '(주)터보소프트',
body.joinDate || null,
clientIp,
userEmail
])
return {