feat 根据用户查看餐饮点
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Basic.Organization.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Controllers
|
||||
{
|
||||
[Authorize]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class GainfoPermissionsController : ControllerBase
|
||||
{
|
||||
private readonly IGainfoPermissions _gainfoPermissions;
|
||||
|
||||
|
||||
public GainfoPermissionsController(IGainfoPermissions gainfoPermissions)
|
||||
{
|
||||
_gainfoPermissions = gainfoPermissions;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据用户查看餐饮点
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("placesByGainfo")]
|
||||
public async Task<List<GetPlaceByGainfoResponse>> GetPlaceByGainfoAsync([FromQuery]GetPlaceByGainfoRequest request)
|
||||
{
|
||||
return await _gainfoPermissions.GetPlaceByGainfoAsync(request);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Request
|
||||
{
|
||||
public class GetPlaceByGainfoRequest : PageDto
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Dlhis.Basic.Organization.Response
|
||||
{
|
||||
public class GetPlaceByGainfoResponse
|
||||
{
|
||||
public Guid PlaceCode { get; set; }
|
||||
public string PlaceName { get; set; }
|
||||
}
|
||||
}
|
||||
10
Src/Dlhis.Basic/Organization/Services/IGainfoPermissions.cs
Normal file
10
Src/Dlhis.Basic/Organization/Services/IGainfoPermissions.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Services
|
||||
{
|
||||
public interface IGainfoPermissions : IScopeDependency
|
||||
{
|
||||
Task<List<GetPlaceByGainfoResponse>> GetPlaceByGainfoAsync(GetPlaceByGainfoRequest request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using Dlhis.Basic.Device.Request;
|
||||
using Dlhis.Basic.Device.Services;
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Basic.Enums;
|
||||
using Dlhis.Entity.Device.Entities;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Services.Implements
|
||||
{
|
||||
public class GainfoPermissions : IGainfoPermissions
|
||||
{
|
||||
private readonly IGainfoStore _gainfoStore;
|
||||
private readonly IDevicePermissionService _devicePermissionService;
|
||||
private readonly IDbContext _dbContext;
|
||||
|
||||
public GainfoPermissions(IGainfoStore gainfoStore, IDevicePermissionService devicePermissionService, IDbContext dbContext)
|
||||
{
|
||||
_gainfoStore = gainfoStore;
|
||||
_devicePermissionService = devicePermissionService;
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task<List<GetPlaceByGainfoResponse>> GetPlaceByGainfoAsync(GetPlaceByGainfoRequest request)
|
||||
{
|
||||
var lst = new List<GetPlaceByGainfoResponse>();
|
||||
var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
|
||||
.Where(x => x.No == request.Search || x.Code == request.Search)
|
||||
.FirstAsync();
|
||||
gainfo.ThrowIfNull($"用户不存在!");
|
||||
|
||||
var req = new AssigmentByCodeRequest
|
||||
{
|
||||
No = gainfo.No
|
||||
};
|
||||
var devices = await _devicePermissionService.GetAssigmentByCodeAsync(req);
|
||||
if (devices != null)
|
||||
{
|
||||
//用户权限设备
|
||||
var unids = new List<string>();
|
||||
foreach (var item in devices.Data)
|
||||
{
|
||||
unids.Add(item.UniqueNo);
|
||||
}
|
||||
//餐饮设备
|
||||
var ids = await _dbContext.Queryable<DeviceEntity>()
|
||||
.Where(x => unids.Contains(x.UniqueNo))
|
||||
.Where(x => x.Type == DeviceTypeEnumType.Meal)
|
||||
.Select(x => x.UniqueNo)
|
||||
.ToListAsync();
|
||||
|
||||
var places = await _dbContext.Queryable<DeviceRegistryEntity>()
|
||||
.Where(x => ids.Contains(x.DeviceUniqueNo))
|
||||
.Select(x => x.BusinessPlaceCode)
|
||||
.ToListAsync();
|
||||
var bplaces = await _dbContext.Queryable<BusinessPlaceEntity>().ToListAsync();
|
||||
foreach (var code in places)
|
||||
{
|
||||
if(code == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var res = new GetPlaceByGainfoResponse();
|
||||
res.PlaceCode = (Guid)code;
|
||||
res.PlaceName = bplaces.Where(x => x.Code == code).Select(x => x.Name).FirstOrDefault();
|
||||
lst.Add(res);
|
||||
}
|
||||
}
|
||||
|
||||
return lst;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public class GainfoService : IGainfoService
|
||||
IServiceProvider serviceProvider,
|
||||
IConfiguration configuration,
|
||||
ILogger<GainfoService> logger,
|
||||
IDepartmentService departmentService = null)
|
||||
IDepartmentService departmentService)
|
||||
{
|
||||
_gainfoStore = gainfoStore;
|
||||
_dbContext = dbContext;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.Core.CustomClass;
|
||||
using SqlSugar.DbConvert;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request;
|
||||
|
||||
@@ -17,6 +19,12 @@ public class BalanceRecordPageRequest : PageDto, IValidatableObject
|
||||
/// </summary>
|
||||
public List<string> ShiftTypes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 充值/消费
|
||||
/// </summary>
|
||||
[EnumDataType(typeof(BalanceRecordTypeEnumType))]
|
||||
public BalanceRecordTypeEnumType Type { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询日期范围类型 DateTimeSearchEnumType
|
||||
|
||||
@@ -46,6 +46,7 @@ public class BalanceService : IBalanceService
|
||||
.WhereIF(request.SearchDateTimePeriod?.End.HasValue == true, record => record.CostDate <= request.SearchDateTimePeriod.End)
|
||||
.WhereIF(request.BusinessplaceCodes.IsPresent(), record => request.BusinessplaceCodes.Contains(record.BusinessPlaceCode))
|
||||
.WhereIF(request.ShiftTypes.IsPresent(), record => request.ShiftTypes.Contains(record.ShiftType))
|
||||
.WhereIF(request.Type.ToString().IsPresent(),record => record.Type == request.Type)
|
||||
.WhereIF(request.Search.IsPresent(), (record, ga) =>
|
||||
ga.Name.Contains(request.Search)
|
||||
|| ga.Code.Contains(request.Search)
|
||||
|
||||
Reference in New Issue
Block a user