feat 人员指纹数据
This commit is contained in:
@@ -0,0 +1,46 @@
|
|||||||
|
using Dlhis.Basic.Organization.Request;
|
||||||
|
using Dlhis.Basic.Organization.Response;
|
||||||
|
using Dlhis.Basic.Organization.Services;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace Dlhis.Basic.Organization.Controllers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户指纹数据
|
||||||
|
/// </summary>
|
||||||
|
[Authorize]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class GainfoFingerprintsController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly IGainfoFingerprintService _gainfoFingerprintService;
|
||||||
|
|
||||||
|
public GainfoFingerprintsController(IGainfoFingerprintService gainfoFingerprintService)
|
||||||
|
{
|
||||||
|
_gainfoFingerprintService = gainfoFingerprintService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 采集
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("collect")]
|
||||||
|
public async Task CollectFingerprintAsync(FingerprintCollectRequest request)
|
||||||
|
{
|
||||||
|
await _gainfoFingerprintService.CollectFingerprintAsync(request.UserCode, request.FingerNum, request.Fingerprint);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取人员指纹数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userCode"></param>
|
||||||
|
/// <param name="fingerNum"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("fingerprints")]
|
||||||
|
public async Task<List<GainfoFingerprintResponse>> GetFingerprintAsync(string userCode, int fingerNum)
|
||||||
|
{
|
||||||
|
return await _gainfoFingerprintService.GetFingerprintAsync(userCode, fingerNum);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace Dlhis.Basic.Organization.Request
|
||||||
|
{
|
||||||
|
public class FingerprintCollectRequest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用户工号
|
||||||
|
/// </summary>
|
||||||
|
[Required(ErrorMessage = "用户工号不能为空")]
|
||||||
|
public string UserCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 手指编号
|
||||||
|
/// </summary>
|
||||||
|
[Range(1, 10, ErrorMessage = "手指编号有误,请输入1到10之间的数字")]
|
||||||
|
public int FingerNum { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指纹数据
|
||||||
|
/// </summary>
|
||||||
|
[Required(ErrorMessage = "指纹数据不能为空")]
|
||||||
|
public string Fingerprint { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
namespace Dlhis.Basic.Organization.Response;
|
||||||
|
|
||||||
|
public class GainfoFingerprintResponse
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用户工号
|
||||||
|
/// </summary>
|
||||||
|
public string UserCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户名称
|
||||||
|
/// </summary>
|
||||||
|
public string UserName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 部门号
|
||||||
|
/// </summary>
|
||||||
|
public string DepartmentNo { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 部门名称
|
||||||
|
/// </summary>
|
||||||
|
public string DepartmentName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指纹号
|
||||||
|
/// </summary>
|
||||||
|
public int FingerNum { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指纹数据
|
||||||
|
/// </summary>
|
||||||
|
public string Fingerprint { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using Dlhis.Basic.Organization.Response;
|
||||||
|
|
||||||
|
namespace Dlhis.Basic.Organization.Services;
|
||||||
|
|
||||||
|
public interface IGainfoFingerprintService : IScopeDependency
|
||||||
|
{
|
||||||
|
Task CollectFingerprintAsync(string userCode, int fingerNum, string fingerprint);
|
||||||
|
|
||||||
|
Task<List<GainfoFingerprintResponse>> GetFingerprintAsync(string userCode, int fingerNum);
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
using Dlhis.Basic.Organization.Response;
|
||||||
|
using Dlhis.Entity.Basic.Entity;
|
||||||
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||||
|
|
||||||
|
namespace Dlhis.Basic.Organization.Services.Implements
|
||||||
|
{
|
||||||
|
public class GainfoFingerprintService : IGainfoFingerprintService
|
||||||
|
{
|
||||||
|
private readonly IDbContext _dbContext;
|
||||||
|
|
||||||
|
public GainfoFingerprintService(IDbContext dbContext)
|
||||||
|
{
|
||||||
|
_dbContext = dbContext;
|
||||||
|
}
|
||||||
|
public async Task CollectFingerprintAsync(string userCode, int fingerNum, string fingerprint)
|
||||||
|
{
|
||||||
|
var gainfoFingerprint = await _dbContext.Queryable<GainfoFingerprintEntity>().Where(x => x.UserCode == userCode && x.FingerNum == fingerNum).FirstAsync();
|
||||||
|
if (gainfoFingerprint == null)
|
||||||
|
{
|
||||||
|
gainfoFingerprint = new GainfoFingerprintEntity
|
||||||
|
{
|
||||||
|
UserCode = userCode,
|
||||||
|
FingerNum = fingerNum,
|
||||||
|
Fingerprint = fingerprint
|
||||||
|
};
|
||||||
|
await _dbContext.InsertAsync(gainfoFingerprint);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gainfoFingerprint.Fingerprint = fingerprint;
|
||||||
|
await _dbContext.UpdateAsync(gainfoFingerprint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<GainfoFingerprintResponse>> GetFingerprintAsync(string userCode, int fingerNum)
|
||||||
|
{
|
||||||
|
return await _dbContext.Queryable<GainfoFingerprintEntity>()
|
||||||
|
.LeftJoin<GainfoEntity>((x, ga) => x.UserCode == ga.Code)
|
||||||
|
.LeftJoin<DepartmentEntity>((x, ga, dept) => ga.DepartmentNo == dept.No)
|
||||||
|
.Select((x, ga, dept) => new GainfoFingerprintResponse
|
||||||
|
{
|
||||||
|
UserCode = x.UserCode,
|
||||||
|
UserName = ga.Name,
|
||||||
|
DepartmentNo = dept.No,
|
||||||
|
DepartmentName = dept.Name,
|
||||||
|
FingerNum = x.FingerNum,
|
||||||
|
Fingerprint = x.Fingerprint
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
34
Src/Dlhis.Entity/Basic/Entity/GainfoFingerprintEntity.cs
Normal file
34
Src/Dlhis.Entity/Basic/Entity/GainfoFingerprintEntity.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
using Kurisu.AspNetCore.DataAccess.Entity;
|
||||||
|
using Kurisu.AspNetCore.DataAccess.SqlSugar;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Dlhis.Entity.Basic.Entity;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 人员指纹数据
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable(TableName = "GainfoFingerprints", TableDescription = "人员指纹数据")]
|
||||||
|
public class GainfoFingerprintEntity : SugarBaseEntity, ITenantId
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 工号
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(UniqueGroupNameList = new[] { "idx_GainfoFingerprints_userCode_fingerNum" })]
|
||||||
|
public string UserCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 手指号, 为1-10, 代表左右手的五个手指, 左小指为1, 左无名指为2, 左中指为3, 左食指为4, 左拇指为5, 右拇指为6, 右食指为7, 右中指为8, 右无名指为9, 右小指为10
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(UniqueGroupNameList = new[] { "idx_GainfoFingerprints_userCode_fingerNum" })]
|
||||||
|
public int FingerNum { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指纹数据
|
||||||
|
/// </summary>
|
||||||
|
public string Fingerprint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 租户ID
|
||||||
|
/// </summary>
|
||||||
|
public string TenantId { get; set; }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user