fix: Add missing maps module and scope gitignore rules
All checks were successful
Test Asgard Runner / test (push) Successful in 3s
All checks were successful
Test Asgard Runner / test (push) Successful in 3s
maps/ gitignore rule was catching backend-nest/src/modules/maps/. Scoped to /maps/ (root only) so runtime data is still ignored but source code isn't. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
63
backend-nest/src/modules/maps/maps.service.ts
Normal file
63
backend-nest/src/modules/maps/maps.service.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { MapLibrary } from '../../entities/map-library.entity';
|
||||
import { MapRotation } from '../../entities/map-rotation.entity';
|
||||
import { UpdateRotationDto } from './dto/update-rotation.dto';
|
||||
|
||||
@Injectable()
|
||||
export class MapsService {
|
||||
constructor(
|
||||
@InjectRepository(MapLibrary)
|
||||
private readonly mapLibraryRepo: Repository<MapLibrary>,
|
||||
@InjectRepository(MapRotation)
|
||||
private readonly mapRotationRepo: Repository<MapRotation>,
|
||||
) {}
|
||||
|
||||
async getMaps(licenseId: string): Promise<{ maps: MapLibrary[] }> {
|
||||
const maps = await this.mapLibraryRepo.find({
|
||||
where: { license_id: licenseId },
|
||||
order: { uploaded_at: 'DESC' },
|
||||
});
|
||||
return { maps };
|
||||
}
|
||||
|
||||
async deleteMap(licenseId: string, mapId: string): Promise<void> {
|
||||
const result = await this.mapLibraryRepo.delete({
|
||||
id: mapId,
|
||||
license_id: licenseId,
|
||||
});
|
||||
|
||||
if (result.affected === 0) {
|
||||
throw new NotFoundException(`Map ${mapId} not found`);
|
||||
}
|
||||
}
|
||||
|
||||
async getRotation(licenseId: string): Promise<MapRotation[]> {
|
||||
return this.mapRotationRepo.find({
|
||||
where: { license_id: licenseId },
|
||||
relations: ['map'],
|
||||
order: { rotation_order: 'ASC' },
|
||||
});
|
||||
}
|
||||
|
||||
async updateRotation(licenseId: string, dto: UpdateRotationDto): Promise<MapRotation[]> {
|
||||
// Delete existing rotation entries for this license
|
||||
await this.mapRotationRepo.delete({ license_id: licenseId });
|
||||
|
||||
// Create new rotation entries
|
||||
const rotationEntries = dto.maps.map((entry) =>
|
||||
this.mapRotationRepo.create({
|
||||
license_id: licenseId,
|
||||
map_id: entry.map_id,
|
||||
rotation_order: entry.rotation_order,
|
||||
is_active: true,
|
||||
}),
|
||||
);
|
||||
|
||||
await this.mapRotationRepo.save(rotationEntries);
|
||||
|
||||
// Return updated rotation with map data
|
||||
return this.getRotation(licenseId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user