This commit is contained in:
fro1991
2026-01-02 21:55:16 +07:00
parent 553d77b3e1
commit a2571781d9
3 changed files with 179 additions and 192 deletions

View File

@ -1,13 +1,4 @@
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
DeleteDateColumn,
ManyToOne,
JoinColumn,
} from "typeorm";
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, ManyToOne, JoinColumn } from "typeorm";
import { Status } from "../../types/status";
import { HrmsAirport } from "./hrms_airport";
import { HrmsDepartment } from "./hrms_department";
@ -21,166 +12,165 @@ import { Munisipo } from "../munisipo";
@Entity("hrms_employees", { schema: "hrms" })
export class HrmsEmployee {
@PrimaryGeneratedColumn("uuid")
id: string;
@PrimaryGeneratedColumn("uuid")
id: string;
@Column({ length: 32, unique: true })
employee_id: string;
@Column({ length: 32, unique: true })
employee_id: string;
@Column({ length: 32, unique: true })
device_user_id: string;
@Column({ length: 32, unique: true })
device_user_id: string;
@Column({ length: 128 })
name: string;
@Column({ length: 128 })
name: string;
@Column({ length: 64 })
place_birth: string;
@Column({ length: 64 })
place_birth: string;
@Column({ type: "date" })
birth_date: Date;
@Column({ type: "date" })
birth_date: Date;
@Column({ length: 16 })
gender: string;
@Column({ length: 16 })
gender: string;
@Column({ length: 32 })
phone: string;
@Column({ length: 32 })
phone: string;
@Column({ length: 128 })
email: string;
@Column({ length: 128 })
email: string;
@ManyToOne(() => Nationality)
@JoinColumn({ name: "nationality_id" })
nationality: Nationality;
@ManyToOne(() => Nationality)
@JoinColumn({ name: "nationality_id" })
nationality: Nationality;
@Column({ length: 64 })
last_education: string;
@Column({ length: 64 })
last_education: string;
@Column({ nullable: true, length: 256 })
photo_url: string;
@Column({ nullable: true, length: 256 })
photo_url: string;
@Column({ nullable: true, length: 512 })
employee_file_url: string;
@Column({ nullable: true, length: 512 })
employee_file_url: string;
@ManyToOne(() => Aldeia)
@JoinColumn({ name: "aldeia_id" })
aldeia: Aldeia;
@ManyToOne(() => Aldeia)
@JoinColumn({ name: "aldeia_id" })
aldeia: Aldeia;
@ManyToOne(() => Suco)
@JoinColumn({ name: "suco_id" })
suco: Suco;
@ManyToOne(() => Suco)
@JoinColumn({ name: "suco_id" })
suco: Suco;
@ManyToOne(() => Administrativu)
@JoinColumn({ name: "administrativu_id" })
administrativu: Administrativu;
@ManyToOne(() => Administrativu)
@JoinColumn({ name: "administrativu_id" })
administrativu: Administrativu;
@ManyToOne(() => Munisipo)
@JoinColumn({ name: "munisipo_id" })
munisipo: Munisipo;
@ManyToOne(() => Munisipo)
@JoinColumn({ name: "munisipo_id" })
munisipo: Munisipo;
@Column({ length: 256 })
street: string;
@Column({ length: 256 })
street: string;
@ManyToOne(() => HrmsAirport)
@JoinColumn({ name: "airport_id" })
airport: HrmsAirport;
@ManyToOne(() => HrmsAirport)
@JoinColumn({ name: "airport_id" })
airport: HrmsAirport;
@ManyToOne(() => HrmsDepartment)
@JoinColumn({ name: "department_id" })
department: HrmsDepartment;
@ManyToOne(() => HrmsDepartment)
@JoinColumn({ name: "department_id" })
department: HrmsDepartment;
@ManyToOne(() => HrmsPosition)
@JoinColumn({ name: "position_id" })
position: HrmsPosition;
@ManyToOne(() => HrmsPosition)
@JoinColumn({ name: "position_id" })
position: HrmsPosition;
@ManyToOne(() => HrmsShift)
@JoinColumn({ name: "shift_id" })
shift: HrmsShift;
@ManyToOne(() => HrmsShift)
@JoinColumn({ name: "shift_id" })
shift: HrmsShift;
@Column({ type: "int" })
yearly_leave_quota: number;
@Column({ type: "int" })
yearly_leave_quota: number;
@Column({ length: 128 })
emergency_name: string;
@Column({ length: 128 })
emergency_name: string;
@Column({ length: 32 })
emergency_phone: string;
@Column({ length: 32 })
emergency_phone: string;
@Column({ length: 64 })
emergency_relation: string;
@Column({ length: 64 })
emergency_relation: string;
@Column({ length: 128, nullable: true })
electoral_number: string;
@Column({ length: 128, nullable: true })
electoral_number: string;
@Column({ type: "date", nullable: true })
electoral_expired_at: Date;
@Column({ type: "date", nullable: true })
electoral_expired_at: Date;
@Column({ length: 256, nullable: true })
electoral_file_url: string;
@Column({ length: 256, nullable: true })
electoral_file_url: string;
@Column({ length: 128, nullable: true })
bi_number: string;
@Column({ length: 128, nullable: true })
bi_number: string;
@Column({ type: "date", nullable: true })
bi_expired_at: Date;
@Column({ type: "date", nullable: true })
bi_expired_at: Date;
@Column({ length: 256, nullable: true })
bi_file_url: string;
@Column({ length: 256, nullable: true })
bi_file_url: string;
@Column({ length: 128, nullable: true })
niss_number: string;
@Column({ length: 128, nullable: true })
niss_number: string;
@Column({ type: "date", nullable: true })
niss_expired_at: Date;
@Column({ type: "date", nullable: true })
niss_expired_at: Date;
@Column({ length: 256, nullable: true })
niss_file_url: string;
@Column({ length: 256, nullable: true })
niss_file_url: string;
@Column({ length: 128, nullable: true })
passport_number: string;
@Column({ length: 128, nullable: true })
passport_number: string;
@Column({ type: "date", nullable: true })
passport_expired_at: Date;
@Column({ type: "date", nullable: true })
passport_expired_at: Date;
@Column({ length: 256, nullable: true })
passport_file_url: string;
@Column({ length: 256, nullable: true })
passport_file_url: string;
@Column({ length: 128, nullable: true })
visa_number: string;
@Column({ length: 128, nullable: true })
visa_number: string;
@Column({ type: "date", nullable: true })
visa_expired_at: Date;
@Column({ type: "date", nullable: true })
visa_expired_at: Date;
@Column({ length: 256, nullable: true })
visa_file_url: string;
@Column({ length: 256, nullable: true })
visa_file_url: string;
@Column({ length: 128, nullable: true })
pr_number: string;
@Column({ length: 128, nullable: true })
pr_number: string;
@Column({ type: "date", nullable: true })
pr_expired_at: Date;
@Column({ type: "date", nullable: true })
pr_expired_at: Date;
@Column({ length: 256, nullable: true })
pr_file_url: string;
@Column({ length: 256, nullable: true })
pr_file_url: string;
@Column({ length: 64 })
status: Status;
@Column({ length: 64 })
status: Status;
@CreateDateColumn()
created_at: Date;
@CreateDateColumn()
created_at: Date;
@Column({ nullable: true, length: 256 })
created_by: string;
@Column({ nullable: true, length: 256 })
created_by: string;
@UpdateDateColumn({ nullable: true })
updated_at: Date;
@UpdateDateColumn({ nullable: true })
updated_at: Date;
@Column({ nullable: true, length: 256 })
updated_by: string;
@Column({ nullable: true, length: 256 })
updated_by: string;
@DeleteDateColumn({ nullable: true })
deleted_at: Date;
@DeleteDateColumn({ nullable: true })
deleted_at: Date;
@Column({ nullable: true, length: 256 })
deleted_by: string;
@Column({ nullable: true, length: 256 })
deleted_by: string;
}

View File

@ -1,7 +1,6 @@
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index, ManyToOne, JoinColumn } from "typeorm";
import { Column, CreateDateColumn, DeleteDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
import { Status } from "../../types/status";
import { HrmsEmployee } from "./hrms_employee";
@Entity("hrms_scholarships", { schema: "hrms" })
export class HrmsScholarship {

View File

@ -1,84 +1,82 @@
import bcrypt from 'bcryptjs';
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index, OneToOne, JoinColumn, ManyToOne, OneToMany, ManyToMany, JoinTable } from 'typeorm';
import bcrypt from "bcryptjs";
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index, OneToOne, JoinColumn, ManyToOne, OneToMany, ManyToMany, JoinTable } from "typeorm";
import { Status } from '../types/status';
import { UserRole } from './users_roles';
import { Status } from "../types/status";
import { UserRole } from "./users_roles";
import { HrmsEmployee } from "./hrms/hrms_employee";
@Entity('users')
@Entity("users")
export class User {
@PrimaryGeneratedColumn('uuid')
id: string;
@PrimaryGeneratedColumn("uuid")
id: string;
@Column({
nullable: false,
unique: true,
length: 64
})
email: string;
@Column({
nullable: false,
unique: true,
length: 64,
})
email: string;
@Column({
nullable: true,
unique: false,
length: 64
})
employee_id: string;
@ManyToOne(() => HrmsEmployee, { onDelete: "NO ACTION", nullable: true })
@JoinTable()
employee: HrmsEmployee;
@Column({
nullable: false,
length: 64,
select: false
})
password: string;
@Column({
nullable: false,
length: 64,
select: false,
})
password: string;
@Column({
nullable: false,
unique: true,
length: 64
})
username: string;
@Column({
nullable: false,
unique: true,
length: 64,
})
username: string;
@Column({
nullable: true,
length: 64,
unique: false,
})
name: string;
@Column({
nullable: true,
length: 64,
unique: false,
})
name: string;
@ManyToMany(() => UserRole, { onDelete: 'CASCADE' })
@JoinTable()
roles: UserRole[]
@ManyToMany(() => UserRole, { onDelete: "CASCADE" })
@JoinTable()
roles: UserRole[];
@Index()
@Column({
nullable: true,
type: 'uuid',
select: false
})
reset_token: string;
@Index()
@Column({
nullable: true,
type: "uuid",
select: false,
})
reset_token: string;
@Column({
nullable: false,
length: 64
})
status: Status;
@Column({
nullable: false,
length: 64,
})
status: Status;
@Column()
@CreateDateColumn()
created_at: Date;
@Column()
@CreateDateColumn()
created_at: Date;
@Column({ nullable: true })
@UpdateDateColumn()
updated_at: Date;
@Column({ nullable: true })
@UpdateDateColumn()
updated_at: Date;
@Column({ nullable: true })
@DeleteDateColumn()
deleted_at: Date;
@Column({ nullable: true })
@DeleteDateColumn()
deleted_at: Date;
hashPassword() {
this.password = bcrypt.hashSync(this.password, 8);
}
hashPassword() {
this.password = bcrypt.hashSync(this.password, 8);
}
checkIfPasswordMatch(unencryptedPassword: string) {
return bcrypt.compareSync(unencryptedPassword, this.password);
}
checkIfPasswordMatch(unencryptedPassword: string) {
return bcrypt.compareSync(unencryptedPassword, this.password);
}
}