feat 获取我的考勤记录
This commit is contained in:
@@ -37,7 +37,6 @@ public class DevicesController : ControllerBase
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Authorize(Roles = "admin,tenant-admin")]
|
|
||||||
[HttpGet("template/page")]
|
[HttpGet("template/page")]
|
||||||
public async Task<Pagination<DeviceTemplateResponse>> GetTemplatePageAsync([FromQuery] DeviceTemplatePageRequest request)
|
public async Task<Pagination<DeviceTemplateResponse>> GetTemplatePageAsync([FromQuery] DeviceTemplatePageRequest request)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -45,4 +45,15 @@ public class DeviceUploadLogsController : ControllerBase
|
|||||||
{
|
{
|
||||||
await _deviceUploadLogService.UploadLogsAsync(requests);
|
await _deviceUploadLogService.UploadLogsAsync(requests);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取考勤记录
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("my")]
|
||||||
|
public async Task<List<DeviceUploadLogResponse>> GetMyRecordsAsync([FromQuery] DeviceUploadLogMyRecordRequest request)
|
||||||
|
{
|
||||||
|
return await _deviceUploadLogService.GetMyRecordsAsync(request);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using Kurisu.AspNetCore.CustomClass;
|
||||||
|
|
||||||
|
namespace Dlhis.ScheduledTask.DeviceUploadLog.Request;
|
||||||
|
|
||||||
|
public class DeviceUploadLogMyRecordRequest : IValidatableObject
|
||||||
|
{
|
||||||
|
public DateTimePeriod DateTimePeriod { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||||
|
{
|
||||||
|
if (DateTimePeriod == null)
|
||||||
|
{
|
||||||
|
DateTimePeriod = new DateTimePeriod();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DateTimePeriod.Start != null)
|
||||||
|
{
|
||||||
|
DateTimePeriod.End = DateTimePeriod.Start.Value.AddDays(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,4 +9,6 @@ public interface IDeviceUploadLogService : IScopeDependency
|
|||||||
Task<Pagination<DeviceUploadLogResponse>> GetPageAsync(DeviceUploadLogPageRequest request);
|
Task<Pagination<DeviceUploadLogResponse>> GetPageAsync(DeviceUploadLogPageRequest request);
|
||||||
|
|
||||||
Task UploadLogsAsync(List<DeviceUploadLogUploadRequest> requests);
|
Task UploadLogsAsync(List<DeviceUploadLogUploadRequest> requests);
|
||||||
|
|
||||||
|
Task<List<DeviceUploadLogResponse>> GetMyRecordsAsync(DeviceUploadLogMyRecordRequest request);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using Dlhis.Entity.Device.Entities;
|
|||||||
using Dlhis.Entity.Device.Enums;
|
using Dlhis.Entity.Device.Enums;
|
||||||
using Dlhis.ScheduledTask.DeviceUploadLog.Request;
|
using Dlhis.ScheduledTask.DeviceUploadLog.Request;
|
||||||
using Dlhis.ScheduledTask.DeviceUploadLog.Response;
|
using Dlhis.ScheduledTask.DeviceUploadLog.Response;
|
||||||
|
using Kurisu.AspNetCore.Authentication.Abstractions;
|
||||||
using Kurisu.AspNetCore.CustomClass;
|
using Kurisu.AspNetCore.CustomClass;
|
||||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
|
||||||
@@ -15,10 +16,38 @@ namespace Dlhis.ScheduledTask.DeviceUploadLog.Services.Implements;
|
|||||||
public class DeviceUploadLogService : IDeviceUploadLogService
|
public class DeviceUploadLogService : IDeviceUploadLogService
|
||||||
{
|
{
|
||||||
private readonly IDbContext _dbContext;
|
private readonly IDbContext _dbContext;
|
||||||
|
private readonly ICurrentUser _currentUser;
|
||||||
|
|
||||||
public DeviceUploadLogService(IDbContext dbContext)
|
public DeviceUploadLogService(IDbContext dbContext, ICurrentUser currentUser)
|
||||||
{
|
{
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
|
_currentUser = currentUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<List<DeviceUploadLogResponse>> GetMyRecordsAsync(DeviceUploadLogMyRecordRequest request)
|
||||||
|
{
|
||||||
|
var jinkoCode = _currentUser.GetUserClaim("jinko-code") ?? string.Empty;
|
||||||
|
|
||||||
|
return await _dbContext.Queryable<DeviceUploadLogEntity>()
|
||||||
|
.LeftJoin<DeviceEntity>((log, d) => log.DeviceUniqueNo == d.UniqueNo)
|
||||||
|
.Where(log => log.UserUniqueNo == jinkoCode)
|
||||||
|
.WhereIF(request.DateTimePeriod.HasValue(), log => log.RaiseDateTime >= request.DateTimePeriod.Start && log.RaiseDateTime <= request.DateTimePeriod.End)
|
||||||
|
.Where((log, d) => d.Type == DeviceTypeEnumType.Attendance || (d.Type == DeviceTypeEnumType.Door && d.AsAttendance))
|
||||||
|
.OrderBy(log => log.RaiseDateTime)
|
||||||
|
.Select((log, d) => new DeviceUploadLogResponse
|
||||||
|
{
|
||||||
|
OriginUserUniqueNo = log.UserUniqueNo,
|
||||||
|
Supplier = d.Supplier,
|
||||||
|
DeviceUniqueNo = log.DeviceUniqueNo,
|
||||||
|
Id = log.Id,
|
||||||
|
RaiseDateTime = log.RaiseDateTime,
|
||||||
|
CreateTime = log.CreateTime,
|
||||||
|
SerialNo = log.SerialNo,
|
||||||
|
DeployPlace = d.DeployPlace,
|
||||||
|
Sync = log.Sync,
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Pagination<DeviceUploadLogResponse>> GetPageAsync(DeviceUploadLogPageRequest request)
|
public async Task<Pagination<DeviceUploadLogResponse>> GetPageAsync(DeviceUploadLogPageRequest request)
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class RolesController : ControllerBase
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Authorize(Roles = "admin")]
|
[Authorize(Roles = "admin,tenant-admin")]
|
||||||
[HttpPost("assign")]
|
[HttpPost("assign")]
|
||||||
public async Task AssignRole(RoleAssignRequest request)
|
public async Task AssignRole(RoleAssignRequest request)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user