diff --git a/OpenAuth.App/ServiceApp/ManageApp.cs b/OpenAuth.App/ServiceApp/ManageApp.cs index 0a3d59d..89c5012 100644 --- a/OpenAuth.App/ServiceApp/ManageApp.cs +++ b/OpenAuth.App/ServiceApp/ManageApp.cs @@ -59,12 +59,12 @@ namespace OpenAuth.App.ServiceApp using (var db = UnitWork.CreateContext()) { var list = await db.LasaDronePort.AsQueryable().Includes(a => a.UavList) - .LeftJoin((a,b)=>a.Id==b.DeviceId) + .LeftJoin((a, b) => a.Id == b.DeviceId) .Where(a => a.IsDelete == false) .WhereIF(!string.IsNullOrEmpty(sn), (a, b) => a.Sn == sn) .WhereIF(!string.IsNullOrEmpty(type), (a, b) => a.TypeId == type) .WhereIF(!string.IsNullOrEmpty(workspaceid), (a, b) => b.WorkSpaceId == workspaceid) - .Select((a,b)=>new LasaDronePort + .Select((a, b) => new LasaDronePort { Id = a.Id, Name = a.Name, @@ -182,12 +182,12 @@ namespace OpenAuth.App.ServiceApp { var list = await db.LasaUav.AsQueryable() .LeftJoin((a, b) => a.PId == b.Id) - .LeftJoin((a, b,c) => b.Id == c.DeviceId) + .LeftJoin((a, b, c) => b.Id == c.DeviceId) .Where((a, b, c) => a.IsDelete == false) .WhereIF(!string.IsNullOrEmpty(sn), (a, b, c) => a.Sn == sn) .WhereIF(!string.IsNullOrEmpty(type), (a, b, c) => a.TypeId == type) .WhereIF(!string.IsNullOrEmpty(workspaceid), (a, b, c) => c.WorkSpaceId == workspaceid) - .Select((a, b,c) => new + .Select((a, b, c) => new { id = a.Id, name = a.Name, @@ -460,6 +460,7 @@ namespace OpenAuth.App.ServiceApp JsonConvert.SerializeObject(cancelTaskRequest)); } } + var flag = await db.LasaTask.DeleteAsync(it => it.Id == id); var taskId = task.Id; var mediaFileList = await db.LasaMediaFile.AsQueryable() @@ -499,7 +500,7 @@ namespace OpenAuth.App.ServiceApp using (var db = UnitWork.CreateContext()) { var list = await db.LasaAirLine.AsQueryable().LeftJoin((a, b) => a.UavId == b.Id) - .WhereIF(!string.IsNullOrEmpty(req.UavTypeId),(a,b) => b.TypeId == req.UavTypeId) + .WhereIF(!string.IsNullOrEmpty(req.UavTypeId), (a, b) => b.TypeId == req.UavTypeId) .WhereIF(!string.IsNullOrEmpty(req.key), a => a.AirLineName.Contains(req.key)) .WhereIF(!string.IsNullOrEmpty(req.AirLineName), a => a.AirLineName.Contains(req.AirLineName)) .WhereIF(!string.IsNullOrEmpty(req.AirLineType), a => a.AirLineType.Equals(req.AirLineType)) @@ -1251,7 +1252,8 @@ namespace OpenAuth.App.ServiceApp { list = list.Where(r => r.WorkSpaceId == workspaceid).ToList(); } - if (type!=null && list.Count > 0) + + if (type != null && list.Count > 0) { list = list.Where(r => r.Type == type).ToList(); } @@ -1400,5 +1402,89 @@ namespace OpenAuth.App.ServiceApp } #endregion + + public async Task> CreateAirLoneFolder(string folderName, string parentId) + { + LasaLineFolder folder = new LasaLineFolder() + { + Id = Guid.NewGuid().ToString(), + Path = folderName, + ParentId = parentId, + CreateTime = DateTime.Now + }; + if (!string.IsNullOrEmpty(parentId)) + { + var parent = await Repository + .ChangeRepository>() + .GetByIdAsync(parentId); + folder.Ancestor = Path.Combine(parent.Ancestor, folderName); + } + else + { + folder.Ancestor = folderName; + } + + return new Response() + { + Result = await Repository + .ChangeRepository>() + .InsertAsync(folder) + }; + } + + public async Task> DeleteAirLineFolder(string folderId) + { + var folder = await Repository + .ChangeRepository>() + .GetByIdAsync(folderId); + var ancestor = folder.Ancestor; + // 删除文件夹记录 + var x = await Repository.ChangeRepository>().DeleteByIdAsync(folderId); + // 删除该文件夹下的航线记录 + var y = await Repository + .ChangeRepository>() + .DeleteAsync(r => r.WPML.Contains(ancestor)); + return new Response() + { + Result = x && y + }; + } + + public async Task>> ListAirLineFolder() + { + var nodes = await Repository.ChangeRepository>() + .AsQueryable().ToListAsync(); + return new Response>() + { + Result = BuildFolderTree(nodes) + }; + } + + public List BuildFolderTree(List folders) + { + var folderMap = folders.ToDictionary(f => f.Id, f => new LasaLineFolder + { + Id = f.Id, + Path = f.Path, + Ancestor = f.Ancestor, + Children = new List() + }); + + var rootNodes = new List(); + + foreach (var folder in folders) + { + if (string.IsNullOrEmpty(folder.ParentId)) + { + rootNodes.Add(folderMap[folder.Id]); + } + else if (folderMap.TryGetValue(folder.ParentId, out var parentNode)) + { + parentNode.Children.Add(folderMap[folder.Id]); + } + } + + return rootNodes; + } } } \ No newline at end of file diff --git a/OpenAuth.Repository/Domain/LasaLineFolder.cs b/OpenAuth.Repository/Domain/LasaLineFolder.cs new file mode 100644 index 0000000..7436c74 --- /dev/null +++ b/OpenAuth.Repository/Domain/LasaLineFolder.cs @@ -0,0 +1,18 @@ +using SqlSugar; + +namespace OpenAuth.Repository.Domain; + + +[SugarTable("lasa_linefolder")] +public class LasaLineFolder +{ + [SugarColumn(IsPrimaryKey = true)] + public string Id {get; set;} + public string Path {get; set;} + public string Ancestor {get; set;} + public string ParentId {get; set;} + public DateTime? CreateTime {get; set;} + + [SugarColumn(IsIgnore = true)] + public List Children { get; set; } +} \ No newline at end of file diff --git a/OpenAuth.WebApi/Controllers/ServiceControllers/ManageController.cs b/OpenAuth.WebApi/Controllers/ServiceControllers/ManageController.cs index ef16013..1897655 100644 --- a/OpenAuth.WebApi/Controllers/ServiceControllers/ManageController.cs +++ b/OpenAuth.WebApi/Controllers/ServiceControllers/ManageController.cs @@ -1,9 +1,6 @@ using System.Text; -using DocumentFormat.OpenXml.Math; using Infrastructure; using Infrastructure.CloudSdk.wayline; -using Infrastructure.Extensions; -using Infrastructure.Helpers; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; @@ -257,6 +254,32 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers #region 航线管理 + // todo 创建文件夹 + // todo 删除文件夹 + // todo 文件夹列表 + [HttpPost] + public async Task> CreateAirLoneFolder(string folderName, string parentId) + { + return await _app.CreateAirLoneFolder(folderName, parentId); + } + + /// + /// 删除文件夹及文件夹航线 + /// + /// + /// + [HttpPost] + public async Task> DeleteAirLineFolder(string folderId) + { + return await _app.DeleteAirLineFolder(folderId); + } + + [HttpGet] + public async Task>> ListAirLineFolder() + { + return await _app.ListAirLineFolder(); + } + /// /// 获取航线列表 ///