refactor: rename project from Flights to Missions and update related components
ci/woodpecker/push/build-arm Pipeline was successful

This commit transitions the project from Azaion.Flights to Azaion.Missions, updating namespaces, DTOs, services, and database entities accordingly. The Docker configuration and entry points have been modified to reflect the new project structure. Additionally, the README and documentation have been updated to clarify the ongoing renaming process and its implications. All references to flights have been replaced with missions, ensuring consistency across the codebase.
This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-05-15 04:35:49 +03:00
parent 4f226e91d5
commit 2840ccb9b6
51 changed files with 381 additions and 352 deletions
+42 -44
View File
@@ -1,75 +1,75 @@
using LinqToDB;
using Azaion.Flights.Database;
using Azaion.Flights.Database.Entities;
using Azaion.Flights.DTOs;
using Azaion.Missions.Database;
using Azaion.Missions.Database.Entities;
using Azaion.Missions.DTOs;
namespace Azaion.Flights.Services;
namespace Azaion.Missions.Services;
public class FlightService(AppDataConnection db)
public class MissionService(AppDataConnection db)
{
public async Task<Flight> CreateFlight(CreateFlightRequest request)
public async Task<Mission> CreateMission(CreateMissionRequest request)
{
var aircraftExists = await db.Aircrafts.AnyAsync(a => a.Id == request.AircraftId);
if (!aircraftExists)
throw new ArgumentException($"Aircraft {request.AircraftId} not found");
var vehicleExists = await db.Vehicles.AnyAsync(v => v.Id == request.VehicleId);
if (!vehicleExists)
throw new ArgumentException($"Vehicle {request.VehicleId} not found");
var flight = new Flight
var mission = new Mission
{
Id = Guid.NewGuid(),
CreatedDate = request.CreatedDate ?? DateTime.UtcNow,
Name = request.Name,
AircraftId = request.AircraftId
VehicleId = request.VehicleId
};
await db.InsertAsync(flight);
return flight;
await db.InsertAsync(mission);
return mission;
}
public async Task<Flight> UpdateFlight(Guid id, UpdateFlightRequest request)
public async Task<Mission> UpdateMission(Guid id, UpdateMissionRequest request)
{
var flight = await db.Flights.FirstOrDefaultAsync(f => f.Id == id)
?? throw new KeyNotFoundException($"Flight {id} not found");
var mission = await db.Missions.FirstOrDefaultAsync(m => m.Id == id)
?? throw new KeyNotFoundException($"Mission {id} not found");
if (request.Name != null)
flight.Name = request.Name;
if (request.AircraftId.HasValue)
mission.Name = request.Name;
if (request.VehicleId.HasValue)
{
var aircraftExists = await db.Aircrafts.AnyAsync(a => a.Id == request.AircraftId.Value);
if (!aircraftExists)
throw new ArgumentException($"Aircraft {request.AircraftId} not found");
flight.AircraftId = request.AircraftId.Value;
var vehicleExists = await db.Vehicles.AnyAsync(v => v.Id == request.VehicleId.Value);
if (!vehicleExists)
throw new ArgumentException($"Vehicle {request.VehicleId} not found");
mission.VehicleId = request.VehicleId.Value;
}
await db.UpdateAsync(flight);
return flight;
await db.UpdateAsync(mission);
return mission;
}
public async Task<Flight> GetFlight(Guid id)
public async Task<Mission> GetMission(Guid id)
{
var flight = await db.Flights.FirstOrDefaultAsync(f => f.Id == id)
?? throw new KeyNotFoundException($"Flight {id} not found");
return flight;
var mission = await db.Missions.FirstOrDefaultAsync(m => m.Id == id)
?? throw new KeyNotFoundException($"Mission {id} not found");
return mission;
}
public async Task<PaginatedResponse<Flight>> GetFlights(GetFlightsQuery query)
public async Task<PaginatedResponse<Mission>> GetMissions(GetMissionsQuery query)
{
var q = db.Flights.AsQueryable();
var q = db.Missions.AsQueryable();
if (!string.IsNullOrEmpty(query.Name))
q = q.Where(f => f.Name.ToLower().Contains(query.Name.ToLower()));
q = q.Where(m => m.Name.ToLower().Contains(query.Name.ToLower()));
if (query.FromDate.HasValue)
q = q.Where(f => f.CreatedDate >= query.FromDate.Value);
q = q.Where(m => m.CreatedDate >= query.FromDate.Value);
if (query.ToDate.HasValue)
q = q.Where(f => f.CreatedDate <= query.ToDate.Value);
q = q.Where(m => m.CreatedDate <= query.ToDate.Value);
var totalCount = await q.CountAsync();
var items = await q
.OrderByDescending(f => f.CreatedDate)
.OrderByDescending(m => m.CreatedDate)
.Skip((query.Page - 1) * query.PageSize)
.Take(query.PageSize)
.ToListAsync();
return new PaginatedResponse<Flight>
return new PaginatedResponse<Mission>
{
Items = items,
TotalCount = totalCount,
@@ -78,16 +78,14 @@ public class FlightService(AppDataConnection db)
};
}
public async Task DeleteFlight(Guid id)
public async Task DeleteMission(Guid id)
{
var flight = await db.Flights.FirstOrDefaultAsync(f => f.Id == id)
?? throw new KeyNotFoundException($"Flight {id} not found");
var mission = await db.Missions.FirstOrDefaultAsync(m => m.Id == id)
?? throw new KeyNotFoundException($"Mission {id} not found");
await db.MapObjects.DeleteAsync(m => m.FlightId == id);
await db.GpsCorrections.DeleteAsync(g => g.FlightId == id);
await db.Orthophotos.DeleteAsync(o => o.FlightId == id);
await db.MapObjects.DeleteAsync(o => o.MissionId == id);
var waypointIds = await db.Waypoints.Where(w => w.FlightId == id).Select(w => w.Id).ToListAsync();
var waypointIds = await db.Waypoints.Where(w => w.MissionId == id).Select(w => w.Id).ToListAsync();
if (waypointIds.Count > 0)
{
var mediaIds = await db.Media.Where(m => m.WaypointId != null && waypointIds.Contains(m.WaypointId!.Value))
@@ -103,7 +101,7 @@ public class FlightService(AppDataConnection db)
await db.Media.DeleteAsync(m => m.WaypointId != null && waypointIds.Contains(m.WaypointId!.Value));
}
await db.Waypoints.DeleteAsync(w => w.FlightId == id);
await db.Flights.DeleteAsync(f => f.Id == id);
await db.Waypoints.DeleteAsync(w => w.MissionId == id);
await db.Missions.DeleteAsync(m => m.Id == id);
}
}