diff --git a/Src/Dlhis.Basic/BusinessPlace/Controllers/BusinessPlacesController.cs b/Src/Dlhis.Basic/BusinessPlace/Controllers/BusinessPlacesController.cs
index 44ada252..815f4e08 100644
--- a/Src/Dlhis.Basic/BusinessPlace/Controllers/BusinessPlacesController.cs
+++ b/Src/Dlhis.Basic/BusinessPlace/Controllers/BusinessPlacesController.cs
@@ -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
///
///
[HttpPost("shifts")]
+ [IgnoreTenant]
public async Task GetShiftsByPlaceCustomCodeHttpPostAsync(BusinessPlaceGetShiftsRequest request)
{
return await _businessPlaceShiftService.GetShiftsByPlaceCustomCodeAsync(request.CustomCode);
@@ -86,6 +88,7 @@ public class BusinessPlacesController : ControllerBase
///
///
[HttpGet("shifts")]
+ [IgnoreTenant]
public async Task GetShiftsByPlaceCustomCodeHttpGetAsync([FromQuery] BusinessPlaceGetShiftsRequest request)
{
return await _businessPlaceShiftService.GetShiftsByPlaceCustomCodeAsync(request.CustomCode);
diff --git a/Src/Dlhis.Basic/BusinessPlace/Response/BusinessPlaceResponse.cs b/Src/Dlhis.Basic/BusinessPlace/Response/BusinessPlaceResponse.cs
index 9793da56..c954462a 100644
--- a/Src/Dlhis.Basic/BusinessPlace/Response/BusinessPlaceResponse.cs
+++ b/Src/Dlhis.Basic/BusinessPlace/Response/BusinessPlaceResponse.cs
@@ -35,9 +35,21 @@ public class BusinessPlaceResponse
public CanteenBusinessPlaceSourceEnumType Source { get; set; }
public string SourceDesc => Source.GetDescription();
+
///
/// 分类,超市/餐厅/食堂
///
public CanteenBusinessPlaceCatalogEnumType Catalog { get; set; }
public string CatalogDesc => Catalog.GetDescription();
+
+
+ ///
+ /// 餐次code
+ ///
+ public Guid? ShiftCode { get; set; }
+
+ ///
+ /// 餐次名称
+ ///
+ public string ShiftName { get; set; }
}
diff --git a/Src/Dlhis.Basic/BusinessPlace/Services/Implements/BusinessPlaceService.cs b/Src/Dlhis.Basic/BusinessPlace/Services/Implements/BusinessPlaceService.cs
index 66fe18e8..ace2b8e9 100644
--- a/Src/Dlhis.Basic/BusinessPlace/Services/Implements/BusinessPlaceService.cs
+++ b/Src/Dlhis.Basic/BusinessPlace/Services/Implements/BusinessPlaceService.cs
@@ -23,11 +23,25 @@ public class BusinessPlaceService : IBusinessPlaceService
public async Task> GetPageAsync(BusinessPlacePageRequest request)
{
var page = await _dbContext.Queryable()
+ .LeftJoin((x, ps) => x.Code == ps.PlaceCode)
+ .LeftJoin((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()
+ .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()
.Where(x => x.Status == CanteenBusinessPlaceStatusEnumType.Opened)
- .Select()
- .ToListAsync();
+ .Select()
+ .ToListAsync();
}
diff --git a/Src/Dlhis.Basic/BusinessShift/Controllers/BusinessShiftsController.cs b/Src/Dlhis.Basic/BusinessShift/Controllers/BusinessShiftsController.cs
index b0438262..323bb7bb 100644
--- a/Src/Dlhis.Basic/BusinessShift/Controllers/BusinessShiftsController.cs
+++ b/Src/Dlhis.Basic/BusinessShift/Controllers/BusinessShiftsController.cs
@@ -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
///
///
[HttpPost("save")]
- public async Task SaveAsync(BusinessPlaceShiftSaveRequest request)
+ public async Task SaveAsync(BusinessPlaceShiftSaveRequest request)
{
- await _businessPlaceShiftService.SaveAsync(request);
+ return await _businessPlaceShiftService.SaveAsync(request);
}
///
@@ -60,6 +61,7 @@ public class BusinessShiftsController : ControllerBase
///
///
[HttpPost("meal/save")]
+ [Transactional]
public async Task SaveMealShiftsAsync(List requests)
{
await _businessPlaceShiftService.SaveMealShiftsAsync(requests);
diff --git a/Src/Dlhis.Basic/BusinessShift/Response/BusinessPlaceShiftResponse.cs b/Src/Dlhis.Basic/BusinessShift/Response/BusinessPlaceShiftResponse.cs
index f0a9d504..82a3aab3 100644
--- a/Src/Dlhis.Basic/BusinessShift/Response/BusinessPlaceShiftResponse.cs
+++ b/Src/Dlhis.Basic/BusinessShift/Response/BusinessPlaceShiftResponse.cs
@@ -18,4 +18,9 @@ public class BusinessPlaceShiftResponse
/// 餐次名称
///
public string Name { get; set; }
+
+ ///
+ /// 就餐时间段
+ ///
+ public List MealShifts { get; set; }
}
diff --git a/Src/Dlhis.Basic/BusinessShift/Response/MealShiftResponse.cs b/Src/Dlhis.Basic/BusinessShift/Response/MealShiftResponse.cs
new file mode 100644
index 00000000..04290aff
--- /dev/null
+++ b/Src/Dlhis.Basic/BusinessShift/Response/MealShiftResponse.cs
@@ -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; }
+ }
+}
diff --git a/Src/Dlhis.Basic/BusinessShift/Services/IBusinessPlaceShiftService.cs b/Src/Dlhis.Basic/BusinessShift/Services/IBusinessPlaceShiftService.cs
index 694c7948..1dc289da 100644
--- a/Src/Dlhis.Basic/BusinessShift/Services/IBusinessPlaceShiftService.cs
+++ b/Src/Dlhis.Basic/BusinessShift/Services/IBusinessPlaceShiftService.cs
@@ -11,7 +11,7 @@ public interface IBusinessPlaceShiftService : IScopeDependency
Task> GetListAsync();
- Task SaveAsync(BusinessPlaceShiftSaveRequest request);
+ Task SaveAsync(BusinessPlaceShiftSaveRequest request);
Task SaveMealShiftsAsync(List requests);
diff --git a/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs b/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs
index aa3f2905..13169a48 100644
--- a/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs
+++ b/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs
@@ -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()
.ToPageListAsync(request);
+ var shiftCodes = page.Data.Select(x => x.Code).ToList();
+
+ //下级就餐时间段
+ var mealShifts = await _dbContext.Queryable()
+ .LeftJoin((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 SaveAsync(BusinessPlaceShiftSaveRequest request)
{
await CheckExistsAsync(request);
+ Guid code = Guid.Empty;
if (!request.Id.HasValue)
{
var entity = request.Adapt();
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 requests)
{
var mealShifts = await GetMealShiftAsync();
@@ -98,7 +123,7 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService
}
}
- [IgnoreTenant]
+
public async Task GetShiftsByPlaceCustomCodeAsync(string placeCustomCode)
{
var place = await _dbContext.Queryable().Where(x => x.CustomCode == placeCustomCode).FirstAsync();
diff --git a/Src/Dlhis.Basic/Device/Controllers/DeviceGroupsController.cs b/Src/Dlhis.Basic/Device/Controllers/DeviceGroupsController.cs
index c05c41ba..29796a25 100644
--- a/Src/Dlhis.Basic/Device/Controllers/DeviceGroupsController.cs
+++ b/Src/Dlhis.Basic/Device/Controllers/DeviceGroupsController.cs
@@ -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
///
///
[HttpPost("assign")]
+ [Transactional]
public async Task AssignDevicesAsync(DeviceAssignRequest request)
{
await _deviceGroupService.AssignDevicesAsync(request);
diff --git a/Src/Dlhis.Basic/Device/Controllers/DevicePermissionsController.cs b/Src/Dlhis.Basic/Device/Controllers/DevicePermissionsController.cs
index 63a9d64c..14ba9f29 100644
--- a/Src/Dlhis.Basic/Device/Controllers/DevicePermissionsController.cs
+++ b/Src/Dlhis.Basic/Device/Controllers/DevicePermissionsController.cs
@@ -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
///
///
[HttpPost("assign")]
+ [Transactional]
public async Task AssignAsync(DevicePermissionSaveReuqest request)
{
await _devicePermissionService.AssignAsync(request);
diff --git a/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs b/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs
index accdbbb3..f4bf018d 100644
--- a/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs
+++ b/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs
@@ -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
///
///
[HttpPost("save")]
+ [Transactional]
public async Task SaveAsync(DeviceSaveRequest request)
{
await _deviceService.SaveAsync(request);
@@ -82,6 +83,7 @@ public class DevicesController : ControllerBase
///
///
[HttpPost("resigter")]
+ [IgnoreTenant]
public async Task ResigterAsync(DeviceResigterRequest request)
{
return await _deviceConnectService.ResigterAsync(request);
@@ -129,6 +131,7 @@ public class DevicesController : ControllerBase
///
///
[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);
}
+
///
/// 获取设备
///
diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceConnectService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceConnectService.cs
index 7dee0250..70cb0034 100644
--- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceConnectService.cs
+++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceConnectService.cs
@@ -20,7 +20,7 @@ public class DeviceConnectService : IDeviceConnectService
_dbContext = dbContext;
}
- [IgnoreTenant]
+
public async Task ResigterAsync(DeviceResigterRequest request)
{
var businessPlace = await _dbContext.Queryable().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().Where(x => x.DeviceUniqueNo == request.UniqueNo).FirstAsync();
diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs
index a8dfee90..7f1e5345 100644
--- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs
+++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs
@@ -91,7 +91,6 @@ public class DeviceGroupService : IDeviceGroupService
}
- [Transactional]
public async Task AssignDevicesAsync(DeviceAssignRequest request)
{
var group = await _dbContext.Queryable().Where(x => x.Code == request.GroupCode).FirstAsync();
diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs
index 3aee41b7..4c494bcc 100644
--- a/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs
+++ b/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs
@@ -21,7 +21,6 @@ public class DevicePermissionService : IDevicePermissionService
_dbContext = dbContext;
}
- [Transactional]
public async Task AssignAsync(DevicePermissionSaveReuqest reuqest)
{
await GenerateDeviceTasksAsync(async () =>
diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
index 8a7e9bb3..3db17c09 100644
--- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
+++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
@@ -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 CheckExistsAsync(string deviceUniqueNo)
{
return await _dbContext.Queryable()
diff --git a/Src/Dlhis.Basic/Dlhis.Basic.csproj b/Src/Dlhis.Basic/Dlhis.Basic.csproj
index 1b0c0da7..4ada33a1 100644
--- a/Src/Dlhis.Basic/Dlhis.Basic.csproj
+++ b/Src/Dlhis.Basic/Dlhis.Basic.csproj
@@ -17,7 +17,7 @@
-
+
diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
index bfc6e493..d4cbc434 100644
--- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
+++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
@@ -104,7 +104,6 @@ public class GainfoService : IGainfoService
///
///
///
- [Transactional]
public async Task DimissionAsync(GainfoDimissionRequest request)
{
var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
diff --git a/Src/Dlhis.Basic/Packs/SqlSugarPack.cs b/Src/Dlhis.Basic/Packs/SqlSugarPack.cs
index 86dc45aa..a54c45cf 100644
--- a/Src/Dlhis.Basic/Packs/SqlSugarPack.cs
+++ b/Src/Dlhis.Basic/Packs/SqlSugarPack.cs
@@ -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();
}
}
+
+
+///
+/// 日志
+///
+[AttributeUsage(AttributeTargets.Method)]
+public class LogAttribute : Attribute, IAsyncActionFilter
+{
+ public LogAttribute(string title)
+ {
+ Title = title;
+ }
+
+ ///
+ ///
+ ///
+ public string Title { get; set; }
+
+ ///
+ /// 是否处理差异
+ ///
+ 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();
+
+ options.Title = Title;
+ options.Diff = Diff;
+ options.BatchNo = Guid.NewGuid();
+ options.RoutePath = httpContext.Request.Path.Value;
+ options.RaiseTime = DateTime.Now;
+ }
+}
+
+///
+/// 事务
+///
+[AttributeUsage(AttributeTargets.Method)]
+public class TransactionalAttribute : Attribute, IAsyncActionFilter
+{
+ public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
+ {
+ var dbContext = context.HttpContext.RequestServices.GetRequiredService();
+ 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;
+ }
+ }
+}
+
+///
+/// 忽略租户
+///
+[AttributeUsage(AttributeTargets.Method)]
+public class IgnoreTenantAttribute : Attribute, IAsyncActionFilter
+{
+ public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
+ {
+ var dbContext = context.HttpContext.RequestServices.GetRequiredService();
+ var options = context.HttpContext!.RequestServices.GetService();
+ try
+ {
+ dbContext.QueryFilter.ClearAndBackup();
+ options.IgnoreTenant = true;
+ await next();
+ }
+ finally
+ {
+ options.IgnoreTenant = false;
+ dbContext.QueryFilter.Restore();
+ }
+ }
+}
diff --git a/Src/Dlhis.Canteen/Dlhis.Canteen.csproj b/Src/Dlhis.Canteen/Dlhis.Canteen.csproj
index 9e21386c..fe0b5fd0 100644
--- a/Src/Dlhis.Canteen/Dlhis.Canteen.csproj
+++ b/Src/Dlhis.Canteen/Dlhis.Canteen.csproj
@@ -36,7 +36,7 @@
-
+
diff --git a/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs b/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs
index 3015ff75..e9757cc8 100644
--- a/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs
+++ b/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs
@@ -39,6 +39,7 @@ public class BalancesController : ControllerBase
///
///
[HttpGet("device/page")]
+ [IgnoreTenant]
public async Task> GetPageByDeviceUniqueNoGetAsync([FromQuery] BalanceRecordPageByDeviceUniqueNoRequest request)
{
return await _balanceService.GetPageByDeviceUniqueNoAsync(request);
@@ -50,6 +51,7 @@ public class BalancesController : ControllerBase
///
///
[HttpPost("device/page")]
+ [IgnoreTenant]
public async Task> GetPageByDeviceUniqueNoPostAsync(BalanceRecordPageByDeviceUniqueNoRequest request)
{
return await _balanceService.GetPageByDeviceUniqueNoAsync(request);
diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
index 59e76cd1..bde9dda2 100644
--- a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
+++ b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
@@ -407,7 +407,7 @@ public class BalanceService : IBalanceService
}
- [IgnoreTenant]
+
public async Task> GetPageByDeviceUniqueNoAsync(BalanceRecordPageByDeviceUniqueNoRequest request)
{
var now = DateTime.Now;
diff --git a/Src/Dlhis.Canteen/Properties/launchSettings.json b/Src/Dlhis.Canteen/Properties/launchSettings.json
index 706bb9bb..f13e2beb 100644
--- a/Src/Dlhis.Canteen/Properties/launchSettings.json
+++ b/Src/Dlhis.Canteen/Properties/launchSettings.json
@@ -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"
diff --git a/Src/Dlhis.Canteen/SqlSugarPack.cs b/Src/Dlhis.Canteen/SqlSugarPack.cs
index 3abac33b..f8d3a155 100644
--- a/Src/Dlhis.Canteen/SqlSugarPack.cs
+++ b/Src/Dlhis.Canteen/SqlSugarPack.cs
@@ -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();
}
}
+
+
+
+
+
+///
+/// 日志
+///
+[AttributeUsage(AttributeTargets.Method)]
+public class LogAttribute : Attribute, IAsyncActionFilter
+{
+ public LogAttribute(string title)
+ {
+ Title = title;
+ }
+
+ ///
+ ///
+ ///
+ public string Title { get; set; }
+
+ ///
+ /// 是否处理差异
+ ///
+ 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();
+
+ options.Title = Title;
+ options.Diff = Diff;
+ options.BatchNo = Guid.NewGuid();
+ options.RoutePath = httpContext.Request.Path.Value;
+ options.RaiseTime = DateTime.Now;
+ }
+}
+
+///
+/// 事务
+///
+[AttributeUsage(AttributeTargets.Method)]
+public class TransactionalAttribute : Attribute, IAsyncActionFilter
+{
+ public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
+ {
+ var dbContext = context.HttpContext.RequestServices.GetRequiredService();
+ 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;
+ }
+ }
+}
+
+///
+/// 忽略租户
+///
+[AttributeUsage(AttributeTargets.Method)]
+public class IgnoreTenantAttribute : Attribute, IAsyncActionFilter
+{
+ public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
+ {
+ var dbContext = context.HttpContext.RequestServices.GetRequiredService();
+ var options = context.HttpContext!.RequestServices.GetService();
+ try
+ {
+ dbContext.QueryFilter.ClearAndBackup();
+ options.IgnoreTenant = true;
+ await next();
+ }
+ finally
+ {
+ options.IgnoreTenant = false;
+ dbContext.QueryFilter.Restore();
+ }
+ }
+}
diff --git a/Src/Dlhis.Common/Dlhis.Common.csproj b/Src/Dlhis.Common/Dlhis.Common.csproj
index 69affc46..3fe68313 100644
--- a/Src/Dlhis.Common/Dlhis.Common.csproj
+++ b/Src/Dlhis.Common/Dlhis.Common.csproj
@@ -21,7 +21,7 @@
-
+
diff --git a/Src/Dlhis.Entity/Dlhis.Entity.csproj b/Src/Dlhis.Entity/Dlhis.Entity.csproj
index beec1bdc..8245cd0d 100644
--- a/Src/Dlhis.Entity/Dlhis.Entity.csproj
+++ b/Src/Dlhis.Entity/Dlhis.Entity.csproj
@@ -11,7 +11,7 @@
-
+
diff --git a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Controllers/DeviceUploadLogsController.cs b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Controllers/DeviceUploadLogsController.cs
index 7a487c2d..ad8f44b7 100644
--- a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Controllers/DeviceUploadLogsController.cs
+++ b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Controllers/DeviceUploadLogsController.cs
@@ -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
///
///
[HttpPost("record")]
+ [IgnoreTenant]
public async Task UploadLogAsync(DeviceUploadLogUploadRequest request)
{
await _deviceUploadLogService.UploadLogAsync(request);
@@ -51,6 +52,7 @@ public class DeviceUploadLogsController : ControllerBase
///
///
[HttpPost("records")]
+ [IgnoreTenant]
public async Task UploadLogsAsync(List requests)
{
await _deviceUploadLogService.UploadLogsAsync(requests);
diff --git a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs
index 0577b046..de3f43fa 100644
--- a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs
+++ b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs
@@ -46,7 +46,6 @@ public class DeviceUploadLogService : IDeviceUploadLogService
return page;
}
- [IgnoreTenant]
public async Task UploadLogAsync(DeviceUploadLogUploadRequest request)
{
var device = await _dbContext.Queryable().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 requests)
{
//判断存在的记录
diff --git a/Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj b/Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj
index c87349e5..74406a5b 100644
--- a/Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj
+++ b/Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj
@@ -20,7 +20,7 @@
-
+
diff --git a/Src/Dlhis.ScheduledTask/Packs/SqlSugarPack.cs b/Src/Dlhis.ScheduledTask/Packs/SqlSugarPack.cs
index 24a3f080..2f562f2b 100644
--- a/Src/Dlhis.ScheduledTask/Packs/SqlSugarPack.cs
+++ b/Src/Dlhis.ScheduledTask/Packs/SqlSugarPack.cs
@@ -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();
}
}
+
+
+
+
+
+
+///
+/// 日志
+///
+[AttributeUsage(AttributeTargets.Method)]
+public class LogAttribute : Attribute, IAsyncActionFilter
+{
+ public LogAttribute(string title)
+ {
+ Title = title;
+ }
+
+ ///
+ ///
+ ///
+ public string Title { get; set; }
+
+ ///
+ /// 是否处理差异
+ ///
+ 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();
+
+ options.Title = Title;
+ options.Diff = Diff;
+ options.BatchNo = Guid.NewGuid();
+ options.RoutePath = httpContext.Request.Path.Value;
+ options.RaiseTime = DateTime.Now;
+ }
+}
+
+///
+/// 事务
+///
+[AttributeUsage(AttributeTargets.Method)]
+public class TransactionalAttribute : Attribute, IAsyncActionFilter
+{
+ public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
+ {
+ var dbContext = context.HttpContext.RequestServices.GetRequiredService();
+ 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;
+ }
+ }
+}
+
+///
+/// 忽略租户
+///
+[AttributeUsage(AttributeTargets.Method)]
+public class IgnoreTenantAttribute : Attribute, IAsyncActionFilter
+{
+ public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
+ {
+ var dbContext = context.HttpContext.RequestServices.GetRequiredService();
+ var options = context.HttpContext!.RequestServices.GetService();
+ try
+ {
+ dbContext.QueryFilter.ClearAndBackup();
+ options.IgnoreTenant = true;
+ await next();
+ }
+ finally
+ {
+ options.IgnoreTenant = false;
+ dbContext.QueryFilter.Restore();
+ }
+ }
+}
+
diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Controllers/AssignmentsController.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Controllers/AssignmentsController.cs
index 80dae44b..fb9b7e2a 100644
--- a/Src/Dlhis.ScheduledTask/TaskAssignment/Controllers/AssignmentsController.cs
+++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Controllers/AssignmentsController.cs
@@ -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
/// 获取设备任务(按设备)
///
///
+ [IgnoreTenant]
[HttpGet("devicetasks")]
public async Task> DeviceGetTasksGetAsync([FromQuery] DeviceTaskGetRequest request)
{
@@ -36,6 +38,7 @@ public class AssignmentsController : ControllerBase
///
///
[HttpPost("devicetasks")]
+ [IgnoreTenant]
public async Task> DeviceGetTasksPostAsync(DeviceTaskGetRequest request)
{
return await _assignmentService.DeviceGetTasksAsync(request);
@@ -47,6 +50,7 @@ public class AssignmentsController : ControllerBase
///
///
[HttpPost("taskstatus")]
+ [IgnoreTenant]
public async Task UpdateDeviceTaskStatusAsync(List requests)
{
await _assignmentService.UpdateDeviceTaskStatusAsync(requests);
@@ -58,6 +62,7 @@ public class AssignmentsController : ControllerBase
///
///
[HttpGet("renewfaceurl")]
+ [IgnoreTenant]
public async Task RenewFaceUrlAsync(long taskId)
{
return await _assignmentService.RenewFaceUrlAsync(taskId);
diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs
index 53c70e7d..70c3c029 100644
--- a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs
+++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs
@@ -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;
diff --git a/Src/Dlhis.Sys/Dlhis.Sys.csproj b/Src/Dlhis.Sys/Dlhis.Sys.csproj
index fe92dc2c..2d7b45d8 100644
--- a/Src/Dlhis.Sys/Dlhis.Sys.csproj
+++ b/Src/Dlhis.Sys/Dlhis.Sys.csproj
@@ -17,7 +17,7 @@
-
+
diff --git a/Src/Dlhis.Sys/Menu/Controllers/MenusController.cs b/Src/Dlhis.Sys/Menu/Controllers/MenusController.cs
index 006fb4f1..97808ff2 100644
--- a/Src/Dlhis.Sys/Menu/Controllers/MenusController.cs
+++ b/Src/Dlhis.Sys/Menu/Controllers/MenusController.cs
@@ -40,6 +40,7 @@ public class MenusController : ControllerBase
///
///
[HttpPost]
+ [Transactional]
public async Task Save(SaveMenuRequest request)
{
await _menuService.SaveMenuAsync(request);
diff --git a/Src/Dlhis.Sys/Menu/Services/Implements/MenuService.cs b/Src/Dlhis.Sys/Menu/Services/Implements/MenuService.cs
index b6c8601d..9fd30309 100644
--- a/Src/Dlhis.Sys/Menu/Services/Implements/MenuService.cs
+++ b/Src/Dlhis.Sys/Menu/Services/Implements/MenuService.cs
@@ -41,7 +41,7 @@ public class MenuService : IMenuService
return top;
}
- [Transactional]
+
public async Task SaveMenuAsync(SaveMenuRequest request)
{
await CheckAsync(request);
diff --git a/Src/Dlhis.Sys/SqlSugarPack.cs b/Src/Dlhis.Sys/SqlSugarPack.cs
index 26d783d6..59e2db32 100644
--- a/Src/Dlhis.Sys/SqlSugarPack.cs
+++ b/Src/Dlhis.Sys/SqlSugarPack.cs
@@ -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();
}
}
+
+
+
+
+///
+/// 日志
+///
+[AttributeUsage(AttributeTargets.Method)]
+public class LogAttribute : Attribute, IAsyncActionFilter
+{
+ public LogAttribute(string title)
+ {
+ Title = title;
+ }
+
+ ///
+ ///
+ ///
+ public string Title { get; set; }
+
+ ///
+ /// 是否处理差异
+ ///
+ 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();
+
+ options.Title = Title;
+ options.Diff = Diff;
+ options.BatchNo = Guid.NewGuid();
+ options.RoutePath = httpContext.Request.Path.Value;
+ options.RaiseTime = DateTime.Now;
+ }
+}
+
+///
+/// 事务
+///
+[AttributeUsage(AttributeTargets.Method)]
+public class TransactionalAttribute : Attribute, IAsyncActionFilter
+{
+ public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
+ {
+ var dbContext = context.HttpContext.RequestServices.GetRequiredService();
+ 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;
+ }
+ }
+}
+
+///
+/// 忽略租户
+///
+[AttributeUsage(AttributeTargets.Method)]
+public class IgnoreTenantAttribute : Attribute, IAsyncActionFilter
+{
+ public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
+ {
+ var dbContext = context.HttpContext.RequestServices.GetRequiredService();
+ var options = context.HttpContext!.RequestServices.GetService();
+ try
+ {
+ dbContext.QueryFilter.ClearAndBackup();
+ options.IgnoreTenant = true;
+ await next();
+ }
+ finally
+ {
+ options.IgnoreTenant = false;
+ dbContext.QueryFilter.Restore();
+ }
+ }
+}
+
+
diff --git a/Src/Dlhis.User/Dlhis.User.csproj b/Src/Dlhis.User/Dlhis.User.csproj
index 78c08d85..97629934 100644
--- a/Src/Dlhis.User/Dlhis.User.csproj
+++ b/Src/Dlhis.User/Dlhis.User.csproj
@@ -17,7 +17,7 @@
-
+