|
using Microsoft.AspNetCore.Http;
|
using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
using System.Drawing.Printing;
|
using System.Dynamic;
|
using System.Linq;
|
using System.Reflection;
|
using System.Text;
|
using System.Threading.Tasks;
|
using WIDESEA_Core;
|
using WIDESEA_Core.BaseRepository;
|
using WIDESEA_Core.BaseServices;
|
using WIDESEA_Core.DB.Models;
|
using WIDESEA_Core.Enums;
|
using WIDESEA_Core.Helper;
|
using WIDESEA_Core.HostedService;
|
using WIDESEA_Core.Utilities;
|
using WIDESEA_DTO.Stock;
|
using WIDESEA_IStockRepository;
|
using WIDESEA_IStockService;
|
using WIDESEA_Model.Models;
|
|
namespace WIDESEA_StockService
|
{
|
public partial class StockViewService : IStockViewService
|
{
|
private string GetDataRole(Type type)
|
{
|
try
|
{
|
UserRole? userRole = PermissionDataHostService.UserRoles.FirstOrDefault(x => x.UserId == App.User.UserId);
|
if (userRole == null)
|
throw new Exception($"无权限");
|
|
if (type.IsAssignableFrom(typeof(BaseWarehouseEntity)) || type.GetProperty(nameof(BaseWarehouseEntity.WarehouseId)) != null)
|
{
|
if (userRole.WarehouseIds.Count > 0)
|
{
|
return $"{nameof(BaseWarehouseEntity.WarehouseId)} in ({userRole.WarehouseIds.Serialize().Replace("[", "").Replace("]", "")})";
|
}
|
|
else
|
return $"1 != 1";
|
}
|
else
|
{
|
return "1 = 1";
|
}
|
}
|
catch (Exception ex)
|
{
|
throw new Exception($"无权限,{ex.Message}");
|
}
|
}
|
}
|
}
|