fix 调整用户对应营业点处理
This commit is contained in:
@@ -1,34 +1,31 @@
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
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
|
||||
namespace Dlhis.Basic.Organization.Controllers;
|
||||
|
||||
[Authorize]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class GainfoPermissionsController : ControllerBase
|
||||
{
|
||||
[Authorize]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class GainfoPermissionsController : ControllerBase
|
||||
private readonly IGainfoPermissions _gainfoPermissions;
|
||||
|
||||
|
||||
public GainfoPermissionsController(IGainfoPermissions gainfoPermissions)
|
||||
{
|
||||
private readonly IGainfoPermissions _gainfoPermissions;
|
||||
_gainfoPermissions = 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);
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据用户查看餐饮点
|
||||
/// </summary>
|
||||
/// <param name="userNo"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("placesByGainfo")]
|
||||
public async Task<List<GetPlaceByGainfoResponse>> GetPlaceByGainfoAsync(string userNo)
|
||||
{
|
||||
return await _gainfoPermissions.GetPlaceByGainfoAsync(userNo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Request
|
||||
{
|
||||
public class GetPlaceByGainfoRequest : PageDto
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Services
|
||||
namespace Dlhis.Basic.Organization.Services;
|
||||
|
||||
public interface IGainfoPermissions : IScopeDependency
|
||||
{
|
||||
public interface IGainfoPermissions : IScopeDependency
|
||||
{
|
||||
Task<List<GetPlaceByGainfoResponse>> GetPlaceByGainfoAsync(GetPlaceByGainfoRequest request);
|
||||
}
|
||||
Task<List<GetPlaceByGainfoResponse>> GetPlaceByGainfoAsync(string userNo);
|
||||
|
||||
//Task GetDevicesUnderGroupByUserNoAsync(string userNo, string deviceGroupCode);
|
||||
}
|
||||
|
||||
@@ -1,78 +1,52 @@
|
||||
using Dlhis.Basic.Device.Request;
|
||||
using Dlhis.Basic.Device.Services;
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
using Dlhis.Basic.Device.Services;
|
||||
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
|
||||
namespace Dlhis.Basic.Organization.Services.Implements;
|
||||
|
||||
public class GainfoPermissions : IGainfoPermissions
|
||||
{
|
||||
public class GainfoPermissions : IGainfoPermissions
|
||||
private readonly IGainfoStore _gainfoStore;
|
||||
private readonly IDevicePermissionService _devicePermissionService;
|
||||
private readonly IDbContext _dbContext;
|
||||
|
||||
public GainfoPermissions(IGainfoStore gainfoStore, IDevicePermissionService devicePermissionService, IDbContext dbContext)
|
||||
{
|
||||
private readonly IGainfoStore _gainfoStore;
|
||||
private readonly IDevicePermissionService _devicePermissionService;
|
||||
private readonly IDbContext _dbContext;
|
||||
_gainfoStore = gainfoStore;
|
||||
_devicePermissionService = devicePermissionService;
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
public GainfoPermissions(IGainfoStore gainfoStore, IDevicePermissionService devicePermissionService, IDbContext dbContext)
|
||||
public async Task<List<GetPlaceByGainfoResponse>> GetPlaceByGainfoAsync(string userNo)
|
||||
{
|
||||
var gainfo = await _gainfoStore.Queryable()
|
||||
.Where(x => x.No == userNo)
|
||||
.FirstAsync();
|
||||
|
||||
if (gainfo == null)
|
||||
{
|
||||
_gainfoStore = gainfoStore;
|
||||
_devicePermissionService = devicePermissionService;
|
||||
_dbContext = dbContext;
|
||||
return new List<GetPlaceByGainfoResponse>();
|
||||
}
|
||||
|
||||
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($"用户不存在!");
|
||||
//用户所有deviceCode权限
|
||||
var deviceCodes = await _devicePermissionService.GetAssignDeviceCodesAsync(gainfo.No);
|
||||
|
||||
var req = new AssigmentByCodeRequest
|
||||
return await _dbContext.Queryable<DeviceEntity>()
|
||||
.LeftJoin<DeviceRegistryEntity>((x, dr) => x.UniqueNo == dr.DeviceUniqueNo)
|
||||
.LeftJoin<BusinessPlaceEntity>((x, dr, place) => dr.BusinessPlaceCode == place.Code)
|
||||
.Where(x => x.Type == DeviceTypeEnumType.Meal)
|
||||
.Where(x => deviceCodes.Contains(x.Code))
|
||||
.Where((x, dr) => !string.IsNullOrEmpty(dr.BusinessPlaceCustomCode))
|
||||
.Select((x, dr, place) => new GetPlaceByGainfoResponse
|
||||
{
|
||||
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();
|
||||
PlaceCode = place.Code,
|
||||
PlaceName = place.Name
|
||||
})
|
||||
.Distinct()
|
||||
.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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user