feat 卡类型编辑

This commit is contained in:
2025-01-03 11:56:06 +08:00
parent d7ab8f27e6
commit fddf77858e
10 changed files with 129 additions and 43 deletions

View File

@@ -1,6 +1,9 @@
using Dlhis.Basic.Organization.Request;
using Dlhis.Basic.Device.Services;
using Dlhis.Basic.Organization.Request;
using Dlhis.Basic.Organization.Response;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Device.Enums;
using Kurisu.AspNetCore.CustomClass;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
using Kurisu.AspNetCore.Utils.Extensions;
using Mapster;
@@ -11,11 +14,18 @@ public class GainfoCardService : IGainfoCardService
{
private readonly IDbContext _dbContext;
private readonly IGainfoStore _gainfoStore;
private readonly IDevicePermissionService _devicePermissionService;
private readonly IGainfoPermissionService _gainfoPermissionService;
public GainfoCardService(IDbContext dbContext, IGainfoStore gainfoStore)
public GainfoCardService(IDbContext dbContext,
IGainfoStore gainfoStore,
IDevicePermissionService devicePermissionService,
IGainfoPermissionService gainfoPermissionService)
{
_dbContext = dbContext;
_gainfoStore = gainfoStore;
_devicePermissionService = devicePermissionService;
_gainfoPermissionService = gainfoPermissionService;
}
public async Task ChangeCardAsync(GainfoChangeCardRequest request)
@@ -46,4 +56,37 @@ public class GainfoCardService : IGainfoCardService
})
.ToListAsync();
}
public async Task<List<KeyValueDto<string, string>>> GetCardTypesAsync()
{
var r = new List<KeyValueDto<string, string>>
{
new()
{
Key = "行政卡", Value = "2"
},
new()
{
Key = "车间卡", Value = "3"
}
};
return await Task.FromResult(r);
}
public async Task EditCardTypeAsync(string code, int typeId)
{
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Code == code).SingleAsync();
gainfo.ThrowIfNull("人员不存在");
gainfo.CardType = typeId;
var myDeviceCodes = await _devicePermissionService.GetUserDeviceCodesByNoAsync(gainfo.No);
var deviceCodes = await _dbContext.Queryable<DeviceEntity>()
.Where(x => myDeviceCodes.Contains(x.Code))
.Where(x => x.EnableTimePeriod)
.Select(x => x.Code)
.ToListAsync();
await _gainfoPermissionService.ResetPermissionsAsync(gainfo.No, DeviceTaskEnumType.Update, deviceCodes, "卡类型编辑下发");
}
}