forked from wangziqi/gongxue-base
feat: auto-populate department_id on create + seed default campus with backfill
This commit is contained in:
@@ -34,7 +34,9 @@ export class ClassroomsService {
|
||||
async create(dto: CreateClassroomDto) {
|
||||
const exists = await this.repo.findOne({ where: { name: dto.name } });
|
||||
if (exists) throw new BadRequestException(`教室 ${dto.name} 已存在`);
|
||||
return this.repo.save(this.repo.create(dto));
|
||||
const entity = this.repo.create(dto);
|
||||
if (dto.departmentId) entity.departmentId = dto.departmentId;
|
||||
return this.repo.save(entity);
|
||||
}
|
||||
|
||||
async update(id: number, dto: UpdateClassroomDto) {
|
||||
|
||||
@@ -32,6 +32,10 @@ export class CreateClassroomDto {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
notes?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
departmentId?: number;
|
||||
}
|
||||
|
||||
export class UpdateClassroomDto {
|
||||
|
||||
Reference in New Issue
Block a user