diff --git a/Src/Dlhis.Basic/Map/Controllers/PointMapsController.cs b/Src/Dlhis.Basic/Map/Controllers/PointMapsController.cs new file mode 100644 index 00000000..eaf928eb --- /dev/null +++ b/Src/Dlhis.Basic/Map/Controllers/PointMapsController.cs @@ -0,0 +1,93 @@ +using Dlhis.Basic.Map.Request; +using Dlhis.Basic.Map.Response; +using Dlhis.Basic.Map.Services; +using Kurisu.Core.DataAccess.Dto; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace Dlhis.Basic.Map.Controllers; + +/// +/// 点位图 +/// +[Authorize] +[Route("api/[controller]")] +[ApiController] +public class PointMapsController : ControllerBase +{ + private readonly IPointMapService _pointMapService; + private readonly IPointMapDetailService _pointMapDetailService; + + public PointMapsController(IPointMapService pointMapService, + IPointMapDetailService pointMapDetailService) + { + _pointMapService = pointMapService; + _pointMapDetailService = pointMapDetailService; + } + + /// + /// 点位图分页 + /// + /// + /// + [HttpGet("page")] + public async Task> GetPointMapPageAsync([FromQuery] PageDto request) + { + return await _pointMapService.GetPageAsync(request); + } + + /// + /// 保存点位图 + /// + /// + /// + [HttpPost("save")] + public async Task SavePointMapAsync(SavePointMapRequest request) + { + await _pointMapService.SaveAsync(request); + } + + /// + /// 删除点位图 + /// + /// + /// + [HttpDelete("{id}")] + public async Task DeletePointMapAsync(long id) + { + await _pointMapService.DeleteAsync(id); + } + + /// + /// 点位数据明细保存 + /// + /// + /// + [HttpPost("detail/save")] + public async Task SaveDetailAsync(SavePointMapDetailRequest request) + { + await _pointMapDetailService.SaveAsync(request); + } + + /// + /// 点位数据明细 + /// + /// + /// + [HttpGet("detail/list")] + public async Task> GetDetailListByPointMapCodeAsync([FromQuery] Guid pointMapCode) + { + return await _pointMapDetailService.GetListByPointMapCodeAsync(pointMapCode); + } + + /// + /// 删除点位数据明细 + /// + /// + /// + [HttpDelete("detail/{id}")] + public async Task DeleteDetailAsync(long id) + { + await _pointMapDetailService.DeleteAsync(id); + } +} diff --git a/Src/Dlhis.Basic/Map/Request/SavePointMapDetailRequest.cs b/Src/Dlhis.Basic/Map/Request/SavePointMapDetailRequest.cs new file mode 100644 index 00000000..3cec3f52 --- /dev/null +++ b/Src/Dlhis.Basic/Map/Request/SavePointMapDetailRequest.cs @@ -0,0 +1,38 @@ +using Dlhis.Entity.Basic.Enums; +using System.ComponentModel.DataAnnotations; + +namespace Dlhis.Basic.Map.Request; + +public class SavePointMapDetailRequest +{ + public long? Id { get; set; } + + /// + /// 点位图code + /// + [Required] + public Guid PointMapCode { get; set; } + + /// + /// 数据code 如果是设备那么为设备code + /// + [Required] + public Guid UniqueCode { get; set; } + + /// + /// 数据类型 PointMapDetailEnumType + /// + [EnumDataType(typeof(PointMapDetailEnumType))] + public PointMapDetailEnumType Type { get; set; } + + /// + /// XYZ + /// + [Required] + public string Position { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } +} diff --git a/Src/Dlhis.Basic/Map/Request/SavePointMapRequest.cs b/Src/Dlhis.Basic/Map/Request/SavePointMapRequest.cs new file mode 100644 index 00000000..3195ac5d --- /dev/null +++ b/Src/Dlhis.Basic/Map/Request/SavePointMapRequest.cs @@ -0,0 +1,22 @@ +using System.ComponentModel.DataAnnotations; + +namespace Dlhis.Basic.Map.Request; + +public class SavePointMapRequest +{ + public long? Id { get; set; } + + /// + /// 位置名称 + /// + [Required(ErrorMessage = "位置名称不可为空")] + public string Name { get; set; } + + /// + /// 图 + /// + [Required(ErrorMessage = "图片不可为空")] + public string ImageUrl { get; set; } + + public string Remark { get; set; } +} diff --git a/Src/Dlhis.Basic/Map/Response/PointMapDetailResponse.cs b/Src/Dlhis.Basic/Map/Response/PointMapDetailResponse.cs new file mode 100644 index 00000000..2528f29f --- /dev/null +++ b/Src/Dlhis.Basic/Map/Response/PointMapDetailResponse.cs @@ -0,0 +1,26 @@ +using Dlhis.Entity.Basic.Enums; + +namespace Dlhis.Basic.Map.Response; + +public class PointMapDetailResponse +{ + /// + /// 数据code + /// + public Guid UniqueCode { get; set; } + + /// + /// 数据类型 + /// + public PointMapDetailEnumType Type { get; set; } + + /// + /// XYZ + /// + public string Position { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } +} diff --git a/Src/Dlhis.Basic/Map/Response/PointMapResponse.cs b/Src/Dlhis.Basic/Map/Response/PointMapResponse.cs new file mode 100644 index 00000000..44bcad67 --- /dev/null +++ b/Src/Dlhis.Basic/Map/Response/PointMapResponse.cs @@ -0,0 +1,23 @@ +using SqlSugar; + +namespace Dlhis.Basic.Map.Response; + +public class PointMapResponse +{ + public long Id { get; set; } + + public Guid Code { get; set; } + + /// + /// 位置名称 + /// + public string Name { get; set; } + + /// + /// 图 + /// + public string ImageUrl { get; set; } + + + public string Remark { get; set; } +} diff --git a/Src/Dlhis.Basic/Map/Services/IPointMapDetailService.cs b/Src/Dlhis.Basic/Map/Services/IPointMapDetailService.cs new file mode 100644 index 00000000..3a060636 --- /dev/null +++ b/Src/Dlhis.Basic/Map/Services/IPointMapDetailService.cs @@ -0,0 +1,13 @@ +using Dlhis.Basic.Map.Request; +using Dlhis.Basic.Map.Response; + +namespace Dlhis.Basic.Map.Services; + +public interface IPointMapDetailService : IScopeDependency +{ + Task SaveAsync(SavePointMapDetailRequest request); + + Task DeleteAsync(long id); + + Task> GetListByPointMapCodeAsync(Guid pointMapCode); +} diff --git a/Src/Dlhis.Basic/Map/Services/IPointMapService.cs b/Src/Dlhis.Basic/Map/Services/IPointMapService.cs new file mode 100644 index 00000000..d91d8010 --- /dev/null +++ b/Src/Dlhis.Basic/Map/Services/IPointMapService.cs @@ -0,0 +1,14 @@ +using Dlhis.Basic.Map.Request; +using Dlhis.Basic.Map.Response; +using Kurisu.Core.DataAccess.Dto; + +namespace Dlhis.Basic.Map.Services; + +public interface IPointMapService : IScopeDependency +{ + Task> GetPageAsync(PageDto request); + + Task SaveAsync(SavePointMapRequest request); + + Task DeleteAsync(long id); +} diff --git a/Src/Dlhis.Basic/Map/Services/Implements/PointMapDetailService.cs b/Src/Dlhis.Basic/Map/Services/Implements/PointMapDetailService.cs new file mode 100644 index 00000000..44563249 --- /dev/null +++ b/Src/Dlhis.Basic/Map/Services/Implements/PointMapDetailService.cs @@ -0,0 +1,45 @@ +using Dlhis.Basic.Map.Request; +using Dlhis.Basic.Map.Response; +using Dlhis.Entity.Basic.Entity; +using Kurisu.SqlSugar.Services; +using Mapster; + +namespace Dlhis.Basic.Map.Services.Implements; + +public class PointMapDetailService : IPointMapDetailService +{ + private readonly IDbContext _dbContext; + + public PointMapDetailService(IDbContext dbContext) + { + _dbContext = dbContext; + } + + public async Task SaveAsync(SavePointMapDetailRequest request) + { + if (!request.Id.HasValue) + { + var entity = request.Adapt(); + await _dbContext.InsertAsync(entity); + } + else + { + var entity = await _dbContext.Queryable().Where(x => x.Id == request.Id).SingleAsync(); + request.Adapt(entity); + await _dbContext.UpdateAsync(entity); + } + } + + public async Task DeleteAsync(long id) + { + await _dbContext.Deleteable().Where(x => x.Id == id).ExecuteCommandAsync(); + } + + public async Task> GetListByPointMapCodeAsync(Guid pointMapCode) + { + return await _dbContext.Queryable() + .Where(x => x.PointMapCode == pointMapCode) + .Select() + .ToListAsync(); + } +} diff --git a/Src/Dlhis.Basic/Map/Services/Implements/PointMapService.cs b/Src/Dlhis.Basic/Map/Services/Implements/PointMapService.cs new file mode 100644 index 00000000..fe5f1338 --- /dev/null +++ b/Src/Dlhis.Basic/Map/Services/Implements/PointMapService.cs @@ -0,0 +1,56 @@ +using Dlhis.Basic.Map.Request; +using Dlhis.Basic.Map.Response; +using Dlhis.Entity.Basic.Entity; +using Kurisu.AspNetCore.Utils.Extensions; +using Kurisu.Core.DataAccess.Dto; +using Kurisu.SqlSugar.Extensions; +using Kurisu.SqlSugar.Services; +using Mapster; + +namespace Dlhis.Basic.Map.Services.Implements; + +public class PointMapService : IPointMapService +{ + private readonly IDbContext _dbContext; + + public PointMapService(IDbContext dbContext) + { + _dbContext = dbContext; + } + + + public async Task> GetPageAsync(PageDto request) + { + return await _dbContext.Queryable() + .Select() + .ToPageListAsync(request); + } + + public async Task SaveAsync(SavePointMapRequest request) + { + if (!request.Id.HasValue) + { + var entity = request.Adapt(); + entity.Code = Guid.NewGuid(); + + await _dbContext.InsertAsync(entity); + } + else + { + var entity = await _dbContext.Queryable().Where(x => x.Id == request.Id).SingleAsync(); + entity.ThrowIfNull("点位图不存在,无法编辑!"); + request.Adapt(entity); + await _dbContext.UpdateAsync(entity); + } + } + + public async Task DeleteAsync(long id) + { + var entity = await _dbContext.Queryable().Where(x => x.Id == id).SingleAsync(); + if (entity != null) + { + await _dbContext.Deleteable().Where(x => x.Id == id).ExecuteCommandAsync(); + await _dbContext.Deleteable().Where(x => x.PointMapCode == entity.Code).ExecuteCommandAsync(); + } + } +} diff --git a/Src/Dlhis.Canteen/MealSupplementRecord/Response/MealSupplementRecordResponse.cs b/Src/Dlhis.Canteen/MealSupplementRecord/Response/MealSupplementRecordResponse.cs index fe39466d..01d8baf3 100644 --- a/Src/Dlhis.Canteen/MealSupplementRecord/Response/MealSupplementRecordResponse.cs +++ b/Src/Dlhis.Canteen/MealSupplementRecord/Response/MealSupplementRecordResponse.cs @@ -1,6 +1,4 @@ using Dlhis.Entity.Basic.Enums; -using SqlSugar.DbConvert; -using SqlSugar; using Kurisu.AspNetCore.Utils.Extensions; namespace Dlhis.Canteen.MealSupplementRecord.Response; diff --git a/Src/Dlhis.Entity/Basic/Entity/PointMapDetailEntity.cs b/Src/Dlhis.Entity/Basic/Entity/PointMapDetailEntity.cs new file mode 100644 index 00000000..eb95854f --- /dev/null +++ b/Src/Dlhis.Entity/Basic/Entity/PointMapDetailEntity.cs @@ -0,0 +1,44 @@ +using Dlhis.Entity.Basic.Enums; +using Kurisu.Core.DataAccess.Entity; +using Kurisu.SqlSugar; +using SqlSugar; +using SqlSugar.DbConvert; + +namespace Dlhis.Entity.Basic.Entity; + +/// +/// 点位图数据 +/// +[SugarTable(TableName = "PointMapDetail", TableDescription = "点位图数据")] +public class PointMapDetailEntity : SugarBaseEntity, ITenantId +{ + /// + /// 点位图code + /// + [SugarColumn(IsNullable = false, ColumnDescription = "点位图code")] + public Guid PointMapCode { get; set; } + + /// + /// 数据code + /// + public Guid UniqueCode { get; set; } + + /// + /// 数据类型 + /// + [SugarColumn(IsNullable = false, ColumnDescription = "数据类型", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))] + public PointMapDetailEnumType Type { get; set; } + + /// + /// XYZ + /// + [SugarColumn(IsNullable = false, ColumnDescription = "XYZ")] + public string Position { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } + + public string TenantId { get; set; } +} diff --git a/Src/Dlhis.Entity/Basic/Entity/PointMapEntity.cs b/Src/Dlhis.Entity/Basic/Entity/PointMapEntity.cs new file mode 100644 index 00000000..53414e4e --- /dev/null +++ b/Src/Dlhis.Entity/Basic/Entity/PointMapEntity.cs @@ -0,0 +1,36 @@ +using Kurisu.Core.DataAccess.Entity; +using Kurisu.SqlSugar; +using SqlSugar; + +namespace Dlhis.Entity.Basic.Entity; + +/// +/// 点位图 +/// +[SugarTable(TableName = "PointMaps", TableDescription = "点位图")] +public class PointMapEntity : SugarBaseEntity, ITenantId, IImageUrl +{ + /// + /// code + /// + [SugarColumn(IsNullable = false, ColumnDescription = "code")] + public Guid Code { get; set; } + + /// + /// 位置名称 + /// + [SugarColumn(IsNullable = false, ColumnDescription = "点位名称")] + public string Name { get; set; } + + /// + /// 图 + /// + [SugarColumn(IsNullable = false, ColumnDescription = "图片地址")] + public string ImageUrl { get; set; } + + + [SugarColumn(ColumnDescription = "备注")] + public string Remark { get; set; } + + public string TenantId { get; set; } +} diff --git a/Src/Dlhis.Entity/Basic/Enums/PointMapDetailEnumType.cs b/Src/Dlhis.Entity/Basic/Enums/PointMapDetailEnumType.cs new file mode 100644 index 00000000..df499bc3 --- /dev/null +++ b/Src/Dlhis.Entity/Basic/Enums/PointMapDetailEnumType.cs @@ -0,0 +1,16 @@ +using System.ComponentModel; + +namespace Dlhis.Entity.Basic.Enums; + +/// +/// 点位图数据类型 +/// +[Description("点位图数据类型")] +public enum PointMapDetailEnumType +{ + /// + /// 设备 + /// + [Description("设备")] + Device = 1, +}