fix 优化查询,增加详情接口
This commit is contained in:
@@ -86,6 +86,17 @@ public class DishesMenusController : ControllerBase
|
||||
await _dishesService.SaveDishesAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据id获取菜品详情
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("dishes/detail/{id}")]
|
||||
public async Task<DishesDetailResponse> GetDishesDetailByIdAsync(long id)
|
||||
{
|
||||
return await _dishesService.GetDishesDetailByIdAsync(id);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取预定送餐配置
|
||||
|
||||
@@ -4,5 +4,8 @@ namespace Dlhis.Basic.Dishes.Request;
|
||||
|
||||
public class DishesPageRequest : PageDto
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 营业点
|
||||
/// </summary>
|
||||
public List<Guid> BusinessPlaceCodes { get; set; }
|
||||
}
|
||||
|
||||
51
Src/Dlhis.Basic/Dishes/Response/DishesDetailResponse.cs
Normal file
51
Src/Dlhis.Basic/Dishes/Response/DishesDetailResponse.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
namespace Dlhis.Basic.Dishes.Response;
|
||||
|
||||
public class DishesDetailResponse
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分类
|
||||
/// </summary>
|
||||
public Guid CategoryCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 营业点
|
||||
/// </summary>
|
||||
public Guid BusinessPlaceCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜品编码
|
||||
/// </summary>
|
||||
public string CustomCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜品名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单价
|
||||
/// </summary>
|
||||
public decimal Price { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// </summary>
|
||||
public List<string> Units { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 图片
|
||||
/// </summary>
|
||||
public string ImageUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public bool Enable { get; set; }
|
||||
}
|
||||
@@ -4,6 +4,8 @@ namespace Dlhis.Basic.Dishes.Response;
|
||||
|
||||
public class DishesMenuPageResponse
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜单编码
|
||||
/// </summary>
|
||||
|
||||
@@ -10,6 +10,8 @@ public interface IDishesService : IScopeDependency
|
||||
|
||||
Task SaveDishesAsync(DishesSaveRequest request);
|
||||
|
||||
Task<DishesDetailResponse> GetDishesDetailByIdAsync(long id);
|
||||
|
||||
Task<GetDishesMenusBookingResponse> GetDishesMenusBookingSetting(GetDishesMenusBookingRequest request);
|
||||
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class DishesMenuService : IDishesMenuService
|
||||
var res = await _businessPlacePermissionsService.GetMyAsync();
|
||||
var myBps = res.dtos.Select(x => x.Code).ToList();
|
||||
|
||||
myBps.Contains(request.BusinessPlaceCode).ThrowIfFalse("当前经营营业点,无法保存菜单");
|
||||
myBps.Contains(request.BusinessPlaceCode).ThrowIfFalse("非经营营业点,无法保存菜单");
|
||||
|
||||
var entities = request.Items.SelectMany(item =>
|
||||
{
|
||||
|
||||
@@ -30,6 +30,7 @@ public class DishesService : IDishesService
|
||||
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))
|
||||
.OrderBy(x => x.CreateTime, SqlSugar.OrderByType.Desc)
|
||||
.Select((x, category) => new DishesResponse
|
||||
{
|
||||
@@ -103,4 +104,11 @@ public class DishesService : IDishesService
|
||||
|
||||
}
|
||||
|
||||
public async Task<DishesDetailResponse> GetDishesDetailByIdAsync(long id)
|
||||
{
|
||||
return await _dbContext.Queryable<DishesEntity>()
|
||||
.Where(x => x.Id == id)
|
||||
.Select<DishesDetailResponse>()
|
||||
.SingleAsync();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user