diff --git a/src/modules/configuration/otp-verification/data/models/otp-verification.model.ts b/src/modules/configuration/otp-verification/data/models/otp-verification.model.ts index 22032aa..eec21fb 100644 --- a/src/modules/configuration/otp-verification/data/models/otp-verification.model.ts +++ b/src/modules/configuration/otp-verification/data/models/otp-verification.model.ts @@ -1,6 +1,6 @@ import { TABLE_NAME } from 'src/core/strings/constants/table.constants'; import { - OPT_ACTION_TYPE, + OTP_ACTION_TYPE, OTP_SOURCE, OtpVerificationEntity, } from '../../domain/entities/otp-verification.entity'; @@ -15,8 +15,8 @@ export class OtpVerificationModel @Column({ type: 'varchar', nullable: false }) otp_code: string; - @Column({ type: 'enum', enum: OPT_ACTION_TYPE }) - action_type: OPT_ACTION_TYPE; + @Column({ type: 'enum', enum: OTP_ACTION_TYPE }) + action_type: OTP_ACTION_TYPE; @Column({ type: 'varchar', nullable: true }) target_id: string; diff --git a/src/modules/configuration/otp-verification/data/services/otp-verification.service.ts b/src/modules/configuration/otp-verification/data/services/otp-verification.service.ts index 12c5c09..a5b8d7c 100644 --- a/src/modules/configuration/otp-verification/data/services/otp-verification.service.ts +++ b/src/modules/configuration/otp-verification/data/services/otp-verification.service.ts @@ -35,18 +35,16 @@ export class OtpVerificationService { const otpCode = otpService.generateSecureOTP(); const dateNow = this.generateTimestamp(); const expiredAt = this.generateOtpExpiration(); - const source = OTP_SOURCE.WEB; - const creator = { - id: 'c59f811e-873c-4472-bd58-21c111902114', - name: 'dev', - }; + + //TODO implementation from auth + const creator = { id: null, name: null }; const newOtp: OtpVerificationEntity = { otp_code: otpCode, action_type: payload.action_type, target_id: payload.target_id, reference: payload.reference, - source: source, + source: payload.source, is_used: false, is_replaced: false, expired_at: expiredAt, diff --git a/src/modules/configuration/otp-verification/domain/entities/otp-verification.entity.ts b/src/modules/configuration/otp-verification/domain/entities/otp-verification.entity.ts index 78e8c68..3d0dc5a 100644 --- a/src/modules/configuration/otp-verification/domain/entities/otp-verification.entity.ts +++ b/src/modules/configuration/otp-verification/domain/entities/otp-verification.entity.ts @@ -1,6 +1,6 @@ import { BaseEntity } from 'src/core/modules/domain/entities//base.entity'; -export enum OPT_ACTION_TYPE { +export enum OTP_ACTION_TYPE { CREATE_DISCOUNT = 'CREATE_DISCOUNT', CANCEL_TRANSACTION = 'CANCEL_TRANSACTION', } @@ -12,7 +12,7 @@ export enum OTP_SOURCE { export interface OtpVerificationEntity extends BaseEntity { otp_code: string; - action_type: OPT_ACTION_TYPE; + action_type: OTP_ACTION_TYPE; target_id: string; reference: string; source: OTP_SOURCE; @@ -23,7 +23,8 @@ export interface OtpVerificationEntity extends BaseEntity { } export interface OtpRequestEntity { - action_type: OPT_ACTION_TYPE; + action_type: OTP_ACTION_TYPE; + source: OTP_SOURCE; target_id: string; reference: string; } diff --git a/src/modules/configuration/otp-verification/infrastructure/dto/otp-verification.dto.ts b/src/modules/configuration/otp-verification/infrastructure/dto/otp-verification.dto.ts index 34786d2..cfd0097 100644 --- a/src/modules/configuration/otp-verification/infrastructure/dto/otp-verification.dto.ts +++ b/src/modules/configuration/otp-verification/infrastructure/dto/otp-verification.dto.ts @@ -1,6 +1,7 @@ import { IsNotEmpty, IsString, ValidateIf } from 'class-validator'; import { - OPT_ACTION_TYPE, + OTP_ACTION_TYPE, + OTP_SOURCE, OtpRequestEntity, OtpVerifyEntity, } from '../../domain/entities/otp-verification.entity'; @@ -10,12 +11,22 @@ export class OtpRequestDto implements OtpRequestEntity { @ApiProperty({ type: String, required: true, - example: OPT_ACTION_TYPE.CANCEL_TRANSACTION, + example: OTP_ACTION_TYPE.CANCEL_TRANSACTION, description: 'CANCEL_TRANSACTION || CREATE_DISCOUNT', }) @IsString() @IsNotEmpty() - action_type: OPT_ACTION_TYPE; + action_type: OTP_ACTION_TYPE; + + @ApiProperty({ + type: String, + required: true, + example: OTP_SOURCE.POS, + description: 'POS || WEB', + }) + @IsString() + @IsNotEmpty() + source: OTP_SOURCE; @ApiProperty({ name: 'target_id', diff --git a/src/modules/configuration/otp-verification/infrastructure/otp-verification-data.controller.ts b/src/modules/configuration/otp-verification/infrastructure/otp-verification-data.controller.ts index 0eb5957..783f109 100644 --- a/src/modules/configuration/otp-verification/infrastructure/otp-verification-data.controller.ts +++ b/src/modules/configuration/otp-verification/infrastructure/otp-verification-data.controller.ts @@ -5,6 +5,7 @@ import { MODULE_NAME } from 'src/core/strings/constants/module.constants'; import { OtpVerificationService } from '../data/services/otp-verification.service'; import { OtpRequestDto, OtpVerifyDto } from './dto/otp-verification.dto'; +//TODO implementation auth @ApiTags(`${MODULE_NAME.OTP_VERIFICATIONS.split('-').join(' ')} - data`) @Controller(`v1/${MODULE_NAME.OTP_VERIFICATIONS}`) @Public()