feat 点位图

This commit is contained in:
2024-04-02 16:59:26 +08:00
parent 6d2384f93f
commit 318491d2f1
13 changed files with 426 additions and 2 deletions

View File

@@ -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<Pagination<PointMapResponse>> GetPageAsync(PageDto request)
{
return await _dbContext.Queryable<PointMapEntity>()
.Select<PointMapResponse>()
.ToPageListAsync(request);
}
public async Task SaveAsync(SavePointMapRequest request)
{
if (!request.Id.HasValue)
{
var entity = request.Adapt<PointMapEntity>();
entity.Code = Guid.NewGuid();
await _dbContext.InsertAsync(entity);
}
else
{
var entity = await _dbContext.Queryable<PointMapEntity>().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<PointMapEntity>().Where(x => x.Id == id).SingleAsync();
if (entity != null)
{
await _dbContext.Deleteable<PointMapEntity>().Where(x => x.Id == id).ExecuteCommandAsync();
await _dbContext.Deleteable<PointMapDetailEntity>().Where(x => x.PointMapCode == entity.Code).ExecuteCommandAsync();
}
}
}