算法实例基本增删改
parent
17123afd9f
commit
fb9a6bfa36
|
|
@ -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<LasaAlgoInstance, SugarDbContext>
|
||||
{
|
||||
public AlgoInstanceServiceApp(ISugarUnitOfWork<SugarDbContext> unitWork,
|
||||
ISimpleClient<LasaAlgoInstance> repository, IAuth auth) : base(unitWork, repository, auth)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<Response<bool>> AddAlgoInstance(LasaAlgoInstance info)
|
||||
{
|
||||
info.Id = Guid.NewGuid().ToString();
|
||||
if (await Repository.InsertAsync(info))
|
||||
{
|
||||
return new Response<bool>
|
||||
{
|
||||
Result = true,
|
||||
Message = "添加成功"
|
||||
};
|
||||
}
|
||||
|
||||
return new Response<bool>
|
||||
{
|
||||
Result = false,
|
||||
Message = "添加失败"
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<Response<bool>> DeleteAlgoInstance(string id)
|
||||
{
|
||||
if (await Repository.DeleteByIdAsync(id))
|
||||
{
|
||||
return new Response<bool>
|
||||
{
|
||||
Result = true,
|
||||
Message = "删除成功"
|
||||
};
|
||||
}
|
||||
|
||||
return new Response<bool>
|
||||
{
|
||||
Result = false,
|
||||
Message = "删除失败"
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<Response<bool>> UpdateAlgoInstance(LasaAlgoInstance info)
|
||||
{
|
||||
// todo 关于会更新空值问题
|
||||
if (await Repository.UpdateAsync(info))
|
||||
{
|
||||
return new Response<bool>
|
||||
{
|
||||
Result = true,
|
||||
Message = "修改成功"
|
||||
};
|
||||
}
|
||||
|
||||
return new Response<bool>
|
||||
{
|
||||
Result = false,
|
||||
Message = "修改失败"
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<Response<PageInfo<List<LasaAlgoInstance>>>> GetAlgoInstanceList(AlgoInstancePageRequest req)
|
||||
{
|
||||
RefAsync<int> 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<PageInfo<List<LasaAlgoInstance>>>
|
||||
{
|
||||
Result = new PageInfo<List<LasaAlgoInstance>>
|
||||
{
|
||||
Items = page,
|
||||
Total = totalCount.Value
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
using OpenAuth.App.Request;
|
||||
|
||||
namespace OpenAuth.App.ServiceApp.Algo.Request;
|
||||
|
||||
public class AlgoInstancePageRequest : PageReq
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using SqlSugar;
|
||||
|
||||
namespace OpenAuth.Repository.Domain;
|
||||
|
||||
/// <summary>
|
||||
/// 算法实例
|
||||
/// </summary>
|
||||
[SugarTable("lasa_algoinstance")]
|
||||
public class LasaAlgoInstance
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键ID
|
||||
/// </summary>
|
||||
[Key]
|
||||
[SugarColumn(ColumnName = "Id")]
|
||||
[MaxLength(50)]
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Name")]
|
||||
[Required]
|
||||
[MaxLength(50)]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 封面
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Cover")]
|
||||
[MaxLength(1000)]
|
||||
public string Cover { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 显示方案
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "DisplayScheme")]
|
||||
[MaxLength(30)]
|
||||
public string DisplayScheme { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Description")]
|
||||
[MaxLength(2000)]
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 显示颜色
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "DisplayColor")]
|
||||
[MaxLength(15)]
|
||||
public string DisplayColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 画面识别区域水平方向
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "RecognitionX")]
|
||||
public float? RecognitionX { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 画面识别区域垂直方向
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "RecognitionY")]
|
||||
public float? RecognitionY { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 空间红束是否开启 0未开启 1开启 Constraint
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "SpaceConstraint")]
|
||||
public short? SpaceConstraint { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 外扩距离
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "ExpansionDistance")]
|
||||
public int? ExpansionDistance { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 时间约束是否开启 0未开启 1开启
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "TemporalConstraint")]
|
||||
public short? TemporalConstraints { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 时间约束开始时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "TcStartTime")]
|
||||
public DateTime? TcStartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 时间约束结束时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "TcEndTime")]
|
||||
public DateTime? TcEndTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 飞行速度
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "FlySpeed")]
|
||||
[MaxLength(30)]
|
||||
public string FlySpeed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 云台俯仰角
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "GimbalPitchDegree")]
|
||||
[MaxLength(35)]
|
||||
public string GimbalPitchDegree { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 识别对象画面占比
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "RecognitionCoverage")]
|
||||
[MaxLength(10)]
|
||||
public string RecognitionCoverage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标签
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Tags")]
|
||||
[MaxLength(255)]
|
||||
public string Tags { get; set; }
|
||||
}
|
||||
|
|
@ -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<Response<bool>> AddAlgoInstance(LasaAlgoInstance info)
|
||||
{
|
||||
return await _app.AddAlgoInstance(info);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<Response<bool>> DeleteAlgoInstance(string id)
|
||||
{
|
||||
return await _app.DeleteAlgoInstance(id);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<Response<bool>> UpdateAlgoInstance(LasaAlgoInstance info)
|
||||
{
|
||||
return await _app.UpdateAlgoInstance(info);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<Response<PageInfo<List<LasaAlgoInstance>>>> GetAlgoInstanceList(AlgoInstancePageRequest req)
|
||||
{
|
||||
return await _app.GetAlgoInstanceList(req);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue