IScenarioService: AddDetection/DeleteDetection/GetDetections (independent of SaveDeployment overwrite). Repository: GetByTaskIdAndRole filters by equipment role. TaskFullConfig.Equipment already includes detections (GetTaskDetail.GetByTaskId returns all). Frontend filters by EquipmentRole.Detection or uses GetDetections. Tests: 4 detection CRUD tests. 212 total pass.
33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using CounterDrone.Core.Models;
|
||
using SQLite;
|
||
|
||
namespace CounterDrone.Core.Repository
|
||
{
|
||
public class EquipmentDeploymentRepository : BaseRepository<EquipmentDeployment>
|
||
{
|
||
public EquipmentDeploymentRepository(SQLiteConnection db) : base(db) { }
|
||
|
||
public List<EquipmentDeployment> GetByTaskId(string taskId)
|
||
{
|
||
return Db.Table<EquipmentDeployment>().Where(e => e.TaskId == taskId).ToList();
|
||
}
|
||
|
||
/// <summary>按任务和角色查询装备(EquipmentRole: 0=Detection, 1=LaunchPlatform)</summary>
|
||
public List<EquipmentDeployment> GetByTaskIdAndRole(string taskId, int equipmentRole)
|
||
{
|
||
return Db.Table<EquipmentDeployment>()
|
||
.Where(e => e.TaskId == taskId && e.EquipmentRole == equipmentRole)
|
||
.ToList();
|
||
}
|
||
|
||
public void DeleteByTaskId(string taskId)
|
||
{
|
||
var equips = GetByTaskId(taskId);
|
||
foreach (var e in equips)
|
||
Db.Delete(e);
|
||
}
|
||
}
|
||
}
|