feat 点位图
This commit is contained in:
56
Src/Dlhis.Basic/Map/Services/Implements/PointMapService.cs
Normal file
56
Src/Dlhis.Basic/Map/Services/Implements/PointMapService.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user