This commit is contained in:
Narul Hidayah
2026-01-02 23:26:20 +07:00
7 changed files with 590 additions and 557 deletions

View File

@ -1,6 +1,10 @@
import axios from "axios"
import config from "config"
<<<<<<< HEAD
import { Paging, User, UserRefreshToken, UserRole, HrmsEmployee } from "entity"
=======
import { HrmsEmployee, Paging, User, UserRefreshToken, UserRole } from "entity"
>>>>>>> f562ccf38baffaa1cb6caf8a196127fe2512c7e4
import exceljs from "exceljs"
import { NextFunction, Response } from "express"
import { Request } from "express-jwt"
@ -247,7 +251,7 @@ export class UserController {
password: Joi.string().pattern(new RegExp("^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$")).min(8).required().label("Password"),
retype_password: Joi.ref("password"),
name: Joi.string().max(64).required().label("Name"),
employee_id: Joi.string().max(64).optional().allow("").label("Employee ID"),
employee_id: Joi.string().uuid().optional().allow("").label("Employee ID"),
status: Joi.string().required().label("Status"),
})
@ -260,9 +264,8 @@ export class UserController {
data.email = param.email
data.status = param.status
if (param.employee_id && param.employee_id != "") {
const employee = await OrmHelper.DB.manager.getRepository(HrmsEmployee).findOneByOrFail({ id: param.employee_id })
data.employee = employee
if (param.employee && param.employee.id! + "") {
data.employee = param.employee
}
data.hashPassword()
@ -572,7 +575,7 @@ export class UserController {
password: Joi.string().allow("").optional().label("Password"),
retype_password: Joi.ref("password"),
name: Joi.string().max(64).required().label("Name"),
employee_id: Joi.string().max(64).optional().allow("").label("Employee ID"),
employee_id: Joi.string().uuid().optional().allow("").label("Employee ID"),
status: Joi.string().required().label("Status"),
})
@ -586,15 +589,13 @@ export class UserController {
if (data != null) {
data.name = param.name
data.employee = param.employee
data.username = param.username
data.email = param.email
data.status = param.status
if (param.employee_id && param.employee_id != "") {
const employee = await OrmHelper.DB.manager.getRepository(HrmsEmployee).findOneByOrFail({ id: param.employee_id })
data.employee = employee
} else {
data.employee = null
if (param.employee && param.employee.id != "") {
data.employee = param.employee
}
if (param.password) {