22 lines
623 B
TypeScript
22 lines
623 B
TypeScript
|
|
import { Injectable, NotFoundException } from '@nestjs/common';
|
||
|
|
import { LearningSessionRepository } from './learning-session.repository';
|
||
|
|
|
||
|
|
@Injectable()
|
||
|
|
export class LearningSessionService {
|
||
|
|
constructor(private readonly repository: LearningSessionRepository) {}
|
||
|
|
|
||
|
|
async start(userId: string, dto: any) {
|
||
|
|
return this.repository.create(userId, dto);
|
||
|
|
}
|
||
|
|
|
||
|
|
async end(id: string) {
|
||
|
|
const session = await this.repository.end(id);
|
||
|
|
if (!session) throw new NotFoundException('会话不存在');
|
||
|
|
return session;
|
||
|
|
}
|
||
|
|
|
||
|
|
async findByUserId(userId: string) {
|
||
|
|
return this.repository.findByUserId(userId);
|
||
|
|
}
|
||
|
|
}
|