2026-05-09 18:25:04 +08:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-05 20:01:43 +08:00
|
|
|
async findByUserId(userId: string, opts: { page?: number; limit?: number; status?: string; sort?: string }) {
|
|
|
|
|
return this.repository.findByUserId(userId, opts);
|
2026-05-09 18:25:04 +08:00
|
|
|
}
|
|
|
|
|
}
|