fix 分类树增加营业点参数
This commit is contained in:
@@ -25,16 +25,17 @@ public class DishesCategoriesController : ControllerBase
|
||||
/// <summary>
|
||||
/// 获取分类树
|
||||
/// </summary>
|
||||
/// <param name="businessPlaceCode"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("tree")]
|
||||
public async Task<List<DishesCategoryTreeResponse>> TreeAsync()
|
||||
public async Task<List<DishesCategoryTreeResponse>> TreeAsync(Guid businessPlaceCode)
|
||||
{
|
||||
return await _dishesCategoryService.TreeAsync();
|
||||
return await _dishesCategoryService.TreeAsync(businessPlaceCode);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 获取分类树(无权限)
|
||||
/// </summary>
|
||||
/// <param name="businessPlaceCode"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Dlhis.Basic.Dishes.Services;
|
||||
|
||||
public interface IDishesCategoryService : IScopeDependency
|
||||
{
|
||||
Task<List<DishesCategoryTreeResponse>> TreeAsync();
|
||||
Task<List<DishesCategoryTreeResponse>> TreeAsync(Guid businessPlaceCode);
|
||||
|
||||
|
||||
Task<List<DishesCategoryTreeResponse>> TreeAllAsync(Guid businessPlaceCode);
|
||||
|
||||
@@ -20,9 +20,10 @@ public class DishesCategoryService : IDishesCategoryService
|
||||
_businessPlacePermissionsService = businessPlacePermissionsService;
|
||||
}
|
||||
|
||||
public async Task<List<DishesCategoryTreeResponse>> TreeAsync()
|
||||
public async Task<List<DishesCategoryTreeResponse>> TreeAsync(Guid businessPlaceCode)
|
||||
{
|
||||
var mybCodes = await GetMyBusinessPlaceCodesAsync();
|
||||
mybCodes = mybCodes.Where(x => x == businessPlaceCode).ToList();
|
||||
|
||||
var categories = await _dbContext.Queryable<DishesCategoryEntity>()
|
||||
.LeftJoin<BusinessPlaceEntity>((x, bplace) => x.BusinessPlaceCode == bplace.Code)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Dlhis.Basic.Dishes.Request;
|
||||
using Dlhis.Basic.BusinessPlace.Services;
|
||||
using Dlhis.Basic.Dishes.Request;
|
||||
using Dlhis.Basic.Dishes.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
@@ -16,21 +17,24 @@ public class DishesService : IDishesService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly ICurrentUser _currentUser;
|
||||
private readonly IBusinessPlacePermissionsService _businessPlacePermissionsService;
|
||||
|
||||
public DishesService(IDbContext dbContext, ICurrentUser currentUser)
|
||||
public DishesService(IDbContext dbContext, ICurrentUser currentUser, IBusinessPlacePermissionsService businessPlacePermissionsService)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_currentUser = currentUser;
|
||||
_businessPlacePermissionsService = businessPlacePermissionsService;
|
||||
}
|
||||
|
||||
public async Task<Pagination<DishesResponse>> GetDishesPageAsync(DishesPageRequest request)
|
||||
{
|
||||
//todo 营业点权限
|
||||
var myCodes = await GetMyBusinessPlaceCodesAsync();
|
||||
|
||||
return await _dbContext.Queryable<DishesEntity>()
|
||||
.LeftJoin<DishesCategoryEntity>((x, category) => x.CategoryCode == category.Code)
|
||||
.WhereIF(request.Search.IsPresent(), x => x.CustomCode == request.Search || x.Name.Contains(request.Search))
|
||||
.WhereIF(request.BusinessPlaceCodes.IsPresent(), x => request.BusinessPlaceCodes.Contains(x.BusinessPlaceCode))
|
||||
.Where(x => myCodes.Contains(x.BusinessPlaceCode))
|
||||
.OrderBy(x => x.CreateTime, SqlSugar.OrderByType.Desc)
|
||||
.Select((x, category) => new DishesResponse
|
||||
{
|
||||
@@ -109,5 +113,17 @@ public class DishesService : IDishesService
|
||||
.Select<DishesDetailResponse>()
|
||||
.SingleAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取我的营业点
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task<List<Guid>> GetMyBusinessPlaceCodesAsync()
|
||||
{
|
||||
return (await _businessPlacePermissionsService.GetMyAsync()).Select(x => x.Code).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user