narinder1231 commited on
Commit
4e912ee
·
1 Parent(s): 350299f

add a function to create an audit log

Browse files
src/controllers/auditLog.controller.ts CHANGED
@@ -1,6 +1,7 @@
1
  import { Request, Response } from 'express';
2
  import { Op, FindOptions } from 'sequelize';
3
  import AuditLog from '../models/auditLogs';
 
4
 
5
  const getAuditLogs = async (req: Request, res: Response) => {
6
 
@@ -79,4 +80,17 @@ const getAuditLogById = async (req: Request, res: Response) => {
79
 
80
  }
81
 
82
- export { getAuditLogs, getAuditLogById }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import { Request, Response } from 'express';
2
  import { Op, FindOptions } from 'sequelize';
3
  import AuditLog from '../models/auditLogs';
4
+ import { AuditLogInterface } from '../shared/interfaces/auditLog.interface';
5
 
6
  const getAuditLogs = async (req: Request, res: Response) => {
7
 
 
80
 
81
  }
82
 
83
+ const createNewAuditLog = async (auditLogData: AuditLogInterface) => {
84
+ try {
85
+ const newAuditLog = await AuditLog.create({
86
+ action_by: auditLogData.action_by,
87
+ invoice_id: auditLogData.invoice_id,
88
+ action: auditLogData.action,
89
+ details: auditLogData.details
90
+ });
91
+ } catch (error) {
92
+ console.error('Error creating audit log:', error);
93
+ }
94
+ };
95
+
96
+ export { getAuditLogs, getAuditLogById, createNewAuditLog }