feat 根据工号获取人脸链接
This commit is contained in:
@@ -145,8 +145,18 @@ public class DevicesController : ControllerBase
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Pagination<DeviceResponse>> GetDeviceByNoAsync([FromQuery]DevicePageRequest request)
|
||||
public async Task<Pagination<DeviceResponse>> GetDeviceByNoAsync([FromQuery] DevicePageRequest request)
|
||||
{
|
||||
return await _deviceService.GetDeviceByNoAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取考勤设备
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("attendances")]
|
||||
public async Task<List<DeviceResponse>> GetAttendanceDevicesAsync()
|
||||
{
|
||||
return await _deviceService.GetAttendanceDevicesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,17 +74,6 @@ public class DeviceResponse
|
||||
/// </summary>
|
||||
public string ConnectionInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后使用人
|
||||
/// </summary>
|
||||
public DateTime LastLogId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后使用日期
|
||||
/// </summary>
|
||||
public DateTime LastLogDateTime { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
|
||||
@@ -13,4 +13,6 @@ public interface IDeviceService : IScopeDependency
|
||||
Task<bool> CheckExistsAsync(string deviceUniqueNo);
|
||||
|
||||
Task<Pagination<DeviceResponse>> GetDeviceByNoAsync(DevicePageRequest request);
|
||||
|
||||
Task<List<DeviceResponse>> GetAttendanceDevicesAsync();
|
||||
}
|
||||
|
||||
@@ -164,5 +164,10 @@ public class DeviceService : IDeviceService
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
public Task<List<DeviceResponse>> GetAttendanceDevicesAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,5 +112,16 @@ public class GainfosController : ControllerBase
|
||||
{
|
||||
return await _gainfoService.GetFaceAsync(token);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取人脸照片
|
||||
/// </summary>
|
||||
/// <param name="userCode"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("face/{userCode}")]
|
||||
public async Task<string> GetFaceByUserCodeAsync(string userCode)
|
||||
{
|
||||
return await _gainfoService.GetFaceByUserCodeAsync(userCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,4 +22,6 @@ public interface IGainfoService : IScopeDependency
|
||||
Task UploadFaceAsync(GainfoUploadFaceRequest request);
|
||||
|
||||
Task<IActionResult> GetFaceAsync(string token);
|
||||
|
||||
Task<string> GetFaceByUserCodeAsync(string userCode);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
using System.Threading.Tasks;
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Basic.Enums;
|
||||
@@ -13,6 +14,8 @@ using Kurisu.SqlSugar.Services;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
using NetTaste;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Services.Implements;
|
||||
|
||||
@@ -266,4 +269,44 @@ public class GainfoService : IGainfoService
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<string> GetFaceByUserCodeAsync(string userCode)
|
||||
{
|
||||
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Code == userCode).SingleAsync();
|
||||
gainfo.ThrowIfNull("人员信息不存在");
|
||||
|
||||
return await Scoped.Request.Value.CreateAsync<string>(async (sp) =>
|
||||
{
|
||||
var configuration = sp.GetService<IConfiguration>();
|
||||
|
||||
var faceConnectionString = configuration.GetSection("SqlSugarOptions:FaceConnectionString").Value;
|
||||
if (faceConnectionString.IsEmpty())
|
||||
{
|
||||
throw new UserFriendlyException("暂不支持获取人脸");
|
||||
}
|
||||
|
||||
var dbContext = sp.GetService<IDbContext>();
|
||||
//todo 切换连接字符串
|
||||
dbContext.Client.CurrentConnectionConfig.ConnectionString = faceConnectionString;
|
||||
|
||||
var face = await dbContext.Queryable<GainfoFaceEntity>()
|
||||
.Where(x => x.UserCode == userCode)
|
||||
.SingleAsync();
|
||||
|
||||
face.ThrowIfNull("人脸照片尚未录入");
|
||||
|
||||
var timeLimitedDataProtector = sp.GetService<IDataProtectionProvider>()
|
||||
.CreateProtector("down:face")
|
||||
.ToTimeLimitedDataProtector();
|
||||
|
||||
var faceUrl = configuration.GetSection("FaceUrlOptions:Url").Value;
|
||||
var limit = configuration.GetSection("FaceUrlOptions:Limit").Get<int>();
|
||||
var dataProtectionProvider = sp.GetService<IDataProtectionProvider>();
|
||||
|
||||
var key = $"face:{userCode}";
|
||||
var token = timeLimitedDataProtector.Protect(key, TimeSpan.FromSeconds(limit));
|
||||
|
||||
return faceUrl + token;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
"CommonRequestUrl": "http://common",
|
||||
"UserRequestUrl": "http://user"
|
||||
},
|
||||
"FaceUrlOptions": {
|
||||
"Url": "https://yikatong.isawesome.cn/api/basic/gainfos/face?token=",
|
||||
"Limit": 7200
|
||||
},
|
||||
"SqlSugarOptions": {
|
||||
"DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=yikatong;charset=utf8mb4;",
|
||||
"SlaveConnectionString": [],
|
||||
|
||||
@@ -77,19 +77,6 @@ public class DeviceEntity : SugarBaseEntity, ITenantId
|
||||
[SugarColumn(ColumnDescription = "连接信息")]
|
||||
public string ConnectionInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后使用人
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true, ColumnDescription = "最后使用人")]
|
||||
public DateTime? LastLogId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后使用日期
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true, ColumnDescription = "最后使用日期")]
|
||||
public DateTime? LastLogDateTime { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
namespace Dlhis.Entity.Device.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// 机器设备功能
|
||||
/// 设备功能
|
||||
/// </summary>
|
||||
[Description("机器设备功能")]
|
||||
[Description("设备功能")]
|
||||
public enum DeviceFuncEnumType
|
||||
{
|
||||
/// <summary>
|
||||
@@ -26,14 +26,12 @@ public enum DeviceFuncEnumType
|
||||
[Description("人脸")]
|
||||
Face,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 刷卡
|
||||
/// </summary>
|
||||
[Description("刷卡")]
|
||||
Card,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 二维码
|
||||
/// </summary>
|
||||
@@ -46,4 +44,10 @@ public enum DeviceFuncEnumType
|
||||
/// </summary>
|
||||
[Description("布控")]
|
||||
Control,
|
||||
|
||||
/// <summary>
|
||||
/// 考勤
|
||||
/// </summary>
|
||||
[Description("考勤")]
|
||||
Attendance,
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ public class AssignmentService : IAssignmentService
|
||||
|
||||
return Scoped.Request.Value.Create((sp) =>
|
||||
{
|
||||
FaceUrlOptions faceUrlOptions = sp.GetService<IOptions<FaceUrlOptions>>().Value;
|
||||
var faceUrlOptions = sp.GetService<IOptions<FaceUrlOptions>>().Value;
|
||||
var dataProtectionProvider = sp.GetService<IDataProtectionProvider>();
|
||||
|
||||
var timeLimitedDataProtector = dataProtectionProvider
|
||||
|
||||
Reference in New Issue
Block a user