46 lines
1.3 KiB
C#
46 lines
1.3 KiB
C#
using Dlhis.Basic.Map.Request;
|
|
using Dlhis.Basic.Map.Response;
|
|
using Dlhis.Entity.Basic.Entity;
|
|
using Kurisu.AspNetCore.DataAccess.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<PointMapDetailEntity>();
|
|
await _dbContext.InsertAsync(entity);
|
|
}
|
|
else
|
|
{
|
|
var entity = await _dbContext.Queryable<PointMapDetailEntity>().Where(x => x.Id == request.Id).SingleAsync();
|
|
request.Adapt(entity);
|
|
await _dbContext.UpdateAsync(entity);
|
|
}
|
|
}
|
|
|
|
public async Task DeleteAsync(long id)
|
|
{
|
|
await _dbContext.Deleteable<PointMapDetailEntity>().Where(x => x.Id == id).ExecuteCommandAsync();
|
|
}
|
|
|
|
public async Task<List<PointMapDetailResponse>> GetListByPointMapCodeAsync(Guid pointMapCode)
|
|
{
|
|
return await _dbContext.Queryable<PointMapDetailEntity>()
|
|
.Where(x => x.PointMapCode == pointMapCode)
|
|
.Select<PointMapDetailResponse>()
|
|
.ToListAsync();
|
|
}
|
|
}
|