feat 外包人员下发配置
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Services;
|
||||
|
||||
public interface IGainfoOutsourceSettingService : IScopeDependency
|
||||
{
|
||||
Task SaveAsync(GainfoOutsourceSettingSaveRequest request);
|
||||
|
||||
Task<object> GetSettingAsync();
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using Dlhis.Basic.Device.Services;
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Kurisu.AspNetCore.Authentication.Abstractions;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Services.Implements;
|
||||
|
||||
public class GainfoOutsourceSettingService : IGainfoOutsourceSettingService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly ICurrentUser _currentUser;
|
||||
private readonly IDevicePermissionService _devicePermissionService;
|
||||
|
||||
public GainfoOutsourceSettingService(IDbContext dbContext, ICurrentUser currentUser, IDevicePermissionService devicePermissionService)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_currentUser = currentUser;
|
||||
_devicePermissionService = devicePermissionService;
|
||||
}
|
||||
|
||||
public async Task SaveAsync(GainfoOutsourceSettingSaveRequest request)
|
||||
{
|
||||
var userNos = await _dbContext.Queryable<GainfoEntity>()
|
||||
.Where(x => SqlFunc.Subqueryable<OutsourceEntity>().Where(p => p.Code == x.Code).Any())
|
||||
.Select(x => x.No)
|
||||
.ToListAsync();
|
||||
|
||||
await _devicePermissionService.GenerateDeviceTasksAsync(async () =>
|
||||
{
|
||||
var currentTenantId = _currentUser.GetStringTenantId();
|
||||
|
||||
(!request.Id.HasValue && await _dbContext.Queryable<OutsourceSettingEntity>()
|
||||
.Where(x => x.TenantId == currentTenantId)
|
||||
.AnyAsync()).ThrowIfTrue("保存失败,请检查参数");
|
||||
|
||||
if (!request.Id.HasValue)
|
||||
{
|
||||
var entity = new OutsourceSettingEntity
|
||||
{
|
||||
EnableFactory = request.EnableFactory,
|
||||
TenantId = currentTenantId
|
||||
};
|
||||
|
||||
await _dbContext.InsertAsync(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
var entity = await _dbContext.Queryable<OutsourceSettingEntity>().Where(x => x.Id == request.Id).SingleAsync();
|
||||
entity.ThrowIfNull("数据不存在,保存失败");
|
||||
|
||||
entity.EnableFactory = request.EnableFactory;
|
||||
|
||||
await _dbContext.UpdateAsync(entity);
|
||||
}
|
||||
}, userNos);
|
||||
}
|
||||
|
||||
|
||||
public async Task<object> GetSettingAsync()
|
||||
{
|
||||
var currentTenantId = _currentUser.GetStringTenantId();
|
||||
return await _dbContext.Queryable<OutsourceSettingEntity>().Where(x => x.TenantId == currentTenantId).Select(x => new
|
||||
{
|
||||
x.Id,
|
||||
x.EnableFactory
|
||||
}).SingleAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user