fix 框架调整,优化数据返回
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using Dlhis.Basic.BusinessPlace.Response;
|
||||
using Dlhis.Basic.BusinessPlace.Services;
|
||||
using Dlhis.Basic.BusinessShift.Services;
|
||||
using Dlhis.Basic.Packs;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -75,6 +76,7 @@ public class BusinessPlacesController : ControllerBase
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("shifts")]
|
||||
[IgnoreTenant]
|
||||
public async Task<BusinessPlaceWithShiftResponse> GetShiftsByPlaceCustomCodeHttpPostAsync(BusinessPlaceGetShiftsRequest request)
|
||||
{
|
||||
return await _businessPlaceShiftService.GetShiftsByPlaceCustomCodeAsync(request.CustomCode);
|
||||
@@ -86,6 +88,7 @@ public class BusinessPlacesController : ControllerBase
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("shifts")]
|
||||
[IgnoreTenant]
|
||||
public async Task<BusinessPlaceWithShiftResponse> GetShiftsByPlaceCustomCodeHttpGetAsync([FromQuery] BusinessPlaceGetShiftsRequest request)
|
||||
{
|
||||
return await _businessPlaceShiftService.GetShiftsByPlaceCustomCodeAsync(request.CustomCode);
|
||||
|
||||
@@ -35,9 +35,21 @@ public class BusinessPlaceResponse
|
||||
public CanteenBusinessPlaceSourceEnumType Source { get; set; }
|
||||
public string SourceDesc => Source.GetDescription();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 分类,超市/餐厅/食堂
|
||||
/// </summary>
|
||||
public CanteenBusinessPlaceCatalogEnumType Catalog { get; set; }
|
||||
public string CatalogDesc => Catalog.GetDescription();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 餐次code
|
||||
/// </summary>
|
||||
public Guid? ShiftCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 餐次名称
|
||||
/// </summary>
|
||||
public string ShiftName { get; set; }
|
||||
}
|
||||
|
||||
@@ -23,11 +23,25 @@ public class BusinessPlaceService : IBusinessPlaceService
|
||||
public async Task<Pagination<BusinessPlaceResponse>> GetPageAsync(BusinessPlacePageRequest request)
|
||||
{
|
||||
var page = await _dbContext.Queryable<BusinessPlaceEntity>()
|
||||
.LeftJoin<BusinessPlaceShiftRelationshipEntity>((x, ps) => x.Code == ps.PlaceCode)
|
||||
.LeftJoin<BusinessShiftEntity>((x, ps, s) => s.Code == ps.ShiftCode)
|
||||
.WhereIF(request.Search.IsPresent(), x => x.CustomCode.Contains(request.Search))
|
||||
.WhereIF(request.Catalog.HasValue, x => x.Catalog == request.Catalog)
|
||||
.WhereIF(request.Status.HasValue, x => x.Status == request.Status)
|
||||
.WhereIF(request.Source.HasValue, x => x.Source == request.Source)
|
||||
.Select<BusinessPlaceResponse>()
|
||||
.Select((x, ps, s) => new BusinessPlaceResponse
|
||||
{
|
||||
Id = x.Id,
|
||||
Code = x.Code,
|
||||
Status = x.Status,
|
||||
Name = x.Name,
|
||||
Catalog = x.Catalog,
|
||||
CustomCode = x.CustomCode,
|
||||
Source = x.Source,
|
||||
|
||||
ShiftCode = s.Code,
|
||||
ShiftName = s.Name
|
||||
})
|
||||
.ToPageListAsync(request);
|
||||
|
||||
return page;
|
||||
@@ -38,8 +52,8 @@ public class BusinessPlaceService : IBusinessPlaceService
|
||||
{
|
||||
return await _dbContext.Queryable<BusinessPlaceEntity>()
|
||||
.Where(x => x.Status == CanteenBusinessPlaceStatusEnumType.Opened)
|
||||
.Select<BusinessPlaceResponse>()
|
||||
.ToListAsync();
|
||||
.Select<BusinessPlaceResponse>()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Dlhis.Basic.BusinessShift.Request;
|
||||
using Dlhis.Basic.BusinessShift.Response;
|
||||
using Dlhis.Basic.BusinessShift.Services;
|
||||
using Dlhis.Basic.Packs;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -49,9 +50,9 @@ public class BusinessShiftsController : ControllerBase
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("save")]
|
||||
public async Task SaveAsync(BusinessPlaceShiftSaveRequest request)
|
||||
public async Task<Guid> SaveAsync(BusinessPlaceShiftSaveRequest request)
|
||||
{
|
||||
await _businessPlaceShiftService.SaveAsync(request);
|
||||
return await _businessPlaceShiftService.SaveAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -60,6 +61,7 @@ public class BusinessShiftsController : ControllerBase
|
||||
/// <param name="requests"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("meal/save")]
|
||||
[Transactional]
|
||||
public async Task SaveMealShiftsAsync(List<BusinessPlaceShiftSaveMealShiftRequest> requests)
|
||||
{
|
||||
await _businessPlaceShiftService.SaveMealShiftsAsync(requests);
|
||||
|
||||
@@ -18,4 +18,9 @@ public class BusinessPlaceShiftResponse
|
||||
/// 餐次名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 就餐时间段
|
||||
/// </summary>
|
||||
public List<MealShiftResponse> MealShifts { get; set; }
|
||||
}
|
||||
|
||||
13
Src/Dlhis.Basic/BusinessShift/Response/MealShiftResponse.cs
Normal file
13
Src/Dlhis.Basic/BusinessShift/Response/MealShiftResponse.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace Dlhis.Basic.BusinessShift.Response
|
||||
{
|
||||
public class MealShiftResponse
|
||||
{
|
||||
public Guid ShiftCode { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public TimeOnly Start { get; set; }
|
||||
|
||||
public TimeOnly End { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ public interface IBusinessPlaceShiftService : IScopeDependency
|
||||
|
||||
Task<List<BusinessPlaceShiftResponse>> GetListAsync();
|
||||
|
||||
Task SaveAsync(BusinessPlaceShiftSaveRequest request);
|
||||
Task<Guid> SaveAsync(BusinessPlaceShiftSaveRequest request);
|
||||
|
||||
Task SaveMealShiftsAsync(List<BusinessPlaceShiftSaveMealShiftRequest> requests);
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.CustomClass;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.Core.Result;
|
||||
using Kurisu.SqlSugar.Attributes;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Mapster;
|
||||
@@ -32,6 +31,26 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService
|
||||
.Select<BusinessPlaceShiftResponse>()
|
||||
.ToPageListAsync(request);
|
||||
|
||||
var shiftCodes = page.Data.Select(x => x.Code).ToList();
|
||||
|
||||
//下级就餐时间段
|
||||
var mealShifts = await _dbContext.Queryable<BusinessShiftMealRelationshipEntity>()
|
||||
.LeftJoin<BasicTypeEntity>((x, bt) => x.ShiftType == bt.Code)
|
||||
.Where(x => shiftCodes.Contains(x.ShiftCode))
|
||||
.Select((x, bt) => new MealShiftResponse
|
||||
{
|
||||
ShiftCode = x.ShiftCode,
|
||||
Name = bt.Display,
|
||||
Start = x.Start,
|
||||
End = x.End,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
page.Data.ForEach(x =>
|
||||
{
|
||||
x.MealShifts = mealShifts.Where(item => item.ShiftCode == x.Code).ToList();
|
||||
});
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@@ -43,16 +62,19 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task SaveAsync(BusinessPlaceShiftSaveRequest request)
|
||||
public async Task<Guid> SaveAsync(BusinessPlaceShiftSaveRequest request)
|
||||
{
|
||||
await CheckExistsAsync(request);
|
||||
|
||||
Guid code = Guid.Empty;
|
||||
if (!request.Id.HasValue)
|
||||
{
|
||||
var entity = request.Adapt<BusinessShiftEntity>();
|
||||
|
||||
entity.Code = Guid.NewGuid();
|
||||
await _dbContext.InsertAsync(entity);
|
||||
|
||||
code = entity.Code;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -61,10 +83,13 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService
|
||||
|
||||
request.Adapt(entity);
|
||||
await _dbContext.UpdateAsync(entity);
|
||||
|
||||
code = entity.Code;
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
[Transactional]
|
||||
public async Task SaveMealShiftsAsync(List<BusinessPlaceShiftSaveMealShiftRequest> requests)
|
||||
{
|
||||
var mealShifts = await GetMealShiftAsync();
|
||||
@@ -98,7 +123,7 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService
|
||||
}
|
||||
}
|
||||
|
||||
[IgnoreTenant]
|
||||
|
||||
public async Task<BusinessPlaceWithShiftResponse> GetShiftsByPlaceCustomCodeAsync(string placeCustomCode)
|
||||
{
|
||||
var place = await _dbContext.Queryable<BusinessPlaceEntity>().Where(x => x.CustomCode == placeCustomCode).FirstAsync();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Dlhis.Basic.Device.Request;
|
||||
using Dlhis.Basic.Device.Response;
|
||||
using Dlhis.Basic.Device.Services;
|
||||
using Dlhis.Basic.Packs;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@@ -74,6 +75,7 @@ public class DeviceGroupsController : ControllerBase
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("assign")]
|
||||
[Transactional]
|
||||
public async Task AssignDevicesAsync(DeviceAssignRequest request)
|
||||
{
|
||||
await _deviceGroupService.AssignDevicesAsync(request);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Dlhis.Basic.Device.Request;
|
||||
using Dlhis.Basic.Device.Response;
|
||||
using Dlhis.Basic.Device.Services;
|
||||
using Dlhis.Basic.Packs;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -25,6 +26,7 @@ public class DevicePermissionsController : ControllerBase
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("assign")]
|
||||
[Transactional]
|
||||
public async Task AssignAsync(DevicePermissionSaveReuqest request)
|
||||
{
|
||||
await _devicePermissionService.AssignAsync(request);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Dlhis.Basic.Device.Request;
|
||||
using Dlhis.Basic.Device.Response;
|
||||
using Dlhis.Basic.Device.Services;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Basic.Packs;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -71,6 +71,7 @@ public class DevicesController : ControllerBase
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("save")]
|
||||
[Transactional]
|
||||
public async Task SaveAsync(DeviceSaveRequest request)
|
||||
{
|
||||
await _deviceService.SaveAsync(request);
|
||||
@@ -82,6 +83,7 @@ public class DevicesController : ControllerBase
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("resigter")]
|
||||
[IgnoreTenant]
|
||||
public async Task<string> ResigterAsync(DeviceResigterRequest request)
|
||||
{
|
||||
return await _deviceConnectService.ResigterAsync(request);
|
||||
@@ -129,6 +131,7 @@ public class DevicesController : ControllerBase
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("heartbeat")]
|
||||
[IgnoreTenant]
|
||||
public async Task HeartbeatAsync(DeviceHeartbeatRequest request)
|
||||
{
|
||||
await _deviceConnectService.HeartbeatAsync(request);
|
||||
@@ -143,6 +146,7 @@ public class DevicesController : ControllerBase
|
||||
{
|
||||
return await _deviceService.CheckExistsAsync(deviceUniqueNo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取设备
|
||||
/// </summary>
|
||||
|
||||
@@ -20,7 +20,7 @@ public class DeviceConnectService : IDeviceConnectService
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
[IgnoreTenant]
|
||||
|
||||
public async Task<string> ResigterAsync(DeviceResigterRequest request)
|
||||
{
|
||||
var businessPlace = await _dbContext.Queryable<BusinessPlaceEntity>().Where(x => x.CustomCode == request.BusinessCustomCode).FirstAsync();
|
||||
@@ -82,7 +82,7 @@ public class DeviceConnectService : IDeviceConnectService
|
||||
//todo 通知设备重新获取
|
||||
}
|
||||
|
||||
[IgnoreTenant]
|
||||
|
||||
public async Task HeartbeatAsync(DeviceHeartbeatRequest request)
|
||||
{
|
||||
var registry = await _dbContext.Queryable<DeviceRegistryEntity>().Where(x => x.DeviceUniqueNo == request.UniqueNo).FirstAsync();
|
||||
|
||||
@@ -91,7 +91,6 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
}
|
||||
|
||||
|
||||
[Transactional]
|
||||
public async Task AssignDevicesAsync(DeviceAssignRequest request)
|
||||
{
|
||||
var group = await _dbContext.Queryable<DeviceGroupEntity>().Where(x => x.Code == request.GroupCode).FirstAsync();
|
||||
|
||||
@@ -21,7 +21,6 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
[Transactional]
|
||||
public async Task AssignAsync(DevicePermissionSaveReuqest reuqest)
|
||||
{
|
||||
await GenerateDeviceTasksAsync(async () =>
|
||||
|
||||
@@ -86,7 +86,6 @@ public class DeviceService : IDeviceService
|
||||
}
|
||||
|
||||
|
||||
[Transactional]
|
||||
public async Task SaveAsync(DeviceSaveRequest request)
|
||||
{
|
||||
await CheckUniqueNoExistsAsync(request);
|
||||
@@ -199,7 +198,7 @@ public class DeviceService : IDeviceService
|
||||
exists.ThrowIfTrue("唯一号已经存在");
|
||||
}
|
||||
|
||||
[IgnoreTenant]
|
||||
|
||||
public async Task<bool> CheckExistsAsync(string deviceUniqueNo)
|
||||
{
|
||||
return await _dbContext.Queryable<DeviceEntity>()
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.2" />
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="6.0.26" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.4" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -104,7 +104,6 @@ public class GainfoService : IGainfoService
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Transactional]
|
||||
public async Task DimissionAsync(GainfoDimissionRequest request)
|
||||
{
|
||||
var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using Kurisu.AspNetCore;
|
||||
using Kurisu.AspNetCore.Startup;
|
||||
using Kurisu.Core.DataAccess.Entity;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Basic.Packs;
|
||||
@@ -33,3 +36,98 @@ public class SqlSugarPack : BaseAppPack
|
||||
//dbFace.CodeFirst.InitTables<GainfoFaceEntity>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 日志
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class LogAttribute : Attribute, IAsyncActionFilter
|
||||
{
|
||||
public LogAttribute(string title)
|
||||
{
|
||||
Title = title;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否处理差异
|
||||
/// </summary>
|
||||
public bool Diff { get; set; }
|
||||
|
||||
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
PreSetting(context.HttpContext);
|
||||
await next();
|
||||
}
|
||||
|
||||
private void PreSetting(HttpContext httpContext)
|
||||
{
|
||||
var options = httpContext.RequestServices.GetService<ISqlSugarOptionsService>();
|
||||
|
||||
options.Title = Title;
|
||||
options.Diff = Diff;
|
||||
options.BatchNo = Guid.NewGuid();
|
||||
options.RoutePath = httpContext.Request.Path.Value;
|
||||
options.RaiseTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 事务
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class TransactionalAttribute : Attribute, IAsyncActionFilter
|
||||
{
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
var dbContext = context.HttpContext.RequestServices.GetRequiredService<ISqlSugarClient>();
|
||||
await dbContext.Ado.BeginTranAsync();
|
||||
try
|
||||
{
|
||||
var result = await next();
|
||||
if (result.Exception != null)
|
||||
{
|
||||
throw result.Exception;
|
||||
}
|
||||
else
|
||||
{
|
||||
await dbContext.Ado.CommitTranAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await dbContext.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 忽略租户
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class IgnoreTenantAttribute : Attribute, IAsyncActionFilter
|
||||
{
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
var dbContext = context.HttpContext.RequestServices.GetRequiredService<ISqlSugarClient>();
|
||||
var options = context.HttpContext!.RequestServices.GetService<ISqlSugarOptionsService>();
|
||||
try
|
||||
{
|
||||
dbContext.QueryFilter.ClearAndBackup<ITenantId>();
|
||||
options.IgnoreTenant = true;
|
||||
await next();
|
||||
}
|
||||
finally
|
||||
{
|
||||
options.IgnoreTenant = false;
|
||||
dbContext.QueryFilter.Restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.2" />
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.3" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.4" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ public class BalancesController : ControllerBase
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("device/page")]
|
||||
[IgnoreTenant]
|
||||
public async Task<Pagination<BalanceRecordResponse>> GetPageByDeviceUniqueNoGetAsync([FromQuery] BalanceRecordPageByDeviceUniqueNoRequest request)
|
||||
{
|
||||
return await _balanceService.GetPageByDeviceUniqueNoAsync(request);
|
||||
@@ -50,6 +51,7 @@ public class BalancesController : ControllerBase
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("device/page")]
|
||||
[IgnoreTenant]
|
||||
public async Task<Pagination<BalanceRecordResponse>> GetPageByDeviceUniqueNoPostAsync(BalanceRecordPageByDeviceUniqueNoRequest request)
|
||||
{
|
||||
return await _balanceService.GetPageByDeviceUniqueNoAsync(request);
|
||||
|
||||
@@ -407,7 +407,7 @@ public class BalanceService : IBalanceService
|
||||
}
|
||||
|
||||
|
||||
[IgnoreTenant]
|
||||
|
||||
public async Task<Pagination<BalanceRecordResponse>> GetPageByDeviceUniqueNoAsync(BalanceRecordPageByDeviceUniqueNoRequest request)
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
|
||||
@@ -7,6 +7,14 @@
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:5008"
|
||||
},
|
||||
"Docker": {
|
||||
"commandName": "Docker",
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_URLS": "http://+:80"
|
||||
},
|
||||
"publishAllPorts": true
|
||||
}
|
||||
},
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json"
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
using Kurisu.AspNetCore.Startup;
|
||||
using Kurisu.Core.DataAccess.Entity;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Canteen;
|
||||
|
||||
@@ -12,3 +16,101 @@ public class SqlSugarPack : BaseAppPack
|
||||
services.AddSqlSugar();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 日志
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class LogAttribute : Attribute, IAsyncActionFilter
|
||||
{
|
||||
public LogAttribute(string title)
|
||||
{
|
||||
Title = title;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否处理差异
|
||||
/// </summary>
|
||||
public bool Diff { get; set; }
|
||||
|
||||
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
PreSetting(context.HttpContext);
|
||||
await next();
|
||||
}
|
||||
|
||||
private void PreSetting(HttpContext httpContext)
|
||||
{
|
||||
var options = httpContext.RequestServices.GetService<ISqlSugarOptionsService>();
|
||||
|
||||
options.Title = Title;
|
||||
options.Diff = Diff;
|
||||
options.BatchNo = Guid.NewGuid();
|
||||
options.RoutePath = httpContext.Request.Path.Value;
|
||||
options.RaiseTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 事务
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class TransactionalAttribute : Attribute, IAsyncActionFilter
|
||||
{
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
var dbContext = context.HttpContext.RequestServices.GetRequiredService<ISqlSugarClient>();
|
||||
await dbContext.Ado.BeginTranAsync();
|
||||
try
|
||||
{
|
||||
var result = await next();
|
||||
if (result.Exception != null)
|
||||
{
|
||||
throw result.Exception;
|
||||
}
|
||||
else
|
||||
{
|
||||
await dbContext.Ado.CommitTranAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await dbContext.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 忽略租户
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class IgnoreTenantAttribute : Attribute, IAsyncActionFilter
|
||||
{
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
var dbContext = context.HttpContext.RequestServices.GetRequiredService<ISqlSugarClient>();
|
||||
var options = context.HttpContext!.RequestServices.GetService<ISqlSugarOptionsService>();
|
||||
try
|
||||
{
|
||||
dbContext.QueryFilter.ClearAndBackup<ITenantId>();
|
||||
options.IgnoreTenant = true;
|
||||
await next();
|
||||
}
|
||||
finally
|
||||
{
|
||||
options.IgnoreTenant = false;
|
||||
dbContext.QueryFilter.Restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.2" />
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.3" />
|
||||
<PackageReference Include="Minio" Version="6.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Kurisu.SqlSugar" Version="0.0.4" />
|
||||
<PackageReference Include="Kurisu.SqlSugar" Version="0.0.6" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.ScheduledTask.DeviceUploadLog.Request;
|
||||
using Dlhis.ScheduledTask.DeviceUploadLog.Request;
|
||||
using Dlhis.ScheduledTask.DeviceUploadLog.Response;
|
||||
using Dlhis.ScheduledTask.DeviceUploadLog.Services;
|
||||
using Dlhis.ScheduledTask.Packs;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -40,6 +40,7 @@ public class DeviceUploadLogsController : ControllerBase
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("record")]
|
||||
[IgnoreTenant]
|
||||
public async Task UploadLogAsync(DeviceUploadLogUploadRequest request)
|
||||
{
|
||||
await _deviceUploadLogService.UploadLogAsync(request);
|
||||
@@ -51,6 +52,7 @@ public class DeviceUploadLogsController : ControllerBase
|
||||
/// <param name="requests"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("records")]
|
||||
[IgnoreTenant]
|
||||
public async Task UploadLogsAsync(List<DeviceUploadLogUploadRequest> requests)
|
||||
{
|
||||
await _deviceUploadLogService.UploadLogsAsync(requests);
|
||||
|
||||
@@ -46,7 +46,6 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
||||
return page;
|
||||
}
|
||||
|
||||
[IgnoreTenant]
|
||||
public async Task UploadLogAsync(DeviceUploadLogUploadRequest request)
|
||||
{
|
||||
var device = await _dbContext.Queryable<DeviceEntity>().Where(x => x.UniqueNo == request.DeviceUniqueNo).SingleAsync();
|
||||
@@ -63,7 +62,7 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
||||
await _dbContext.InsertAsync(entity);
|
||||
}
|
||||
|
||||
[IgnoreTenant]
|
||||
|
||||
public async Task UploadLogsAsync(List<DeviceUploadLogUploadRequest> requests)
|
||||
{
|
||||
//判断存在的记录
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.7" />
|
||||
<PackageReference Include="Hangfire.Dashboard.BasicAuthorization" Version="1.0.2" />
|
||||
<PackageReference Include="Hangfire.Redis.StackExchange" Version="1.9.3" />
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.2" />
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="6.0.26" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
using Kurisu.AspNetCore.Startup;
|
||||
using Kurisu.Core.DataAccess.Entity;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Packs;
|
||||
|
||||
@@ -12,3 +16,103 @@ public class SqlSugarPack : BaseAppPack
|
||||
services.AddSqlSugar();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 日志
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class LogAttribute : Attribute, IAsyncActionFilter
|
||||
{
|
||||
public LogAttribute(string title)
|
||||
{
|
||||
Title = title;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否处理差异
|
||||
/// </summary>
|
||||
public bool Diff { get; set; }
|
||||
|
||||
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
PreSetting(context.HttpContext);
|
||||
await next();
|
||||
}
|
||||
|
||||
private void PreSetting(HttpContext httpContext)
|
||||
{
|
||||
var options = httpContext.RequestServices.GetService<ISqlSugarOptionsService>();
|
||||
|
||||
options.Title = Title;
|
||||
options.Diff = Diff;
|
||||
options.BatchNo = Guid.NewGuid();
|
||||
options.RoutePath = httpContext.Request.Path.Value;
|
||||
options.RaiseTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 事务
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class TransactionalAttribute : Attribute, IAsyncActionFilter
|
||||
{
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
var dbContext = context.HttpContext.RequestServices.GetRequiredService<ISqlSugarClient>();
|
||||
await dbContext.Ado.BeginTranAsync();
|
||||
try
|
||||
{
|
||||
var result = await next();
|
||||
if (result.Exception != null)
|
||||
{
|
||||
throw result.Exception;
|
||||
}
|
||||
else
|
||||
{
|
||||
await dbContext.Ado.CommitTranAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await dbContext.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 忽略租户
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class IgnoreTenantAttribute : Attribute, IAsyncActionFilter
|
||||
{
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
var dbContext = context.HttpContext.RequestServices.GetRequiredService<ISqlSugarClient>();
|
||||
var options = context.HttpContext!.RequestServices.GetService<ISqlSugarOptionsService>();
|
||||
try
|
||||
{
|
||||
dbContext.QueryFilter.ClearAndBackup<ITenantId>();
|
||||
options.IgnoreTenant = true;
|
||||
await next();
|
||||
}
|
||||
finally
|
||||
{
|
||||
options.IgnoreTenant = false;
|
||||
dbContext.QueryFilter.Restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Dlhis.ScheduledTask.TaskAssignment.Request;
|
||||
using Dlhis.ScheduledTask.Packs;
|
||||
using Dlhis.ScheduledTask.TaskAssignment.Request;
|
||||
using Dlhis.ScheduledTask.TaskAssignment.Response;
|
||||
using Dlhis.ScheduledTask.TaskAssignment.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@@ -25,6 +26,7 @@ public class AssignmentsController : ControllerBase
|
||||
/// 获取设备任务(按设备)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[IgnoreTenant]
|
||||
[HttpGet("devicetasks")]
|
||||
public async Task<List<DeviceTaskToDeviceByDeviceResponse>> DeviceGetTasksGetAsync([FromQuery] DeviceTaskGetRequest request)
|
||||
{
|
||||
@@ -36,6 +38,7 @@ public class AssignmentsController : ControllerBase
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("devicetasks")]
|
||||
[IgnoreTenant]
|
||||
public async Task<List<DeviceTaskToDeviceByDeviceResponse>> DeviceGetTasksPostAsync(DeviceTaskGetRequest request)
|
||||
{
|
||||
return await _assignmentService.DeviceGetTasksAsync(request);
|
||||
@@ -47,6 +50,7 @@ public class AssignmentsController : ControllerBase
|
||||
/// <param name="requests"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("taskstatus")]
|
||||
[IgnoreTenant]
|
||||
public async Task UpdateDeviceTaskStatusAsync(List<UpdateDeviceTaskStatusRequest> requests)
|
||||
{
|
||||
await _assignmentService.UpdateDeviceTaskStatusAsync(requests);
|
||||
@@ -58,6 +62,7 @@ public class AssignmentsController : ControllerBase
|
||||
/// <param name="taskId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("renewfaceurl")]
|
||||
[IgnoreTenant]
|
||||
public async Task<string> RenewFaceUrlAsync(long taskId)
|
||||
{
|
||||
return await _assignmentService.RenewFaceUrlAsync(taskId);
|
||||
|
||||
@@ -12,13 +12,11 @@ using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using SqlSugar;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Attributes;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Kurisu.Core.CustomClass;
|
||||
|
||||
namespace Dlhis.ScheduledTask.TaskAssignment.Services.Implements;
|
||||
|
||||
[IgnoreTenant]
|
||||
public class AssignmentService : IAssignmentService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.2" />
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.3" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.4" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ public class MenusController : ControllerBase
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Transactional]
|
||||
public async Task Save(SaveMenuRequest request)
|
||||
{
|
||||
await _menuService.SaveMenuAsync(request);
|
||||
|
||||
@@ -41,7 +41,7 @@ public class MenuService : IMenuService
|
||||
return top;
|
||||
}
|
||||
|
||||
[Transactional]
|
||||
|
||||
public async Task<string> SaveMenuAsync(SaveMenuRequest request)
|
||||
{
|
||||
await CheckAsync(request);
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
using Kurisu.AspNetCore.Startup;
|
||||
using Kurisu.Core.DataAccess.Entity;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Sys;
|
||||
|
||||
@@ -12,3 +16,102 @@ public class SqlSugarPack : BaseAppPack
|
||||
services.AddSqlSugar();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 日志
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class LogAttribute : Attribute, IAsyncActionFilter
|
||||
{
|
||||
public LogAttribute(string title)
|
||||
{
|
||||
Title = title;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否处理差异
|
||||
/// </summary>
|
||||
public bool Diff { get; set; }
|
||||
|
||||
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
PreSetting(context.HttpContext);
|
||||
await next();
|
||||
}
|
||||
|
||||
private void PreSetting(HttpContext httpContext)
|
||||
{
|
||||
var options = httpContext.RequestServices.GetService<ISqlSugarOptionsService>();
|
||||
|
||||
options.Title = Title;
|
||||
options.Diff = Diff;
|
||||
options.BatchNo = Guid.NewGuid();
|
||||
options.RoutePath = httpContext.Request.Path.Value;
|
||||
options.RaiseTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 事务
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class TransactionalAttribute : Attribute, IAsyncActionFilter
|
||||
{
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
var dbContext = context.HttpContext.RequestServices.GetRequiredService<ISqlSugarClient>();
|
||||
await dbContext.Ado.BeginTranAsync();
|
||||
try
|
||||
{
|
||||
var result = await next();
|
||||
if (result.Exception != null)
|
||||
{
|
||||
throw result.Exception;
|
||||
}
|
||||
else
|
||||
{
|
||||
await dbContext.Ado.CommitTranAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await dbContext.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 忽略租户
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class IgnoreTenantAttribute : Attribute, IAsyncActionFilter
|
||||
{
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
var dbContext = context.HttpContext.RequestServices.GetRequiredService<ISqlSugarClient>();
|
||||
var options = context.HttpContext!.RequestServices.GetService<ISqlSugarOptionsService>();
|
||||
try
|
||||
{
|
||||
dbContext.QueryFilter.ClearAndBackup<ITenantId>();
|
||||
options.IgnoreTenant = true;
|
||||
await next();
|
||||
}
|
||||
finally
|
||||
{
|
||||
options.IgnoreTenant = false;
|
||||
dbContext.QueryFilter.Restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.2" />
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.3" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.4" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user