临时提交2

This commit is contained in:
2025-07-21 18:49:49 +08:00
parent 29a2d44319
commit 525c681b6c
57 changed files with 628 additions and 558 deletions

View File

@@ -1,22 +1,41 @@
using System.Diagnostics;
using AutoMapper;
using DMS.Infrastructure.Entities;
using DMS.Core.Enums;
using DMS.Core.Helper;
using DMS.Core.Interfaces.Repositories;
using DMS.Core.Models;
using DMS.Infrastructure.Data;
using SqlSugar;
using DMS.Infrastructure.Interfaces;
using DMS.Infrastructure.Entities;
namespace DMS.Infrastructure.Repositories;
public class DeviceRepository : BaseRepository<DbDevice>,IDeviceRepository
public class DeviceRepository : BaseRepository<DbDevice>, IDeviceRepository
{
private readonly IMapper _mapper;
public DeviceRepository(SqlSugarDbContext dbContext)
public DeviceRepository(IMapper mapper, SqlSugarDbContext dbContext)
: base(dbContext)
{
_mapper = mapper;
}
public async Task<List<Device>> GetAllAsync()
{
var dbList = await base.GetAllAsync();
return _mapper.Map<List<Device>>(dbList);
}
public async Task<Device> GetByIdAsync(int id)
{
var dbDevice = await base.GetByIdAsync(id);
return _mapper.Map<Device>(dbDevice);
}
public async Task<Device> AddAsync(Device model)
{
var dbDevice = await base.AddAsync(_mapper.Map<DbDevice>(model));
return _mapper.Map(dbDevice, model);
}
public async Task<int> UpdateAsync(Device model) => await base.UpdateAsync(_mapper.Map<DbDevice>(model));
public async Task<int> DeleteAsync(Device model) => await base.DeleteAsync(_mapper.Map<DbDevice>(model));
}