fix: review blockers — entity registration, session enum, conflict date-range, @Type decorators
This commit is contained in:
@@ -19,6 +19,9 @@ import {
|
||||
ClassroomRental,
|
||||
Permission,
|
||||
Role,
|
||||
Class,
|
||||
ClassStudent,
|
||||
ClassTeacher,
|
||||
ClassSchedule,
|
||||
AttendanceRecord,
|
||||
DingAttendanceRaw,
|
||||
|
||||
@@ -24,7 +24,7 @@ export class AttendanceRecordItem {
|
||||
attendanceDate: string;
|
||||
|
||||
@IsString()
|
||||
@IsIn(['morning', 'afternoon', 'evening'])
|
||||
@IsIn(['morning_reading', 'morning', 'afternoon', 'evening_study', 'night_check'])
|
||||
@IsNotEmpty()
|
||||
session: string;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { IsOptional, IsString, IsNotEmpty, IsInt, IsArray, IsDateString, IsEnum } from 'class-validator';
|
||||
import { Type } from 'class-transformer';
|
||||
import { ClassType, ClassStatus, TeacherRoleType } from '../../entities';
|
||||
|
||||
export class CreateClassDto {
|
||||
@@ -84,7 +85,9 @@ export class UpdateClassDto {
|
||||
}
|
||||
|
||||
export class QueryClassDto {
|
||||
@IsOptional() @IsInt()
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsInt()
|
||||
departmentId?: number;
|
||||
|
||||
@IsOptional() @IsString()
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
Min,
|
||||
Max,
|
||||
} from 'class-validator';
|
||||
import { Type } from 'class-transformer';
|
||||
|
||||
export class CreateScheduleDto {
|
||||
@IsInt()
|
||||
@@ -115,14 +116,17 @@ export class UpdateScheduleDto {
|
||||
|
||||
export class QueryScheduleDto {
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsInt()
|
||||
classroomId?: number;
|
||||
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsInt()
|
||||
classId?: number;
|
||||
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@Max(7)
|
||||
@@ -147,6 +151,7 @@ export class WeeklyViewQueryDto {
|
||||
endDate?: string;
|
||||
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsInt()
|
||||
classroomId?: number;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ export class SchedulesService {
|
||||
}
|
||||
|
||||
async create(dto: CreateScheduleDto) {
|
||||
await this.checkConflict(dto.classroomId, dto.weekDay, dto.startTime, dto.endTime);
|
||||
await this.checkConflict(dto.classroomId, dto.weekDay, dto.startTime, dto.endTime, dto.startDate, dto.endDate);
|
||||
|
||||
const schedule = this.scheduleRepo.create(dto);
|
||||
const saved = await this.scheduleRepo.save(schedule);
|
||||
@@ -54,8 +54,10 @@ export class SchedulesService {
|
||||
const weekDay = dto.weekDay ?? existing.weekDay;
|
||||
const startTime = dto.startTime ?? existing.startTime;
|
||||
const endTime = dto.endTime ?? existing.endTime;
|
||||
const startDate = dto.startDate ?? existing.startDate;
|
||||
const endDate = dto.endDate ?? existing.endDate;
|
||||
|
||||
await this.checkConflict(classroomId, weekDay, startTime, endTime, id);
|
||||
await this.checkConflict(classroomId, weekDay, startTime, endTime, startDate, endDate, id);
|
||||
|
||||
await this.scheduleRepo.update(id, dto as Record<string, unknown>);
|
||||
return this.findOne(id);
|
||||
@@ -73,6 +75,8 @@ export class SchedulesService {
|
||||
weekDay: number,
|
||||
startTime: string,
|
||||
endTime: string,
|
||||
startDate: string,
|
||||
endDate: string,
|
||||
excludeId?: number,
|
||||
) {
|
||||
const qb = this.scheduleRepo
|
||||
@@ -81,7 +85,9 @@ export class SchedulesService {
|
||||
.andWhere('cs.weekDay = :weekDay', { weekDay })
|
||||
.andWhere('cs.status = :status', { status: 'active' })
|
||||
.andWhere('cs.startTime < :endTime', { endTime })
|
||||
.andWhere('cs.endTime > :startTime', { startTime });
|
||||
.andWhere('cs.endTime > :startTime', { startTime })
|
||||
.andWhere('cs.startDate <= :endDate', { endDate })
|
||||
.andWhere('cs.endDate >= :startDate', { startDate });
|
||||
|
||||
if (excludeId) qb.andWhere('cs.id != :excludeId', { excludeId });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user