38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { BaseService } from '../base/base.service';
|
|
import { db, ObjectType, Prisma, UserProfile } from '@nice/common';
|
|
import { DefaultArgs } from '@prisma/client/runtime/library';
|
|
import EventBus, { CrudOperation } from '@server/utils/event-bus';
|
|
|
|
@Injectable()
|
|
export class DailyTrainService extends BaseService<Prisma.DailyTrainTimeDelegate> {
|
|
constructor() {
|
|
super(db, ObjectType.DAILY_TRAIN, true);
|
|
}
|
|
async create(args: Prisma.DailyTrainTimeCreateArgs) {
|
|
console.log(args);
|
|
const result = await super.create(args);
|
|
this.emitDataChanged(CrudOperation.CREATED, result);
|
|
return result;
|
|
}
|
|
|
|
async update(args: Prisma.DailyTrainTimeUpdateArgs) {
|
|
const result = await super.update(args);
|
|
this.emitDataChanged(CrudOperation.UPDATED, result);
|
|
return result;
|
|
}
|
|
|
|
async findMany(args: Prisma.DailyTrainTimeFindManyArgs) {
|
|
const result = await super.findMany(args);
|
|
return result;
|
|
}
|
|
|
|
private emitDataChanged(operation: CrudOperation, data: any) {
|
|
EventBus.emit('dataChanged', {
|
|
type: ObjectType.DAILY_TRAIN,
|
|
operation,
|
|
data,
|
|
});
|
|
}
|
|
}
|