2026-05-09 18:25:04 +08:00
|
|
|
import { Injectable, NotFoundException } from '@nestjs/common';
|
|
|
|
|
import { LearningSessionRepository } from './learning-session.repository';
|
2026-05-17 19:08:07 +08:00
|
|
|
import type { PaginationDto } from '../../common/dto/pagination.dto';
|
2026-05-09 18:25:04 +08:00
|
|
|
|
|
|
|
|
@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-05-17 19:08:07 +08:00
|
|
|
async findByUserId(userId: string, pagination: PaginationDto) {
|
|
|
|
|
return this.repository.findByUserId(userId, pagination);
|
2026-05-09 18:25:04 +08:00
|
|
|
}
|
|
|
|
|
}
|