feat: setup module otp verifications

pull/144/head
Firman Ramdhani 2025-06-04 09:48:10 +07:00
parent 5e328fda1e
commit 5f08b4be66
12 changed files with 58 additions and 0 deletions

View File

@ -30,4 +30,5 @@ export enum MODULE_NAME {
QUEUE = 'queue',
TIME_GROUPS = 'time-groups',
OTP_VERIFICATIONS = 'otp-verification',
}

View File

@ -45,4 +45,5 @@ export enum TABLE_NAME {
QUEUE_BUCKET = 'queue_bucket',
TIME_GROUPS = 'time_groups',
OTP_VERIFICATIONS = 'otp_verifications',
}

View File

@ -0,0 +1,35 @@
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
import {
OPT_ACTION_TYPE,
OTP_SOURCE,
OtpVerificationEntity,
} from '../../domain/entities/otp-verification.entity';
import { Column, Entity } from 'typeorm';
import { BaseModel } from 'src/core/modules/data/model/base.model';
@Entity(TABLE_NAME.OTP_VERIFICATIONS)
export class OtpVerificationModel
extends BaseModel<OtpVerificationEntity>
implements OtpVerificationEntity
{
@Column({ type: 'varchar', nullable: false })
otp_code: string;
@Column({ type: 'enum', enum: OPT_ACTION_TYPE })
action_type: OPT_ACTION_TYPE;
@Column({ type: 'varchar', nullable: true })
target_id: string;
@Column({ type: 'enum', enum: OTP_SOURCE })
source: OTP_SOURCE;
@Column({ default: false })
is_used: boolean;
@Column({ type: 'bigint', nullable: false })
expired_at: number; // UNIX timestamp
@Column({ type: 'bigint', nullable: true })
verified_at: number; // UNIX timestamp or null
}

View File

@ -0,0 +1,21 @@
import { BaseEntity } from 'src/core/modules/domain/entities//base.entity';
export enum OPT_ACTION_TYPE {
CREATE_DISCOUNT = 'CREATE_DISCOUNT',
CANCEL_TRANSACTION = 'CANCEL_TRANSACTION',
}
export enum OTP_SOURCE {
POS = 'POS',
WEB = 'WEB',
}
export interface OtpVerificationEntity extends BaseEntity {
otp_code: string;
action_type: OPT_ACTION_TYPE;
target_id: string;
source: OTP_SOURCE;
is_used: boolean;
expired_at: number;
verified_at: number;
}