32 lines
1001 B
C#
32 lines
1001 B
C#
using Dlhis.Entity.Device.Entities;
|
|
using Dlhis.ScheduledTask.DeviceUploadLog.Request;
|
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
|
|
|
namespace Dlhis.ScheduledTask.DeviceUploadLog.Services.Implements;
|
|
|
|
public class DeviceUserService : IDeviceUserService
|
|
{
|
|
private readonly IDbContext _dbContext;
|
|
|
|
public DeviceUserService(IDbContext dbContext)
|
|
{
|
|
_dbContext = dbContext;
|
|
}
|
|
|
|
public async Task UploadAsync(DeviceUploadUserCodeRequest request)
|
|
{
|
|
if (!await _dbContext.Queryable<DeviceUserEntity>().Where(x => x.DeviceUniqueNo == request.DeviceUniqueNo).AnyAsync())
|
|
{
|
|
var userCodes = request.UserCodes.Distinct().ToList();
|
|
|
|
var entities = userCodes.Select(userCode => new DeviceUserEntity
|
|
{
|
|
DeviceUniqueNo = request.DeviceUniqueNo,
|
|
UserCode = userCode,
|
|
IsDeleted = false
|
|
}).ToList();
|
|
|
|
await _dbContext.InsertAsync(entities);
|
|
}
|
|
}
|
|
} |