doctor-mail/apps/server/src/models/lecture/lecture.service.ts

36 lines
925 B
TypeScript
Raw Normal View History

2024-12-31 15:57:32 +08:00
import { Injectable } from '@nestjs/common';
import { BaseService } from '../base/base.service';
import {
UserProfile,
db,
ObjectType,
2025-01-03 09:24:46 +08:00
Prisma
2025-01-06 08:45:23 +08:00
} from '@nice/common';
2025-01-03 09:24:46 +08:00
import EventBus, { CrudOperation } from '@server/utils/event-bus';
2024-12-31 15:57:32 +08:00
@Injectable()
export class LectureService extends BaseService<Prisma.LectureDelegate> {
constructor() {
super(db, ObjectType.COURSE);
}
2025-01-03 09:24:46 +08:00
async create(args: Prisma.LectureCreateArgs, params?: { staff?: UserProfile }) {
const result = await super.create(args)
EventBus.emit('dataChanged', {
type: ObjectType.LECTURE,
operation: CrudOperation.CREATED,
data: result,
});
return result;
}
async update(args: Prisma.LectureUpdateArgs) {
const result = await super.update(args);
EventBus.emit('dataChanged', {
type: ObjectType.LECTURE,
operation: CrudOperation.UPDATED,
data: result,
});
return result;
}
2024-12-31 15:57:32 +08:00
}