refactor 优化代码

This commit is contained in:
2024-11-26 15:26:12 +08:00
parent a32910f0d9
commit 623a5c4e49
88 changed files with 1820 additions and 941 deletions

View File

@@ -1,7 +1,5 @@
using Dlhis.ScheduledTask.Common.Request;
using Dlhis.ScheduledTask.Common.Services;
using Dlhis.ScheduledTask.TaskAssignment.Request;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
using Dlhis.Basic.Api;
using Dlhis.Jip.Api.Request;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -10,18 +8,16 @@ namespace Dlhis.ScheduledTask.TaskAssignment.Controllers;
/// <summary>
/// 调度任务
/// </summary>
[Authorize(Roles = "admin")]
[AllowAnonymous]
[Route("api/[controller]")]
[ApiController]
public class HangfireController : ControllerBase
{
private readonly IHangfireService _hangfireService;
private readonly IDbContext _dbContext;
private readonly ISyncApi _gainfoSyncApi;
public HangfireController(IHangfireService hangfireService, IDbContext dbContext)
public HangfireController(ISyncApi gainfoSyncApi)
{
_hangfireService = hangfireService;
_dbContext = dbContext;
_gainfoSyncApi = gainfoSyncApi;
}
/// <summary>
@@ -29,11 +25,10 @@ public class HangfireController : ControllerBase
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[AllowAnonymous]
[HttpPost("sap/person/no")]
public async Task PersonManuallySync(SapNoRequest request)
{
await _hangfireService.CreateSapPersonSyncBackgroundJobAsync(request);
await _gainfoSyncApi.SyncGainfoByUserCodeAsync(request.Code);
}
/// <summary>
@@ -44,13 +39,6 @@ public class HangfireController : ControllerBase
[HttpPost("sap/werk/no")]
public async Task WerkManuallySync(SapNoRequest request)
{
await _hangfireService.CreateSapWerkSyncBackgroundJobAsync(request);
}
[AllowAnonymous]
[HttpPost("sap/face")]
public async Task FaceUploadToSapAsync(FaceUploadToSapRequest request)
{
await _hangfireService.FaceUploadToSapAsync(request);
await _gainfoSyncApi.SyncGainfoByWerkAsync(request.Code);
}
}