fix 营业点控制(admin),unit返回
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
namespace Dlhis.Basic.Dishes.Response;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Dlhis.Basic.Dishes.Response;
|
||||
|
||||
public class DishesDetailResponse
|
||||
{
|
||||
@@ -42,7 +45,20 @@ public class DishesDetailResponse
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// </summary>
|
||||
public List<string> Units { get; set; }
|
||||
public List<string> Units
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CurrentUnits.IsPresent())
|
||||
{
|
||||
return CurrentUnits.ToObject<List<string>>();
|
||||
}
|
||||
return new () { "个" };
|
||||
}
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public string CurrentUnits { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 图片
|
||||
|
||||
@@ -93,6 +93,7 @@ public class DishesMenuService : IDishesMenuService
|
||||
Price = dishes.Price,
|
||||
Name = dishes.Name,
|
||||
Number = x.Number,
|
||||
CurrentUnits = dishes.Units.ToString()
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ using Dlhis.Basic.Places.Dtos;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Dlhis.Sys.Api;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace Dlhis.Basic.BusinessPlace.Services.Implements;
|
||||
|
||||
@@ -51,15 +52,17 @@ public class BusinessPlacePermissionsService : IBusinessPlacePermissionsService
|
||||
public async Task<List<BusinessPlaceDto>> GetMyAsync()
|
||||
{
|
||||
var userId = _currentUser.GetIntSubjectId();
|
||||
var role = _currentUser.GetUserClaim(ClaimTypes.Role);
|
||||
var isAdmin = role == "admin" || role == "tenant-admin";
|
||||
|
||||
var guids = await _dbContext.Queryable<BusinessPlaceManagerRelationshipEntity>()
|
||||
.Where(x => x.ManagerUserId == userId)
|
||||
var codes = await _dbContext.Queryable<BusinessPlaceManagerRelationshipEntity>()
|
||||
.WhereIF(!isAdmin, x => x.ManagerUserId == userId)
|
||||
.Select(x => x.BusinessPlaceCode)
|
||||
.Distinct()
|
||||
.ToListAsync();
|
||||
|
||||
return await _dbContext.Queryable<BusinessPlaceEntity>()
|
||||
.Where(x => guids.Contains(x.Code))
|
||||
.Where(x => codes.Contains(x.Code))
|
||||
.Select<BusinessPlaceDto>()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user