fix(server): remove CampusScope from StudentsService
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
import { Injectable, NotFoundException, BadRequestException } from '@nestjs/common';
|
import { Injectable, NotFoundException, BadRequestException } from '@nestjs/common';
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { Repository, Like, Not, In, FindOptionsWhere } from 'typeorm';
|
import { Repository, Like, Not, In, FindOptionsWhere } from 'typeorm';
|
||||||
import { CampusScope } from '../common/campus-scope';
|
|
||||||
import { Student } from '../entities/student.entity';
|
import { Student } from '../entities/student.entity';
|
||||||
import { Class } from '../entities/class.entity';
|
import { Class } from '../entities/class.entity';
|
||||||
import { ClassStudent } from '../entities/class-student.entity';
|
import { ClassStudent } from '../entities/class-student.entity';
|
||||||
@@ -16,7 +15,6 @@ export class StudentsService {
|
|||||||
@InjectRepository(ClassStudent) private classStudentRepo: Repository<ClassStudent>,
|
@InjectRepository(ClassStudent) private classStudentRepo: Repository<ClassStudent>,
|
||||||
@InjectRepository(Class) private classRepo: Repository<Class>,
|
@InjectRepository(Class) private classRepo: Repository<Class>,
|
||||||
@InjectRepository(AttendanceRecord) private attendanceRepo: Repository<AttendanceRecord>,
|
@InjectRepository(AttendanceRecord) private attendanceRepo: Repository<AttendanceRecord>,
|
||||||
private readonly scope: CampusScope,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async findAll(query?: { name?: string; status?: string; includeArchived?: boolean; tenantId?: number | string }) {
|
async findAll(query?: { name?: string; status?: string; includeArchived?: boolean; tenantId?: number | string }) {
|
||||||
@@ -26,11 +24,9 @@ export class StudentsService {
|
|||||||
if (query?.status) {
|
if (query?.status) {
|
||||||
where.status = query.status;
|
where.status = query.status;
|
||||||
} else if (!query?.includeArchived) {
|
} else if (!query?.includeArchived) {
|
||||||
// Default: hide archived and staff, unless explicitly queried
|
where.status = Not(In(['archived']));
|
||||||
where.status = Not(In(['archived', 'staff']));
|
|
||||||
}
|
}
|
||||||
const filteredWhere = await this.scope.filter(where);
|
return this.repo.find({ where, order: { createdAt: 'DESC' }, relations: ['tenant'] });
|
||||||
return this.repo.find({ where: filteredWhere, order: { createdAt: 'DESC' }, relations: ['tenant'] });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async findOne(id: number) {
|
async findOne(id: number) {
|
||||||
|
|||||||
Reference in New Issue
Block a user