53 lines
2.1 KiB
C#
53 lines
2.1 KiB
C#
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();
|
|
}
|
|
}
|
|
}
|