"feat: add EventItem, EventReview models with seed data and mock files, update User and Event schemas"
This commit is contained in:
66
03_source/cms_backend/src/app/services/AccessLog.service.ts
Normal file
66
03_source/cms_backend/src/app/services/AccessLog.service.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
// src/app/services/AccessLog.service.ts
|
||||
//
|
||||
// PURPOSE:
|
||||
// Service for handling AccessLog records
|
||||
//
|
||||
// RULES:
|
||||
// - All methods return Promises
|
||||
// - Input validation should be done at controller level
|
||||
// - Errors should be propagated to caller
|
||||
|
||||
import type { AccessLog } from '@prisma/client';
|
||||
|
||||
import prisma from '../lib/prisma';
|
||||
|
||||
// type CreateAccessLog = {
|
||||
// userId?: string;
|
||||
// message?: string;
|
||||
// metadata?: Record<string, any>;
|
||||
// };
|
||||
|
||||
// type UpdateAccessLog = {
|
||||
// status?: number;
|
||||
// metadata?: object;
|
||||
// };
|
||||
|
||||
async function listAccessLogs(): Promise<AccessLog[]> {
|
||||
return prisma.accessLog.findMany({
|
||||
orderBy: { timestamp: 'desc' },
|
||||
take: 100,
|
||||
});
|
||||
}
|
||||
|
||||
async function getAccessLog(id: string): Promise<AccessLog | null> {
|
||||
return prisma.accessLog.findUnique({ where: { id } });
|
||||
}
|
||||
|
||||
async function createAccessLog(userId?: string, message?: string, metadata?: Record<string, any>): Promise<AccessLog> {
|
||||
return prisma.accessLog.create({
|
||||
data: {
|
||||
userId,
|
||||
message,
|
||||
metadata,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// async function update(id: string, data: UpdateAccessLog): Promise<AccessLog> {
|
||||
// return prisma.accessLog.update({
|
||||
// where: { id },
|
||||
// data: {
|
||||
// ...data,
|
||||
// metadata: data.metadata || {},
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
|
||||
// async function deleteAccessLog(id: string): Promise<AccessLog> {
|
||||
// return prisma.accessLog.delete({ where: { id } });
|
||||
// }
|
||||
|
||||
export {
|
||||
//
|
||||
getAccessLog,
|
||||
listAccessLogs,
|
||||
createAccessLog,
|
||||
};
|
Reference in New Issue
Block a user