diff --git a/OpenAuth.App/ServiceApp/Algo/AlgoInstanceServiceApp.cs b/OpenAuth.App/ServiceApp/Algo/AlgoInstanceServiceApp.cs new file mode 100644 index 0000000..81ab8a0 --- /dev/null +++ b/OpenAuth.App/ServiceApp/Algo/AlgoInstanceServiceApp.cs @@ -0,0 +1,90 @@ +using Infrastructure; +using OpenAuth.App.BaseApp.Base; +using OpenAuth.App.Interface; +using OpenAuth.App.ServiceApp.Algo.Request; +using OpenAuth.Repository; +using OpenAuth.Repository.Domain; +using SqlSugar; + +namespace OpenAuth.App.ServiceApp; + +public class AlgoInstanceServiceApp : SqlSugarBaseApp +{ + public AlgoInstanceServiceApp(ISugarUnitOfWork unitWork, + ISimpleClient repository, IAuth auth) : base(unitWork, repository, auth) + { + } + + public async Task> AddAlgoInstance(LasaAlgoInstance info) + { + info.Id = Guid.NewGuid().ToString(); + if (await Repository.InsertAsync(info)) + { + return new Response + { + Result = true, + Message = "添加成功" + }; + } + + return new Response + { + Result = false, + Message = "添加失败" + }; + } + + public async Task> DeleteAlgoInstance(string id) + { + if (await Repository.DeleteByIdAsync(id)) + { + return new Response + { + Result = true, + Message = "删除成功" + }; + } + + return new Response + { + Result = false, + Message = "删除失败" + }; + } + + public async Task> UpdateAlgoInstance(LasaAlgoInstance info) + { + // todo 关于会更新空值问题 + if (await Repository.UpdateAsync(info)) + { + return new Response + { + Result = true, + Message = "修改成功" + }; + } + + return new Response + { + Result = false, + Message = "修改失败" + }; + } + + public async Task>>> GetAlgoInstanceList(AlgoInstancePageRequest req) + { + RefAsync totalCount = 0; + var page = await Repository.AsQueryable() + .WhereIF(!string.IsNullOrEmpty(req.key), x => x.Name.Contains(req.key)) + .ToPageListAsync(req.page, req.limit, totalCount); + + return new Response>> + { + Result = new PageInfo> + { + Items = page, + Total = totalCount.Value + } + }; + } +} \ No newline at end of file diff --git a/OpenAuth.App/ServiceApp/Algo/Request/AlgoInstancePageRequest.cs b/OpenAuth.App/ServiceApp/Algo/Request/AlgoInstancePageRequest.cs new file mode 100644 index 0000000..0b90b24 --- /dev/null +++ b/OpenAuth.App/ServiceApp/Algo/Request/AlgoInstancePageRequest.cs @@ -0,0 +1,7 @@ +using OpenAuth.App.Request; + +namespace OpenAuth.App.ServiceApp.Algo.Request; + +public class AlgoInstancePageRequest : PageReq +{ +} \ No newline at end of file diff --git a/OpenAuth.Repository/Domain/LasaAlgoInstance.cs b/OpenAuth.Repository/Domain/LasaAlgoInstance.cs new file mode 100644 index 0000000..0040348 --- /dev/null +++ b/OpenAuth.Repository/Domain/LasaAlgoInstance.cs @@ -0,0 +1,126 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using SqlSugar; + +namespace OpenAuth.Repository.Domain; + +/// +/// 算法实例 +/// +[SugarTable("lasa_algoinstance")] +public class LasaAlgoInstance +{ + /// + /// 主键ID + /// + [Key] + [SugarColumn(ColumnName = "Id")] + [MaxLength(50)] + public string Id { get; set; } + + /// + /// 名称 + /// + [SugarColumn(ColumnName = "Name")] + [Required] + [MaxLength(50)] + public string Name { get; set; } + + /// + /// 封面 + /// + [SugarColumn(ColumnName = "Cover")] + [MaxLength(1000)] + public string Cover { get; set; } + + /// + /// 显示方案 + /// + [SugarColumn(ColumnName = "DisplayScheme")] + [MaxLength(30)] + public string DisplayScheme { get; set; } + + /// + /// 描述 + /// + [SugarColumn(ColumnName = "Description")] + [MaxLength(2000)] + public string Description { get; set; } + + /// + /// 显示颜色 + /// + [SugarColumn(ColumnName = "DisplayColor")] + [MaxLength(15)] + public string DisplayColor { get; set; } + + /// + /// 画面识别区域水平方向 + /// + [SugarColumn(ColumnName = "RecognitionX")] + public float? RecognitionX { get; set; } + + /// + /// 画面识别区域垂直方向 + /// + [SugarColumn(ColumnName = "RecognitionY")] + public float? RecognitionY { get; set; } + + /// + /// 空间红束是否开启 0未开启 1开启 Constraint + /// + [SugarColumn(ColumnName = "SpaceConstraint")] + public short? SpaceConstraint { get; set; } + + /// + /// 外扩距离 + /// + [SugarColumn(ColumnName = "ExpansionDistance")] + public int? ExpansionDistance { get; set; } + + /// + /// 时间约束是否开启 0未开启 1开启 + /// + [SugarColumn(ColumnName = "TemporalConstraint")] + public short? TemporalConstraints { get; set; } + + /// + /// 时间约束开始时间 + /// + [SugarColumn(ColumnName = "TcStartTime")] + public DateTime? TcStartTime { get; set; } + + /// + /// 时间约束结束时间 + /// + [SugarColumn(ColumnName = "TcEndTime")] + public DateTime? TcEndTime { get; set; } + + /// + /// 飞行速度 + /// + [SugarColumn(ColumnName = "FlySpeed")] + [MaxLength(30)] + public string FlySpeed { get; set; } + + /// + /// 云台俯仰角 + /// + [SugarColumn(ColumnName = "GimbalPitchDegree")] + [MaxLength(35)] + public string GimbalPitchDegree { get; set; } + + /// + /// 识别对象画面占比 + /// + [SugarColumn(ColumnName = "RecognitionCoverage")] + [MaxLength(10)] + public string RecognitionCoverage { get; set; } + + /// + /// 标签 + /// + [SugarColumn(ColumnName = "Tags")] + [MaxLength(255)] + public string Tags { get; set; } +} \ No newline at end of file diff --git a/OpenAuth.WebApi/Controllers/ServiceControllers/AlgoInstanceController.cs b/OpenAuth.WebApi/Controllers/ServiceControllers/AlgoInstanceController.cs new file mode 100644 index 0000000..a544fa4 --- /dev/null +++ b/OpenAuth.WebApi/Controllers/ServiceControllers/AlgoInstanceController.cs @@ -0,0 +1,44 @@ +using Infrastructure; +using Microsoft.AspNetCore.Mvc; +using OpenAuth.App.ServiceApp; +using OpenAuth.App.ServiceApp.Algo.Request; +using OpenAuth.Repository.Domain; + +namespace OpenAuth.WebApi.Controllers.ServiceControllers; + +[Route("api/[controller]/[action]")] +[ApiController] +public class AlgoInstanceController : ControllerBase +{ + private readonly AlgoInstanceServiceApp _app; + + public AlgoInstanceController(AlgoInstanceServiceApp app) + { + _app = app; + } + + // todo 增删改查 + [HttpPost] + public async Task> AddAlgoInstance(LasaAlgoInstance info) + { + return await _app.AddAlgoInstance(info); + } + + [HttpPost] + public async Task> DeleteAlgoInstance(string id) + { + return await _app.DeleteAlgoInstance(id); + } + + [HttpPost] + public async Task> UpdateAlgoInstance(LasaAlgoInstance info) + { + return await _app.UpdateAlgoInstance(info); + } + + [HttpGet] + public async Task>>> GetAlgoInstanceList(AlgoInstancePageRequest req) + { + return await _app.GetAlgoInstanceList(req); + } +} \ No newline at end of file