fix 优化查询
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Dlhis.Basic.Dishes.Request;
|
||||
using Dlhis.Basic.Dishes.Response;
|
||||
using Dlhis.Basic.Dishes.Services;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@@ -31,6 +32,19 @@ public class DishesCategoriesController : ControllerBase
|
||||
return await _dishesCategoryService.TreeAsync();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="businessPlaceCode"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("tree-all")]
|
||||
[IgnoreTenant]
|
||||
public async Task<List<DishesCategoryTreeResponse>> TreeAllAsync(Guid businessPlaceCode)
|
||||
{
|
||||
return await _dishesCategoryService.TreeAllAsync(businessPlaceCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存分类
|
||||
/// </summary>
|
||||
|
||||
@@ -60,6 +60,7 @@ public class DishesMenusController : ControllerBase
|
||||
/// <param name="categoryCode"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("dishes-selections")]
|
||||
[IgnoreTenant]
|
||||
public async Task<List<DishesDetailResponse>> GetDishesUnderCurrentMenuAsync(Guid businessPlaceCode,
|
||||
DateTime date,
|
||||
ShiftEnumType? shiftType,
|
||||
|
||||
@@ -7,5 +7,9 @@ public interface IDishesCategoryService : IScopeDependency
|
||||
{
|
||||
Task<List<DishesCategoryTreeResponse>> TreeAsync();
|
||||
|
||||
|
||||
Task<List<DishesCategoryTreeResponse>> TreeAllAsync(Guid businessPlaceCode);
|
||||
|
||||
|
||||
Task SaveAsync(DishesCategorySaveRequest request);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,32 @@ public class DishesCategoryService : IDishesCategoryService
|
||||
return tops;
|
||||
}
|
||||
|
||||
public async Task<List<DishesCategoryTreeResponse>> TreeAllAsync(Guid businessPlaceCode)
|
||||
{
|
||||
var categories = await _dbContext.Queryable<DishesCategoryEntity>()
|
||||
.LeftJoin<BusinessPlaceEntity>((x, bplace) => x.BusinessPlaceCode == bplace.Code)
|
||||
.Where(x => x.BusinessPlaceCode == businessPlaceCode)
|
||||
.Select((x, bplace) => new DishesCategoryTreeResponse
|
||||
{
|
||||
BusinessPlaceCode = bplace.Code,
|
||||
Code = x.Code,
|
||||
Name = x.Name,
|
||||
PCode = x.PCode,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var tops = categories.Where(x => !x.PCode.HasValue).ToList();
|
||||
|
||||
tops.ForEach(x =>
|
||||
{
|
||||
RecursionGetNext(x, categories);
|
||||
});
|
||||
|
||||
return tops;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task SaveAsync(DishesCategorySaveRequest request)
|
||||
{
|
||||
await CheckBusinessPlacePermissionAsync(request.BusinessPlaceCode);
|
||||
|
||||
Reference in New Issue
Block a user