fix 就餐增加权限控制
This commit is contained in:
@@ -29,6 +29,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Canteen", "Src\Dlhis.
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Sys.Api", "Src\Dlhis.Sys.Api\Dlhis.Sys.Api.csproj", "{85A345C7-913E-4C1B-BE1C-600DE408A02F}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Sys.Api", "Src\Dlhis.Sys.Api\Dlhis.Sys.Api.csproj", "{85A345C7-913E-4C1B-BE1C-600DE408A02F}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dlhis.Basic.Api", "Src\Dlhis.Basic.Api\Dlhis.Basic.Api.csproj", "{1F337648-8A22-4601-A842-0F634FBA2825}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -71,6 +73,10 @@ Global
|
|||||||
{85A345C7-913E-4C1B-BE1C-600DE408A02F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{85A345C7-913E-4C1B-BE1C-600DE408A02F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{85A345C7-913E-4C1B-BE1C-600DE408A02F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{85A345C7-913E-4C1B-BE1C-600DE408A02F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{85A345C7-913E-4C1B-BE1C-600DE408A02F}.Release|Any CPU.Build.0 = Release|Any CPU
|
{85A345C7-913E-4C1B-BE1C-600DE408A02F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{1F337648-8A22-4601-A842-0F634FBA2825}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{1F337648-8A22-4601-A842-0F634FBA2825}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{1F337648-8A22-4601-A842-0F634FBA2825}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{1F337648-8A22-4601-A842-0F634FBA2825}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -84,6 +90,7 @@ Global
|
|||||||
{925048C9-5940-4B51-8480-4DC908C754A1} = {57074FD8-1A2F-40C7-8476-001778A3F65D}
|
{925048C9-5940-4B51-8480-4DC908C754A1} = {57074FD8-1A2F-40C7-8476-001778A3F65D}
|
||||||
{8317C526-3523-4195-9B19-2F17CFD71927} = {3D8A98C1-83C9-4375-AEAB-4F72AFAF365B}
|
{8317C526-3523-4195-9B19-2F17CFD71927} = {3D8A98C1-83C9-4375-AEAB-4F72AFAF365B}
|
||||||
{85A345C7-913E-4C1B-BE1C-600DE408A02F} = {57074FD8-1A2F-40C7-8476-001778A3F65D}
|
{85A345C7-913E-4C1B-BE1C-600DE408A02F} = {57074FD8-1A2F-40C7-8476-001778A3F65D}
|
||||||
|
{1F337648-8A22-4601-A842-0F634FBA2825} = {4EBCE46B-CE3A-4A47-9432-82A1854CA58A}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {7439494A-E2FD-4FEA-8ABF-74AE57A4A5A0}
|
SolutionGuid = {7439494A-E2FD-4FEA-8ABF-74AE57A4A5A0}
|
||||||
|
|||||||
13
Src/Dlhis.Basic.Api/Dlhis.Basic.Api.csproj
Normal file
13
Src/Dlhis.Basic.Api/Dlhis.Basic.Api.csproj
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Kurisu.RemoteCall" Version="0.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
11
Src/Dlhis.Basic.Api/IDevicePermissionApi.cs
Normal file
11
Src/Dlhis.Basic.Api/IDevicePermissionApi.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using Kurisu.Core.Result;
|
||||||
|
using Kurisu.RemoteCall.Attributes;
|
||||||
|
|
||||||
|
namespace Dlhis.Basic.Api;
|
||||||
|
|
||||||
|
[EnableRemoteClient(Name = "basic-service", BaseUrl = "${InternalRequest:BasicRequestUrl}")]
|
||||||
|
public interface IDevicePermissionApi
|
||||||
|
{
|
||||||
|
[Get("/api/devicepermissions/canteen/uniqueNos")]
|
||||||
|
Task<DefaultApiResult<List<string>>> GetCanteenDeviceUniqueNosByUserNoAsync(string userNo);
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ using Dlhis.Basic.Device.Services;
|
|||||||
using Kurisu.Core.DataAccess.Dto;
|
using Kurisu.Core.DataAccess.Dto;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Org.BouncyCastle.Asn1.Ocsp;
|
||||||
|
|
||||||
namespace Dlhis.Basic.Device.Controllers;
|
namespace Dlhis.Basic.Device.Controllers;
|
||||||
|
|
||||||
@@ -51,4 +52,16 @@ public class DevicePermissionsController : ControllerBase
|
|||||||
{
|
{
|
||||||
return await _devicePermissionService.GetAssigmentByCodeAsync(request);
|
return await _devicePermissionService.GetAssigmentByCodeAsync(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 就餐设备唯一号权限
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userNo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("canteen/uniqueNos")]
|
||||||
|
public async Task<List<string>> GetCanteenDeviceUniqueNosByUserNoAsync(string userNo)
|
||||||
|
{
|
||||||
|
return await _devicePermissionService.GetCanteenDeviceUniqueNosByUserNoAsync(userNo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ namespace Dlhis.Basic.Device.Response;
|
|||||||
|
|
||||||
public class DeviceGroupTreeResponse
|
public class DeviceGroupTreeResponse
|
||||||
{
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 上级分组code
|
/// 上级分组code
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -50,6 +50,14 @@ public interface IDevicePermissionService : IScopeDependency
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<List<Guid>> GetAssignDeviceCodesAsync(string userNo);
|
Task<List<Guid>> GetAssignDeviceCodesAsync(string userNo);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取就餐权限唯一号
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userNo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<string>> GetCanteenDeviceUniqueNosByUserNoAsync(string userNo);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取用户权限设备
|
/// 获取用户权限设备
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -198,6 +198,17 @@ public class DevicePermissionService : IDevicePermissionService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<List<string>> GetCanteenDeviceUniqueNosByUserNoAsync(string userNo)
|
||||||
|
{
|
||||||
|
var all = await GetAssignDeviceCodesAsync(userNo);
|
||||||
|
|
||||||
|
return await _dbContext.Queryable<DeviceEntity>().Where(x => x.Type == DeviceTypeEnumType.Meal)
|
||||||
|
.Where(x => all.Contains(x.Code))
|
||||||
|
.Select(x => x.UniqueNo)
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取用户所有设备权限
|
/// 获取用户所有设备权限
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -340,7 +351,7 @@ public class DevicePermissionService : IDevicePermissionService
|
|||||||
|
|
||||||
var devices = await _dbContext.Queryable<DeviceEntity>().ToListAsync();
|
var devices = await _dbContext.Queryable<DeviceEntity>().ToListAsync();
|
||||||
|
|
||||||
if(ggs != null && ggs.Count > 0)
|
if (ggs != null && ggs.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var gid in ggs)
|
foreach (var gid in ggs)
|
||||||
{
|
{
|
||||||
@@ -351,7 +362,7 @@ public class DevicePermissionService : IDevicePermissionService
|
|||||||
gds.AddRange(ds);
|
gds.AddRange(ds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var dds = gds.Distinct().ToList();
|
var dds = gds.Distinct().ToList();
|
||||||
var lst = devices.Where(x => dds.Contains(x.Code))
|
var lst = devices.Where(x => dds.Contains(x.Code))
|
||||||
.Select(x => new AssigmentByCodeResponse
|
.Select(x => new AssigmentByCodeResponse
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Dlhis.Basic.Api\Dlhis.Basic.Api.csproj" />
|
||||||
<ProjectReference Include="..\Dlhis.Common.Api\Dlhis.Common.Api.csproj" />
|
<ProjectReference Include="..\Dlhis.Common.Api\Dlhis.Common.Api.csproj" />
|
||||||
<ProjectReference Include="..\Dlhis.Entity\Dlhis.Entity.csproj" />
|
<ProjectReference Include="..\Dlhis.Entity\Dlhis.Entity.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -43,5 +43,4 @@ public class OrdersController : ControllerBase
|
|||||||
{
|
{
|
||||||
return await _orderService.AddAsync(request);
|
return await _orderService.AddAsync(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
using Dlhis.Canteen.Order.Request;
|
using Dlhis.Basic.Api;
|
||||||
|
using Dlhis.Canteen.Order.Request;
|
||||||
using Dlhis.Canteen.Order.Response;
|
using Dlhis.Canteen.Order.Response;
|
||||||
using Dlhis.Canteen.Setting.Services;
|
using Dlhis.Canteen.Setting.Services;
|
||||||
using Dlhis.Entity.Basic.Entity;
|
using Dlhis.Entity.Basic.Entity;
|
||||||
using Dlhis.Entity.Canteen.Entities;
|
using Dlhis.Entity.Canteen.Entities;
|
||||||
using Dlhis.Entity.Canteen.Enums;
|
using Dlhis.Entity.Canteen.Enums;
|
||||||
using Dlhis.Entity.Device.Entities;
|
using Dlhis.Entity.Device.Entities;
|
||||||
|
using Dlhis.Entity.Sys.Entities;
|
||||||
using Kurisu.AspNetCore.UnifyResultAndValidation;
|
using Kurisu.AspNetCore.UnifyResultAndValidation;
|
||||||
using Kurisu.AspNetCore.Utils;
|
using Kurisu.AspNetCore.Utils;
|
||||||
using Kurisu.AspNetCore.Utils.Extensions;
|
using Kurisu.AspNetCore.Utils.Extensions;
|
||||||
@@ -22,14 +24,17 @@ public class OrderService : IOrderService
|
|||||||
{
|
{
|
||||||
private readonly IDbContext _dbContext;
|
private readonly IDbContext _dbContext;
|
||||||
private readonly ICanteenSettingService _canteenSettingService;
|
private readonly ICanteenSettingService _canteenSettingService;
|
||||||
|
private readonly IDevicePermissionApi _devicePermissionApi;
|
||||||
private readonly ILogger<OrderService> _logger;
|
private readonly ILogger<OrderService> _logger;
|
||||||
|
|
||||||
public OrderService(IDbContext dbContext,
|
public OrderService(IDbContext dbContext,
|
||||||
ICanteenSettingService canteenSettingService,
|
ICanteenSettingService canteenSettingService,
|
||||||
|
IDevicePermissionApi devicePermissionApi,
|
||||||
ILogger<OrderService> logger)
|
ILogger<OrderService> logger)
|
||||||
{
|
{
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
_canteenSettingService = canteenSettingService;
|
_canteenSettingService = canteenSettingService;
|
||||||
|
_devicePermissionApi = devicePermissionApi;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,6 +47,14 @@ public class OrderService : IOrderService
|
|||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task CheckPAsync(string userNo, string deviceUniqueNo)
|
||||||
|
{
|
||||||
|
var uniqueNosResult = await _devicePermissionApi.GetCanteenDeviceUniqueNosByUserNoAsync(userNo);
|
||||||
|
var uniqueNos = uniqueNosResult.Data;
|
||||||
|
|
||||||
|
uniqueNos.Contains(deviceUniqueNo).ThrowIfFalse("无消费权限");
|
||||||
|
}
|
||||||
|
|
||||||
[IgnoreTenant]
|
[IgnoreTenant]
|
||||||
public async Task<OrderResultResponse> AddAsync(OrderAddRequest request)
|
public async Task<OrderResultResponse> AddAsync(OrderAddRequest request)
|
||||||
{
|
{
|
||||||
@@ -59,7 +72,8 @@ public class OrderService : IOrderService
|
|||||||
.AnyAsync();
|
.AnyAsync();
|
||||||
canteenUserExists.ThrowIfFalse($"就餐用户{request.UserUniqueNo}不存在,无法操作");
|
canteenUserExists.ThrowIfFalse($"就餐用户{request.UserUniqueNo}不存在,无法操作");
|
||||||
|
|
||||||
|
//消费权限控制
|
||||||
|
await CheckPAsync(gainfo.No, request.DeviceUniqueNo);
|
||||||
|
|
||||||
//消费
|
//消费
|
||||||
if (request.Type == BalanceRecordTypeEnumType.Out)
|
if (request.Type == BalanceRecordTypeEnumType.Out)
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"InternalRequest": {
|
"InternalRequest": {
|
||||||
"CommonRequestUrl": "http://localhost:5001"
|
"CommonRequestUrl": "http://localhost:5001",
|
||||||
|
"BasicRequestUrl": "http://localhost:5002"
|
||||||
},
|
},
|
||||||
"SwaggerOptions": {
|
"SwaggerOptions": {
|
||||||
"Enable": true,
|
"Enable": true,
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"InternalRequest": {
|
"InternalRequest": {
|
||||||
"CommonRequestUrl": "http://common"
|
"CommonRequestUrl": "http://common",
|
||||||
|
"BasicRequestUrl": "http://basic"
|
||||||
},
|
},
|
||||||
"SqlSugarOptions": {
|
"SqlSugarOptions": {
|
||||||
"DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=yikatong;charset=utf8mb4;",
|
"DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=yikatong;charset=utf8mb4;",
|
||||||
|
|||||||
25
Src/Dlhis.Entity/Basic/Entity/BusinessPlaceGroupEntity.cs
Normal file
25
Src/Dlhis.Entity/Basic/Entity/BusinessPlaceGroupEntity.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
using Kurisu.Core.DataAccess.Entity;
|
||||||
|
using Kurisu.SqlSugar;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Dlhis.Entity.Basic.Entity;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 营业点分组
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable(TableName = "BusinessPlaceGroup", TableDescription = "营业点分组")]
|
||||||
|
public class BusinessPlaceGroupEntity : SugarBaseEntity, ITenantId
|
||||||
|
{
|
||||||
|
public Guid? PCode { get; set; }
|
||||||
|
|
||||||
|
public Guid Code { get; set; }
|
||||||
|
|
||||||
|
[SugarColumn(ColumnDescription = "名称")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
[SugarColumn(ColumnDescription = "备注")]
|
||||||
|
public string Remark { get; set; }
|
||||||
|
|
||||||
|
public string TenantId { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using Kurisu.Core.DataAccess.Entity;
|
||||||
|
using Kurisu.SqlSugar;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Dlhis.Entity.Basic.Entity;
|
||||||
|
|
||||||
|
|
||||||
|
[SugarTable(TableName = "BusinessPlaceGroupRelationship", TableDescription = "营业点分组")]
|
||||||
|
public class BusinessPlaceGroupRelationshipEntity : SugarBaseEntity, ITenantId
|
||||||
|
{
|
||||||
|
public Guid BusinessPlaceGroupCode { get; set; }
|
||||||
|
|
||||||
|
public Guid BusinessPlaceCode { get; set; }
|
||||||
|
|
||||||
|
public string TenantId { get; set; }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user