Compare commits

..

2 Commits

Author SHA1 Message Date
harshithnrao
1d40b6544a swagger in config
and update entity
2025-03-03 13:33:12 +05:30
harshithnrao
66391a2ab2 swagger for controllers 2025-03-02 21:04:40 +05:30
25 changed files with 3396 additions and 5188 deletions

6735
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
{
"name": "abnandan-skeleton-be",
"name": "remedify-payment-microservice",
"version": "0.0.1",
"description": "",
"author": "",
@ -23,11 +23,11 @@
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@nestjs-modules/mailer": "^1.10.3",
"@nestjs/common": "^10.0.0",
"@nestjs/config": "^3.1.1",
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/swagger": "^8.1.1",
"@nestjs/typeorm": "^10.0.1",
"dotenv": "^16.3.1",
"handlebars": "^4.7.8",

View File

@ -41,4 +41,8 @@ export class AppConfigService {
getMailConfig() {
return configMaster[this.defaultEnv].mailConfig;
}
getSwaggerConfig() {
return configMaster[this.defaultEnv].swaggerConfig;
}
}

View File

@ -29,6 +29,13 @@
"defaults": {
"from": "\"No Reply\" <admin@wct.co.in>"
}
},
"swaggerConfig": {
"swagger": {
"title": "Remedify Payment API",
"description": "Remedify Payment API",
"version": "1.0.0"
}
}
}
}

View File

@ -29,6 +29,14 @@
"defaults": {
"from": "\"No Reply\" <admin@wct.co.in>"
}
},
"swaggerConfig": {
"swagger": {
"title": "Remedify Payment API",
"description": "Remedify Payment API",
"version": "1.0.0",
"tag": "Remedify Payment API"
}
}
}
}

View File

@ -30,8 +30,8 @@ import { RefundsModule } from './refund/refund.module';
QuoteModule,
RefundsModule,
DataModule,
MailModule,
MasterConfigModule,
// MailModule,
// MasterConfigModule,
ConfigModule,
],
controllers: [AppController, AppConfigController],

View File

@ -41,6 +41,10 @@ export class AppService {
const emailConfig = this.configService.getMailConfig();
this.commonService.mailConfig = emailConfig;
Utility.mailConfig = emailConfig;
const swaggerConfig = this.configService.getSwaggerConfig();
this.commonService.swaggerConfig = swaggerConfig;
Utility.swaggerConfig = swaggerConfig;
}
getModels() {

View File

@ -4,7 +4,8 @@ export class Utility {
static sequelize: Sequelize;
static appPort: number = 3000;
static models: any;
static fileConfig: any = {"storagePath": "./uploads"};
static fileConfig: any = { "storagePath": "./uploads" };
static swaggerConfig: any;
static mailConfig: any = {
"transport": {
"host": "smtppro.zoho.in",

View File

@ -7,6 +7,7 @@ export class CommonService {
models: any;
fileConfig: any;
mailConfig: any;
swaggerConfig: any;
constructor() {
}

View File

@ -1,29 +1,36 @@
import { Table, Column, Model, Default, DataType } from 'sequelize-typescript';
import { ApiProperty } from '@nestjs/swagger';
@Table({tableName: 'crud_config_info', paranoid : true})
@Table({tableName: 'crud_config_info', paranoid: true})
export default class DataModel extends Model {
@ApiProperty({ type: Number })
@Column({type: DataType.NUMBER})
endPtNm: number;
@ApiProperty({ type: String })
@Column({type: DataType.TEXT})
sqlQueryText: string;
@ApiProperty({ type: String })
@Column({type: DataType.TEXT})
opsTypeName: string;
@ApiProperty({ type: Date, default: new Date() })
@Default(new Date())
@Column({type: DataType.DATEONLY})
validFrom: Date;
@ApiProperty({ type: Date, default: new Date('2070-12-31') })
@Default(new Date("2070-12-31"))
@Column({type: DataType.DATEONLY})
validTill: Date;
@ApiProperty({ type: String })
@Column({type: DataType.TEXT})
createBy: string;
@ApiProperty({ type: String })
@Column({type: DataType.TEXT})
modifiedBy: string;
}

View File

@ -3,19 +3,81 @@ import { Response } from 'express';
import { InvoicesService } from './invoice.service';
import { GenericResponse } from 'src/common/GenericResponse.model';
import Invoice from './invoice.entity';
import { ApiTags, ApiOperation, ApiResponse, ApiParam, ApiBody } from '@nestjs/swagger';
@ApiTags('invoices')
@Controller('invoice')
export class InvoicesController {
constructor(private invoiceService: InvoicesService) { }
constructor(private invoiceService: InvoicesService) {}
@Get("/all")
@ApiOperation({ summary: 'Get all invoices' })
@ApiResponse({
status: 200,
description: 'Successfully retrieved all invoices',
})
@ApiResponse({
status: 404,
description: 'No invoices found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "No invoices found"
},
"data": null
}
})
async getAll(@Res() res: Response) {
const response = await this.invoiceService.findAll() || [];
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
const response = await this.invoiceService.findAll();
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: 'No invoices found'
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Get(':id')
@ApiOperation({ summary: 'Get invoice by ID' })
@ApiParam({ name: 'id', type: Number, description: 'Invoice ID' })
@ApiResponse({
status: 400,
description: 'ID parameter is missing',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NO_ID_IN_REQ",
"stackTrace": "Request"
},
"data": null
}
})
@ApiResponse({
status: 404,
description: 'Invoice not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Invoice not found"
},
"data": null
}
})
@ApiResponse({
status: 200,
description: 'Successfully retrieved invoice',
})
async findById(@Param('id') id: number, @Res() res: Response) {
if (!id) {
const response = new GenericResponse({
@ -24,80 +86,232 @@ export class InvoicesController {
exceptionMessage: 'ERR.NO_ID_IN_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.invoiceService.findByPk(id) || {};
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
const response = await this.invoiceService.findByPk(id);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: `Invoice with ID ${id} not found`
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Post('/filter')
async filter(@Body() user: Invoice, @Res() res: Response) {
if (!user) {
@ApiOperation({ summary: 'Filter invoices based on criteria' })
@ApiBody({ type: Invoice, description: 'Invoice filter criteria' })
@ApiResponse({
status: 404,
description: 'No invoices matching criteria found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "No invoices found matching criteria"
},
"data": null
}
})
@ApiResponse({
status: 200,
description: 'Successfully filtered invoices',
})
async filter(@Body() invoice: Invoice, @Res() res: Response) {
if (!invoice) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.invoiceService.filter(user) || [];
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
const response = await this.invoiceService.filter(invoice);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: 'No invoices found matching criteria'
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Post()
async insert(@Body() user: Invoice, @Res() res: Response) {
if (!user) {
@ApiOperation({ summary: 'Insert a new invoice' })
@ApiBody({ type: Invoice, description: 'Invoice data to insert' })
@ApiResponse({
status: 400,
description: 'Failed to insert invoice',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Invoice not created"
},
"data": null
}
})
@ApiResponse({
status: 201,
description: 'Invoice successfully created',
})
async insert(@Body() invoice: Invoice, @Res() res: Response) {
if (!invoice) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
delete user.id;
const response = await this.invoiceService.upsert(user, true);
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
delete invoice.id;
const response = await this.invoiceService.upsert(invoice, true);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_CREATED',
stackTrace: 'Invoice not created'
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(201).send(httpResponse);
}
@Put()
async update(@Body() user: Invoice, @Res() res: Response) {
if (!user || !user.id) {
@ApiOperation({ summary: 'Update an existing invoice' })
@ApiBody({ type: Invoice, description: 'Invoice data to update' })
@ApiResponse({
status: 400,
description: 'Failed to update invoice',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Invoice not updated"
},
"data": null
}
})
@ApiResponse({
status: 404,
description: 'Invoice not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Invoice not found"
},
"data": null
}
})
@ApiResponse({
status: 200,
description: 'Invoice successfully updated',
})
async update(@Body() invoice: Invoice, @Res() res: Response) {
if (!invoice || !invoice.id) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.invoiceService.upsert(user, false);
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
const response = await this.invoiceService.upsert(invoice, false);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: 'Invoice not updated'
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Delete(':id')
@ApiOperation({ summary: 'Delete an invoice by ID' })
@ApiParam({ name: 'id', type: Number, description: 'Invoice ID to delete' })
@ApiResponse({
status: 400,
description: 'ID parameter is missing',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NO_ID_IN_REQ",
"stackTrace": "Request"
},
"data": null
}
})
@ApiResponse({
status: 404,
description: 'Invoice not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Invoice not found"
},
"data": null
}
})
@ApiResponse({
status: 200,
description: 'Invoice successfully deleted',
})
async deleteById(@Param('id') id: number, @Res() res: Response) {
if (!id) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_REQ',
exceptionMessage: 'ERR.NO_ID_IN_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.invoiceService.remove(id) || {};
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
const response = await this.invoiceService.remove(id);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: `Invoice with ID ${id} not found`
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
}

View File

@ -1,60 +1,78 @@
import { Table, Column, Model, Default, DataType, ForeignKey } from 'sequelize-typescript';
import { ApiProperty } from '@nestjs/swagger';
import Payment from 'src/payment/payment.entity';
@Table({ tableName: 'invoice' , paranoid : true})
@Table({ tableName: 'invoice', paranoid: true })
export default class Invoice extends Model {
@ApiProperty({ type: Number })
@Column({ type: DataType.BIGINT, allowNull: false })
user_id: number;
@ApiProperty({ type: Number })
@ForeignKey(() => Payment)
@Column({ type: DataType.BIGINT, allowNull: false, field: 'payment_id' })
payment_id: number;
@ApiProperty({ type: String })
@Column({ type: DataType.TEXT, field: 'invoice_number' })
invoice_number: string;
@ApiProperty({ type: Number })
@Column({ type: DataType.NUMBER, field: 'amount' })
amount: number;
@ApiProperty({ type: Number })
@Column({ type: DataType.NUMBER, field: 'remaining_balance' })
remaining_balance: number;
@ApiProperty({ type: Number })
@Column({ type: DataType.NUMBER, field: 'tax' })
tax: number;
@ApiProperty({ type: Date })
@Column({ type: DataType.DATEONLY, field: 'issue_date' })
issue_date: Date;
@ApiProperty({ type: Date })
@Column({ type: DataType.DATEONLY, field: 'due_date' })
due_date: Date;
@ApiProperty({ type: String })
@Column({ type: DataType.TEXT, field: 'status' })
status: string;
@ApiProperty({ type: Date, default: new Date() })
@Default(new Date())
@Column({ type: DataType.DATEONLY, field: 'validFrom' })
valid_from: Date;
@ApiProperty({ type: Date, default: new Date("2070-12-31") })
@Default(new Date("2070-12-31"))
@Column({ type: DataType.DATEONLY, field: 'validTill' })
valid_till: Date;
@ApiProperty({ type: Date })
@Column({ type: DataType.DATEONLY, field: 'createdAt' })
created_at: Date;
@ApiProperty({ type: Date })
@Column({ type: DataType.DATEONLY, field: 'updatedAt' })
updated_at: Date;
@ApiProperty({ type: String })
@Column({ type: DataType.TEXT, field: 'createdBy' })
created_by: string;
@ApiProperty({ type: String })
@Column({ type: DataType.TEXT, field: 'modifiedBy' })
modified_by: string;
@ApiProperty({ type: Date })
@Column({ type: DataType.DATEONLY, field: 'deletedAt' })
deleted_at: Date;
@ApiProperty({ type: Number })
@Column({ type: DataType.NUMBER, field: 'version' })
version: number;

View File

@ -1,5 +1,5 @@
import { MailerModule } from '@nestjs-modules/mailer';
import { HandlebarsAdapter } from '@nestjs-modules/mailer/dist/adapters/handlebars.adapter';
// import { MailerModule } from '@nestjs-modules/mailer';
// import { HandlebarsAdapter } from '@nestjs-modules/mailer/dist/adapters/handlebars.adapter';
import { Module } from '@nestjs/common';
import { MailService } from './mail.service';
import { join } from 'path';
@ -7,21 +7,21 @@ import { Utility } from 'src/common/Utility';
@Module({
imports: [
MailerModule.forRoot({
// transport: 'smtps://user@example.com:topsecret@smtp.example.com',
// or
transport: Utility.mailConfig.transport,
defaults: Utility.mailConfig.defaults,
template: {
dir: join(__dirname, 'templates'),
adapter: new HandlebarsAdapter(), // or new PugAdapter() or new EjsAdapter()
options: {
strict: true,
},
},
}),
// MailerModule.forRoot({
// // transport: 'smtps://user@example.com:topsecret@smtp.example.com',
// // or
// transport: Utility.mailConfig.transport,
// defaults: Utility.mailConfig.defaults,
// template: {
// dir: join(__dirname, 'templates'),
// adapter: new HandlebarsAdapter(), // or new PugAdapter() or new EjsAdapter()
// options: {
// strict: true,
// },
// },
// }),
],
providers: [MailService],
exports: [MailService], // 👈 export for DI
// providers: [MailService],
// exports: [MailService], // 👈 export for DI
})
export class MailModule {}

View File

@ -1,19 +1,19 @@
import { MailerService } from '@nestjs-modules/mailer';
// import { MailerService } from '@nestjs-modules/mailer';
import { Injectable } from '@nestjs/common';
@Injectable()
export class MailService {
constructor(private mailerService: MailerService) { }
// constructor(private mailerService: MailerService) { }
async sendEmail(templateName: string, subject: string, context: any, toEmail: string, ccEmails?: string[], bccEmails?: string[]) {
await this.mailerService.sendMail({
to: toEmail,
cc: ccEmails,
bcc: bccEmails,
subject: subject,
template: templateName, // `.hbs` extension is appended automatically
context,
})
}
// async sendEmail(templateName: string, subject: string, context: any, toEmail: string, ccEmails?: string[], bccEmails?: string[]) {
// await this.mailerService.sendMail({
// to: toEmail,
// cc: ccEmails,
// bcc: bccEmails,
// subject: subject,
// template: templateName, // `.hbs` extension is appended automatically
// context,
// })
// }
}

View File

@ -3,14 +3,27 @@ import { AppModule } from './app.module';
import * as bodyParser from 'body-parser';
import * as configMaster from './app-config/config.json';
import { Utility } from './common/Utility';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
async function bootstrap() {
Utility.appPort = configMaster.local.appConfig.port;
Utility.mailConfig = configMaster.local.mailConfig;
Utility.fileConfig = configMaster.local.fileConfig;
Utility.swaggerConfig = configMaster.local.swaggerConfig;
const app = await NestFactory.create(AppModule, { cors: true });
app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({limit: '50mb', extended: true}));
const config = new DocumentBuilder()
.setTitle(Utility.swaggerConfig.swagger.title)
.setVersion(Utility.swaggerConfig.swagger.version)
.addTag(Utility.swaggerConfig.swagger.tag)
.setDescription(Utility.swaggerConfig.swagger.description)
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('api', app, document);
app.use(bodyParser.json({ limit: '50mb' }));
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
await app.listen(Utility.appPort);
}
bootstrap();

View File

@ -3,101 +3,309 @@ import { Response } from 'express';
import { OffersRedemptionsService } from './offers-redemption.service';
import { GenericResponse } from 'src/common/GenericResponse.model';
import OffersRedemption from './offers-redemption.entity';
import { ApiTags, ApiOperation, ApiResponse, ApiParam, ApiBody } from '@nestjs/swagger';
@ApiTags('offers-redemption')
@Controller('offers-redemption')
export class OffersRedemptionsController {
constructor(private offersRedemptionService: OffersRedemptionsService) {}
@Get("/all")
@ApiOperation({ summary: 'Get all offers redemptions' })
@ApiResponse({ status: 200, description: 'Successfully retrieved all offers redemptions' })
@ApiResponse({
status: 404,
description: 'No offers redemption found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "No offers redemptions found"
},
"data": null
}
})
async getAllCompanys(@Res() res: Response) {
const response = await this.offersRedemptionService.findAll() || [];
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: 'No offers redemptions found'
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Get(':id')
@ApiOperation({ summary: 'Get an offer redemption by ID' })
@ApiParam({ name: 'id', type: Number, description: 'Offer Redemption ID' })
@ApiResponse({
status: 400,
description: 'ID parameter is missing',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NO_ID_REQ",
"stackTrace": "Request"
},
"data": null
}
})
@ApiResponse({
status: 404,
description: 'Offer redemption not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "No offer redemption found matching criteria"
},
"data": null
}
})
@ApiResponse({
status: 200,
description: 'Successfully retrieved offer redemption',
})
async findById(@Param('id') id: number, @Res() res: Response) {
if(!id) {
if (!id) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_ID_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.offersRedemptionService.findByPk(id) || {};
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
const response = await this.offersRedemptionService.findByPk(id);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: `Offer redemption with ID ${id} not found`
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Post('/filter')
@ApiOperation({ summary: 'Filter offers redemptions' })
@ApiBody({ type: OffersRedemption })
@ApiResponse({
status: 404,
description: 'Offer redemption not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "No offer redemption found matching criteria"
},
"data": null
}
})
@ApiResponse({
status: 200,
description: 'Successfully filtered offers redemptions',
})
async filter(@Body() offersRedemption: OffersRedemption, @Res() res: Response) {
if(!offersRedemption) {
if (!offersRedemption) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_ID_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.offersRedemptionService.findOne(offersRedemption) || {};
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
const response = await this.offersRedemptionService.findOne(offersRedemption);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: 'No offer redemption found matching criteria'
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Post()
@ApiOperation({ summary: 'Insert a new offer redemption' })
@ApiBody({ type: OffersRedemption })
@ApiResponse({
status: 400,
description: 'Failed to insert offer redemption',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Offer redemption not created"
},
"data": null
}
})
@ApiResponse({
status: 201,
description: 'Offer redemption successfully created',
})
async insert(@Body() offersRedemption: OffersRedemption, @Res() res: Response) {
if(!offersRedemption) {
if (!offersRedemption) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_ID_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
delete offersRedemption.id;
const response = await this.offersRedemptionService.upsert(offersRedemption, true);
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: 'Offer redemption not created'
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(201).send(httpResponse);
}
@Put()
@ApiOperation({ summary: 'Update an existing offer redemption' })
@ApiBody({ type: OffersRedemption })
@ApiResponse({
status: 400,
description: 'Offer redemption not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Request"
},
"data": null
}
})
@ApiResponse({
status: 404,
description: 'Offer redemption not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Offer redemption not found"
},
"data": null
}
})
@ApiResponse({
status: 200,
description: 'Offer redemption successfully updated',
})
async update(@Body() offersRedemption: OffersRedemption, @Res() res: Response) {
if(!offersRedemption || !offersRedemption.id) {
if (!offersRedemption || !offersRedemption.id) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_ID_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.offersRedemptionService.upsert(offersRedemption, false);
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: 'Offer redemption not found'
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Delete(':id')
@ApiOperation({ summary: 'Delete an offer redemption by ID' })
@ApiParam({ name: 'id', type: Number, description: 'Offer Redemption ID' })
@ApiResponse({
status: 400,
description: 'ID parameter is missing',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NO_ID_REQ",
"stackTrace": "Request"
},
"data": null
}
})
@ApiResponse({
status: 404,
description: 'Offer redemption not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Offer redemption not found"
},
"data": null
}
})
@ApiResponse({ status: 200, description: 'Offer redemption successfully deleted' })
async deleteById(@Param('id') id: number, @Res() res: Response) {
if(!id) {
if (!id) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_ID_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.offersRedemptionService.remove(id) || {};
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
const response = await this.offersRedemptionService.remove(id);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: `Offer redemption with ID ${id} not found`
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
}

View File

@ -1,46 +1,60 @@
import { Table, Column, Model, Default, DataType } from 'sequelize-typescript';
import { ApiProperty } from '@nestjs/swagger';
@Table({ tableName: 'offers_redemption' , paranoid : true})
@Table({ tableName: 'offers_redemption', paranoid: true })
export default class OfferRedemption extends Model {
@ApiProperty({ type: Number })
@Column(DataType.BIGINT)
user_id: number;
@ApiProperty({ type: Number })
@Column(DataType.BIGINT)
offer_id: number;
@ApiProperty({ type: Number })
@Column(DataType.BIGINT)
payment_id: number;
@ApiProperty({ type: Date })
@Column(DataType.DATEONLY)
redemption_date: Date;
@ApiProperty({ type: String })
@Column(DataType.TEXT)
status: string;
@ApiProperty({ type: Date, default: new Date() })
@Default(new Date())
@Column(DataType.DATEONLY)
validFrom: Date;
@ApiProperty({ type: Date, default: new Date("2070-12-31") })
@Default(new Date("2070-12-31"))
@Column(DataType.DATEONLY)
validTill: Date;
@ApiProperty({ type: Date })
@Column(DataType.DATEONLY)
createdAt: Date;
@ApiProperty({ type: Date })
@Column(DataType.DATEONLY)
updatedAt: Date;
@ApiProperty({ type: String })
@Column(DataType.TEXT)
createdBy: string;
@ApiProperty({ type: String })
@Column(DataType.TEXT)
modifiedBy: string;
@ApiProperty({ type: Date })
@Column(DataType.DATEONLY)
deletedAt: Date;
@ApiProperty({ type: Number })
@Column(DataType.NUMBER)
version: number;
}

View File

@ -1,103 +1,311 @@
import { Body, Controller, Delete, Get, Param, Post, Put, Res } from '@nestjs/common';
import { OfferService } from './offers.service';
import { Response } from 'express';
import { OfferService } from './offers.service';
import { GenericResponse } from 'src/common/GenericResponse.model';
import Offer from './offers.entity';
import { ApiTags, ApiOperation, ApiResponse, ApiParam, ApiBody } from '@nestjs/swagger';
@ApiTags('offers')
@Controller('offers')
export class OfferController {
constructor(private offersService: OfferService) {}
@Get("/all")
@ApiOperation({ summary: 'Get all offers' })
@ApiResponse({ status: 200, description: 'Successfully retrieved all offers' })
@ApiResponse({
status: 404,
description: 'No offers found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "No offers found"
},
"data": null
}
})
async getAllOffers(@Res() res: Response) {
const response = await this.offersService.findAll() || [];
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: 'No offers found'
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Get(':id')
@ApiOperation({ summary: 'Get an offer by ID' })
@ApiParam({ name: 'id', type: Number, description: 'Offer ID' })
@ApiResponse({
status: 400,
description: 'ID parameter is missing',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NO_ID_REQ",
"stackTrace": "Request"
},
"data": null
}
})
@ApiResponse({
status: 404,
description: 'Offer not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Offer not found"
},
"data": null
}
})
@ApiResponse({
status: 200,
description: 'Successfully retrieved offer',
})
async findById(@Param('id') id: number, @Res() res: Response) {
if(!id) {
if (!id) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_ID_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.offersService.findByPk(id) || {};
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
const response = await this.offersService.findByPk(id);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: `Offer with ID ${id} not found`
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Post('/filter')
@ApiOperation({ summary: 'Filter offers' })
@ApiBody({ type: Offer })
@ApiResponse({
status: 404,
description: 'No offers found matching criteria',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "No offers found matching criteria"
},
"data": null
}
})
@ApiResponse({
status: 200,
description: 'Successfully filtered offers',
})
async filter(@Body() offers: Offer, @Res() res: Response) {
if(!offers) {
if (!offers) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_ID_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.offersService.filter(offers) || {};
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
const response = await this.offersService.filter(offers);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: 'No offers found matching criteria'
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Post()
@ApiOperation({ summary: 'Create a new offer' })
@ApiBody({ type: Offer })
@ApiResponse({
status: 400,
description: 'Failed to create offer',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Offer not created"
},
"data": null
}
})
@ApiResponse({
status: 201,
description: 'Offer successfully created',
})
async insert(@Body() offers: Offer, @Res() res: Response) {
if(!offers) {
if (!offers) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_ID_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
delete offers.id;
const response = await this.offersService.upsert(offers, true);
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: 'Offer not created'
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(201).send(httpResponse);
}
@Put()
@ApiOperation({ summary: 'Update an existing offer' })
@ApiBody({ type: Offer })
@ApiResponse({
status: 400,
description: 'Offer not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Request"
},
"data": null
}
})
@ApiResponse({
status: 404,
description: 'Offer not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Offer not found"
},
"data": null
}
})
@ApiResponse({
status: 200,
description: 'Offer successfully updated',
})
async update(@Body() offers: Offer, @Res() res: Response) {
if(!Offer || !offers.id) {
if (!offers || !offers.id) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_ID_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.offersService.upsert(offers, false);
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: 'Offer not found'
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Delete(':id')
@ApiOperation({ summary: 'Delete an offer by ID' })
@ApiParam({ name: 'id', type: Number, description: 'Offer ID' })
@ApiResponse({
status: 400,
description: 'ID parameter is missing',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NO_ID_REQ",
"stackTrace": "Request"
},
"data": null
}
})
@ApiResponse({
status: 404,
description: 'Offer not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Offer not found"
},
"data": null
}
})
@ApiResponse({ status: 200, description: 'Offer successfully deleted' })
async deleteById(@Param('id') id: number, @Res() res: Response) {
if(!id) {
if (!id) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_ID_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.offersService.remove(id) || {};
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
const response = await this.offersService.remove(id);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: `Offer with ID ${id} not found`
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
}

View File

@ -1,43 +1,56 @@
import { Table, Column, Model, Default, DataType, Unique } from 'sequelize-typescript';
import { ApiProperty } from '@nestjs/swagger';
@Table({ tableName: 'offers' , paranoid : true})
@Table({ tableName: 'offers', paranoid: true })
export default class Offer extends Model {
@ApiProperty({ type: String })
@Column(DataType.TEXT)
code: string;
@ApiProperty({ type: String })
@Column(DataType.TEXT)
description: string;
@ApiProperty({ type: Number })
@Column(DataType.NUMBER)
discount_value: number;
@ApiProperty({ type: String })
@Column(DataType.TEXT)
status: string;
@ApiProperty({ type: Date, default: new Date() })
@Default(new Date())
@Column(DataType.DATEONLY)
validFrom: Date;
@ApiProperty({ type: Date, default: new Date("2070-12-31") })
@Default(new Date("2070-12-31"))
@Column(DataType.DATEONLY)
validTill: Date;
@ApiProperty({ type: Date })
@Column(DataType.DATEONLY)
createdAt: Date;
@ApiProperty({ type: Date })
@Column(DataType.DATEONLY)
updatedAt: Date;
@ApiProperty({ type: String })
@Column(DataType.TEXT)
createdBy: string;
@ApiProperty({ type: String })
@Column(DataType.TEXT)
modifiedBy: string;
@ApiProperty({ type: Date })
@Column(DataType.DATEONLY)
deletedAt: Date;
@ApiProperty({ type: Number })
@Column(DataType.NUMBER)
version: number;
}

View File

@ -3,19 +3,59 @@ import { PaymentService } from './payment.service';
import { Response } from 'express';
import { GenericResponse } from '../common/GenericResponse.model';
import Payment from './payment.entity';
import { ApiTags, ApiOperation, ApiResponse, ApiParam, ApiBody } from '@nestjs/swagger';
@ApiTags('payments')
@Controller('payments')
export class PaymentController {
constructor(private paymentService: PaymentService) { }
@Get("/all")
@ApiOperation({ summary: 'Get all payments' })
@ApiResponse({
status: 200,
description: 'Successfully retrieved all payments',
})
async getAllPayments(@Res() res: Response) {
const response = await this.paymentService.findAll() || [];
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Get(':id')
@ApiOperation({ summary: 'Get a payment by ID' })
@ApiParam({ name: 'id', type: Number, description: 'Payment ID' })
@ApiResponse({
status: 400,
description: 'Payment not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Request"
},
"data": null
}
})
@ApiResponse({
status: 404,
description: 'Payment not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "No payments found matching criteria"
},
"data": null
}
})
@ApiResponse({
status: 200,
description: 'Successfully retrieved payment',
})
async findById(@Param('id') id: number, @Res() res: Response) {
if (!id) {
const response = new GenericResponse({
@ -24,15 +64,58 @@ export class PaymentController {
exceptionMessage: 'ERR.NO_ID_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.paymentService.findByPk(id) || {};
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
const response = await this.paymentService.findByPk(id);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: `Payment with ID ${id} not found`
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Post('/filter')
@ApiOperation({ summary: 'Filter payments' })
@ApiBody({ type: Payment })
@ApiResponse({
status: 400,
description: 'Payment not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Request"
},
"data": null
}
})
@ApiResponse({
status: 404,
description: 'Payment not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "No payments found matching criteria"
},
"data": null
}
})
@ApiResponse({
status: 200,
description: 'Successfully filtered payments',
})
async filter(@Body() payment: Payment, @Res() res: Response) {
if (!payment) {
const response = new GenericResponse({
@ -41,15 +124,63 @@ export class PaymentController {
exceptionMessage: 'ERR.NO_ID_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.paymentService.filter(payment) || [];
const httpResponse = new GenericResponse(null, response)
const response = await this.paymentService.filter(payment);
if (response && response.length === 0) {
const successResponse = new GenericResponse(null, []);
res.status(200).send(successResponse);
return;
}
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: `No payments found matching criteria`
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Post()
@ApiOperation({ summary: 'Insert a new payment' })
@ApiBody({ type: Payment })
@ApiResponse({
status: 400,
description: 'Payment not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Request"
},
"data": null
}
})
@ApiResponse({
status: 404,
description: 'Payment not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Payment not found"
},
"data": null
}
})
@ApiResponse({
status: 201,
description: 'Payment successfully created',
})
async insert(@Body() payment: Payment, @Res() res: Response) {
if (!payment) {
const response = new GenericResponse({
@ -58,16 +189,59 @@ export class PaymentController {
exceptionMessage: 'ERR.NO_ID_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
delete payment.id;
const response = await this.paymentService.upsert(payment, true);
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: `Payment not found`
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(201).send(httpResponse);
}
@Put()
@ApiOperation({ summary: 'Update an existing payment' })
@ApiBody({ type: Payment })
@ApiResponse({
status: 400,
description: 'Payment not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Request"
},
"data": null
}
})
@ApiResponse({
status: 404,
description: 'Payment not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Payment not found"
},
"data": null
}
})
@ApiResponse({
status: 200,
description: 'Payment successfully updated',
})
async update(@Body() payment: Payment, @Res() res: Response) {
if (!payment || !payment.id) {
const response = new GenericResponse({
@ -76,15 +250,54 @@ export class PaymentController {
exceptionMessage: 'ERR.NO_ID_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.paymentService.upsert(payment, false);
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: `Payment not found`
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Delete(':id')
@ApiOperation({ summary: 'Delete a payment by ID' })
@ApiParam({ name: 'id', type: Number, description: 'Payment ID' })
@ApiResponse({
status: 400,
description: 'Payment not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Request"
},
"data": null
}
})
@ApiResponse({
status: 404,
description: 'Payment not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Payment with ID 1 not found"
},
"data": null
}
})
@ApiResponse({ status: 200, description: 'Payment successfully deleted' })
async deleteById(@Param('id') id: number, @Res() res: Response) {
if (!id) {
const response = new GenericResponse({
@ -93,13 +306,21 @@ export class PaymentController {
exceptionMessage: 'ERR.NO_ID_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.paymentService.remove(id) || {};
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
const response = await this.paymentService.remove(id);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: `Payment with ID ${id} not found`
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
}

View File

@ -1,58 +1,76 @@
import { Table, Column, Model, Default, DataType } from 'sequelize-typescript';
import { ApiProperty } from '@nestjs/swagger';
@Table({ tableName: 'payment' , paranoid : true})
@Table({ tableName: 'payment', paranoid: true })
export default class Payment extends Model {
@ApiProperty({ type: Number })
@Column(DataType.BIGINT)
user_id: number;
@ApiProperty({ type: Number })
@Column(DataType.NUMBER)
amount: number;
@ApiProperty({ type: Date })
@Column(DataType.DATEONLY)
payment_date: Date;
@ApiProperty({ type: String })
@Column(DataType.TEXT)
method: string;
@ApiProperty({ type: String })
@Column(DataType.TEXT)
payment_signature: string;
@ApiProperty({ type: String })
@Column(DataType.TEXT)
from_account: string;
@ApiProperty({ type: String })
@Column(DataType.TEXT)
to_account: string;
@ApiProperty({ type: Number })
@Column(DataType.NUMBER)
remaining_amount: number;
@ApiProperty({ type: String })
@Column(DataType.TEXT)
status: string;
@ApiProperty({ type: Date, default: new Date() })
@Default(new Date())
@Column(DataType.DATEONLY)
validFrom: Date;
@ApiProperty({ type: Date, default: new Date("2070-12-31") })
@Default(new Date("2070-12-31"))
@Column(DataType.DATEONLY)
validTill: Date;
@ApiProperty({ type: Date })
@Column(DataType.DATEONLY)
createdAt: Date;
@ApiProperty({ type: Date })
@Column(DataType.DATEONLY)
updatedAt: Date;
@ApiProperty({ type: String })
@Column(DataType.TEXT)
createdBy: string;
@ApiProperty({ type: String })
@Column(DataType.TEXT)
modifiedBy: string;
@ApiProperty({ type: Date })
@Column(DataType.DATEONLY)
deletedAt: Date;
@ApiProperty({ type: Number })
@Column(DataType.NUMBER)
version: number;
}

View File

@ -3,101 +3,309 @@ import { Response } from 'express';
import { GenericResponse } from 'src/common/GenericResponse.model';
import { PlanUsageService } from './plan-usage.service';
import PlanUsage from './plan-usage.entity';
import { ApiTags, ApiOperation, ApiResponse, ApiParam, ApiBody } from '@nestjs/swagger';
@ApiTags('plan-usage')
@Controller('plans-usage')
export class PlanUsageController {
constructor(private itemsService: PlanUsageService) {}
constructor(private itemsService: PlanUsageService) { }
@Get("/all")
@ApiOperation({ summary: 'Get all plan usage' })
@ApiResponse({ status: 200, description: 'Successfully retrieved all plan usage' })
async getAll(@Res() res: Response) {
const response = await this.itemsService.findAll() || [];
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
const response = await this.itemsService.findAll();
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: 'No plan usage found'
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Get(':id')
@ApiOperation({ summary: 'Get a plan usage by ID' })
@ApiParam({ name: 'id', type: Number, description: 'Plan Usage ID' })
@ApiResponse({
status: 400,
description: 'ID parameter is missing',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NO_ID_REQ",
"stackTrace": "Request"
},
"data": null
}
})
@ApiResponse({
status: 404,
description: 'Plan usage not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "No plan usage found matching criteria"
},
"data": null
}
})
@ApiResponse({
status: 200,
description: 'Successfully retrieved plan usage',
})
async findById(@Param('id') id: number, @Res() res: Response) {
if(!id) {
if (!id) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_ID_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.itemsService.findByPk(id) || {};
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
const response = await this.itemsService.findByPk(id);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: `Plan usage with ID ${id} not found`
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Post('/filter')
@ApiOperation({ summary: 'Filter plan usage' })
@ApiBody({ type: PlanUsage })
@ApiResponse({
status: 400,
description: 'Plan usage not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Request"
},
"data": null
}
})
@ApiResponse({
status: 404,
description: 'Plan usage not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "No plan usage found matching criteria"
},
"data": null
}
})
@ApiResponse({
status: 200,
description: 'Successfully filtered plan usage',
})
async filter(@Body() item: PlanUsage, @Res() res: Response) {
if(!item) {
if (!item) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_ID_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.itemsService.filter(item) || {};
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
const response = await this.itemsService.filter(item);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: 'No plan usage found matching criteria'
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Post()
@ApiOperation({ summary: 'Insert a new plan usage' })
@ApiBody({ type: PlanUsage })
@ApiResponse({
status: 400,
description: 'Plan usage not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Request"
},
"data": null
}
})
@ApiResponse({
status: 201,
description: 'Plan usage successfully created',
})
async insert(@Body() item: PlanUsage, @Res() res: Response) {
if(!item) {
if (!item) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_ID_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
delete item.id;
const response = await this.itemsService.upsert(item, true);
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: 'Plan usage not created'
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(201).send(httpResponse);
}
@Put()
@ApiOperation({ summary: 'Update an existing plan usage' })
@ApiBody({ type: PlanUsage })
@ApiResponse({
status: 400,
description: 'Plan usage not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Request"
},
"data": null
}
})
@ApiResponse({
status: 404,
description: 'Plan usage not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Plan usage not found"
},
"data": null
}
})
@ApiResponse({
status: 200,
description: 'Plan usage successfully updated',
})
async update(@Body() item: PlanUsage, @Res() res: Response) {
if(!item || !item.id) {
if (!item || !item.id) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_ID_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.itemsService.upsert(item, false);
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: 'Plan usage not found'
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Delete(':id')
@ApiOperation({ summary: 'Delete a plan usage by ID' })
@ApiParam({ name: 'id', type: Number, description: 'Plan Usage ID' })
@ApiResponse({
status: 400,
description: 'ID parameter is missing',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NO_ID_REQ",
"stackTrace": "Request"
},
"data": null
}
})
@ApiResponse({
status: 404,
description: 'Plan usage not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Plan usage not found"
},
"data": null
}
})
@ApiResponse({ status: 200, description: 'Plan usage successfully deleted' })
async deleteById(@Param('id') id: number, @Res() res: Response) {
if(!id) {
if (!id) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_ID_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.itemsService.remove(id) || {};
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
const response = await this.itemsService.remove(id);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: `Plan usage with ID ${id} not found`
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
}

View File

@ -1,46 +1,60 @@
import { Table, Column, Model, Default, DataType } from 'sequelize-typescript';
import { ApiProperty } from '@nestjs/swagger';
@Table({ tableName: 'plan_usage' , paranoid : true})
@Table({ tableName: 'plan_usage', paranoid: true })
export default class PlanUsage extends Model {
@ApiProperty({ type: Number })
@Column(DataType.BIGINT)
user_id: number;
@ApiProperty({ type: Number })
@Column(DataType.BIGINT)
plan_id: number;
@ApiProperty({ type: String })
@Column(DataType.TEXT)
usage_type: string;
@ApiProperty({ type: Date })
@Column(DataType.DATEONLY)
usage_quantity: Date;
@ApiProperty({ type: String })
@Column(DataType.TEXT)
status: string;
@ApiProperty({ type: Date, default: new Date() })
@Default(new Date())
@Column(DataType.DATEONLY)
validFrom: Date;
@ApiProperty({ type: Date, default: new Date("2070-12-31") })
@Default(new Date("2070-12-31"))
@Column(DataType.DATEONLY)
validTill: Date;
@ApiProperty({ type: Date })
@Column(DataType.DATEONLY)
createdAt: Date;
@ApiProperty({ type: Date })
@Column(DataType.DATEONLY)
updatedAt: Date;
@ApiProperty({ type: String })
@Column(DataType.TEXT)
createdBy: string;
@ApiProperty({ type: String })
@Column(DataType.TEXT)
modifiedBy: string;
@ApiProperty({ type: Date })
@Column(DataType.DATEONLY)
deletedAt: Date;
@ApiProperty({ type: Number })
@Column(DataType.NUMBER)
version: number;
}

View File

@ -3,106 +3,316 @@ import { Response } from 'express';
import { GenericResponse } from 'src/common/GenericResponse.model';
import Plan from './plans.entity';
import { PlansService } from './plans.service';
import { ApiTags, ApiOperation, ApiResponse, ApiParam, ApiBody } from '@nestjs/swagger';
@ApiTags('plans')
@Controller('plans')
export class PlansController {
constructor(private planService?: PlansService) {
if(!planService) {
planService = new PlansService();
}
}
constructor(private planService: PlansService) { }
@Get("/all")
@ApiOperation({ summary: 'Get all plans' })
@ApiResponse({
status: 200,
description: 'Successfully retrieved all plans',
})
@ApiResponse({
status: 404,
description: 'No plans found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "No plans found"
},
"data": null
}
})
async plangetAll(@Res() res: Response) {
const response = await this.planService.findAll() || [];
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: 'No plans found'
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Get(':id')
@ApiOperation({ summary: 'Get a plan by ID' })
@ApiParam({ name: 'id', type: Number, description: 'Plan ID' })
@ApiResponse({
status: 400,
description: 'ID parameter is missing',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NO_ID_IN_REQ",
"stackTrace": "Request"
},
"data": null
}
})
@ApiResponse({
status: 404,
description: 'Plan not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Plan not found"
},
"data": null
}
})
@ApiResponse({
status: 200,
description: 'Successfully retrieved plan',
})
async planFindById(@Param('id') id: number, @Res() res: Response) {
if(!id) {
if (!id) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_ID_IN_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.planService.findByPk(id) || {};
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
const response = await this.planService.findByPk(id);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: `Plan with ID ${id} not found`
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Post('/filter')
async planFilter(@Body() user: Plan, @Res() res: Response) {
if(!user) {
@ApiOperation({ summary: 'Filter plans based on criteria' })
@ApiBody({ type: Plan })
@ApiResponse({
status: 404,
description: 'No plans found matching criteria',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "No plans found matching criteria"
},
"data": null
}
})
@ApiResponse({
status: 200,
description: 'Successfully filtered plans',
})
async planFilter(@Body() plan: Plan, @Res() res: Response) {
if (!plan) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.planService.filter(user) || [];
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
const response = await this.planService.filter(plan);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: 'No plans found matching criteria'
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Post()
async planInsert(@Body() user: Plan, @Res() res: Response) {
if(!user) {
@ApiOperation({ summary: 'Create a new plan' })
@ApiBody({ type: Plan })
@ApiResponse({
status: 400,
description: 'Failed to create plan',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_CREATED",
"stackTrace": "Plan not created"
},
"data": null
}
})
@ApiResponse({
status: 201,
description: 'Plan successfully created',
})
async planInsert(@Body() plan: Plan, @Res() res: Response) {
if (!plan) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
delete user.id;
const response = await this.planService.upsert(user, true);
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
delete plan.id;
const response = await this.planService.upsert(plan, true);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_CREATED',
stackTrace: 'Plan not created'
}, null);
res.status(400).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(201).send(httpResponse);
}
@Put()
async planUpdate(@Body() user: Plan, @Res() res: Response) {
if(!user || !user.id) {
@ApiOperation({ summary: 'Update an existing plan' })
@ApiBody({ type: Plan })
@ApiResponse({
status: 400,
description: 'Failed to update plan',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_UPDATED",
"stackTrace": "Plan not updated"
},
"data": null
}
})
@ApiResponse({
status: 404,
description: 'Plan not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Plan not found"
},
"data": null
}
})
@ApiResponse({
status: 200,
description: 'Plan successfully updated',
})
async planUpdate(@Body() plan: Plan, @Res() res: Response) {
if (!plan || !plan.id) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.planService.upsert(user, false);
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
const response = await this.planService.upsert(plan, false);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: 'Plan not found'
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
@Delete(':id')
@ApiOperation({ summary: 'Delete a plan by ID' })
@ApiParam({ name: 'id', type: Number, description: 'Plan ID' })
@ApiResponse({
status: 400,
description: 'ID parameter is missing',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NO_ID_IN_REQ",
"stackTrace": "Request"
},
"data": null
}
})
@ApiResponse({
status: 404,
description: 'Plan not found',
example: {
"notification": {
"exception": true,
"exceptionSeverity": "HIGH",
"exceptionMessage": "ERR.NOT_FOUND",
"stackTrace": "Plan not found"
},
"data": null
}
})
@ApiResponse({
status: 200,
description: 'Plan successfully deleted',
})
async planDeleteById(@Param('id') id: number, @Res() res: Response) {
if(!id) {
if (!id) {
const response = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NO_REQ',
exceptionMessage: 'ERR.NO_ID_IN_REQ',
stackTrace: 'Request'
}, null);
res.send(response);
res.status(400).send(response);
return;
}
const response = await this.planService.remove(id) || {};
const httpResponse = new GenericResponse(null, response)
res.send(httpResponse);
const response = await this.planService.remove(id);
if (!response) {
const errorResponse = new GenericResponse({
exception: true,
exceptionSeverity: 'HIGH',
exceptionMessage: 'ERR.NOT_FOUND',
stackTrace: `Plan with ID ${id} not found`
}, null);
res.status(404).send(errorResponse);
return;
}
const httpResponse = new GenericResponse(null, response);
res.status(200).send(httpResponse);
}
}

View File

@ -1,46 +1,60 @@
import { Table, Column, Model, Default, DataType } from 'sequelize-typescript';
import { ApiProperty } from '@nestjs/swagger';
@Table({ tableName: 'plans_ref' , paranoid : true})
@Table({ tableName: 'plans_ref', paranoid: true })
export default class Plan extends Model {
@ApiProperty({ type: String })
@Column(DataType.TEXT)
name: string;
@ApiProperty({ type: Number })
@Column(DataType.NUMBER)
price: number;
@ApiProperty({ type: Date })
@Column(DataType.DATEONLY)
duration: Date;
@ApiProperty({ type: String })
@Column(DataType.TEXT)
description: string;
@ApiProperty({ type: String })
@Column(DataType.TEXT)
status: string;
@ApiProperty({ type: Date, default: new Date() })
@Default(new Date())
@Column(DataType.DATEONLY)
validFrom: Date;
@ApiProperty({ type: Date, default: new Date("2070-12-31") })
@Default(new Date("2070-12-31"))
@Column(DataType.DATEONLY)
validTill: Date;
@ApiProperty({ type: Date })
@Column(DataType.DATEONLY)
createdAt: Date;
@ApiProperty({ type: Date })
@Column(DataType.DATEONLY)
updatedAt: Date;
@ApiProperty({ type: String })
@Column(DataType.TEXT)
createdBy: string;
@ApiProperty({ type: String })
@Column(DataType.TEXT)
modifiedBy: string;
@ApiProperty({ type: Date })
@Column(DataType.DATEONLY)
deletedAt: Date;
@ApiProperty({ type: Number })
@Column(DataType.NUMBER)
version: number;
}