fix 优化菜品保存和分页

This commit is contained in:
2024-03-18 13:42:35 +08:00
parent fcc1f134ed
commit b3b99623e3
15 changed files with 80 additions and 56 deletions

View File

@@ -7,7 +7,6 @@ using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
using Kurisu.Core.DataAccess.Dto;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Org.BouncyCastle.Asn1.Ocsp;
namespace Dlhis.Basic.Dishes.Controller;

View File

@@ -12,6 +12,12 @@ public class DishesSaveRequest
[Required]
public Guid CategoryCode { get; set; }
/// <summary>
/// 营业点
/// </summary>
[Required]
public Guid BusinessPlaceCode { get; set; }
/// <summary>
/// 菜品名称
/// </summary>
@@ -40,6 +46,12 @@ public class DishesSaveRequest
/// </summary>
public string ImageUrl { get; set; }
/// <summary>
/// 单位
/// </summary>
[MinLength(1)]
public List<string> Units { get; set; }
/// <summary>
/// 是否启用
/// </summary>

View File

@@ -1,6 +1,4 @@
using Dlhis.Entity.Canteen.Enums;
using SqlSugar.DbConvert;
using SqlSugar;
namespace Dlhis.Basic.Dishes.Response;
@@ -11,11 +9,6 @@ public class DishesMenuPageResponse
/// </summary>
public string CustomCode { get; set; }
/// <summary>
/// 菜单类型
/// </summary>
public CanteenMenuEnumType Type { get; set; }
/// <summary>
/// 所属营业点
/// </summary>

View File

@@ -1,40 +1,35 @@
using Dlhis.Entity.Canteen.Enums;
using Kurisu.AspNetCore.Utils.Extensions;
using Kurisu.AspNetCore.Utils.Extensions;
using Newtonsoft.Json;
namespace Dlhis.Basic.Dishes.Response;
public class DishesResponse
{
/// <summary>
/// 大类
/// 分类
/// </summary>
public string Categories { get; set; }
public Guid CategoryCode { get; set; }
/// <summary>
/// 小类
/// 分类
/// </summary>
public string SubCategories { get; set; }
public string CategoryName { get; set; }
/// <summary>
/// 营业点
/// </summary>
public Guid BusinessPlaceCode { get; set; }
/// <summary>
/// 菜品编码
/// </summary>
public string Code { get; set; }
public string CustomCode { get; set; }
/// <summary>
/// 菜品名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 菜品类型
/// </summary>
public CanteenMenuEnumType Type { get; set; }
/// <summary>
/// 菜品类型描述
/// </summary>
public string TypeDescription => Type.GetDescription();
/// <summary>
/// 描述
/// </summary>
@@ -43,25 +38,23 @@ public class DishesResponse
/// <summary>
/// 单价
/// </summary>
public decimal Amount { get; set; }
public decimal Price { get; set; }
/// <summary>
/// 单位
/// </summary>
public string Unit { get; set; }
public List<string> Units => CurrnetUnits.ToObject<List<string>>();
[JsonIgnore]
public string CurrnetUnits { get; set; }
/// <summary>
/// 图片
/// </summary>
public string Image { get; set; }
public string ImageUrl { get; set; }
/// <summary>
/// 是否启用
/// </summary>
public bool Enable { get; set; }
/// <summary>
/// 限售份数
/// </summary>
public int? RestrictedNum { get; set; } = null;
}

View File

@@ -64,7 +64,7 @@ public class DishesMenuService : IDishesMenuService
Number = number,
Price = price,
Type = CanteenMenuEnumType.Booking,
Type = CanteenApplicaitonTypeEnumType.Booking,
Version = 0,
Enable = false,
};

View File

@@ -8,7 +8,6 @@ using Kurisu.Core.DataAccess.Dto;
using Kurisu.SqlSugar.Extensions;
using Kurisu.SqlSugar.Services;
using Mapster;
using System.Collections.Generic;
namespace Dlhis.Basic.Dishes.Services.Implements;
@@ -28,9 +27,15 @@ public class DishesService : IDishesService
//todo 营业点权限
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))
.OrderBy(x => x.CreateTime, SqlSugar.OrderByType.Desc)
.Select<DishesResponse>()
.Select((x, category) => new DishesResponse
{
CurrnetUnits = x.Units.ToString(),
CategoryName = category.Name,
}, true)
.ToPageListAsync(request);
}
@@ -60,7 +65,7 @@ public class DishesService : IDishesService
.FirstAsync();
shift.ThrowIfNull($"营业点{request.PlaceCode}吗,没有餐别!");
var BusinessShiftMealRelationships= await _dbContext.Queryable<BusinessShiftMealRelationshipEntity>()
var BusinessShiftMealRelationships = await _dbContext.Queryable<BusinessShiftMealRelationshipEntity>()
.Where(x => x.ShiftCode == shift.ShiftCode)
.Select<BusinessShiftMealRelationshipResponse>()
.ToListAsync();
@@ -74,7 +79,7 @@ public class DishesService : IDishesService
{
payTypes.Add(BalanceRecordSourceEnumType.LocalTenantSubsidies);
}
var res = new GetDishesMenusBookingResponse
{
BusinessShiftMealRelationships = BusinessShiftMealRelationships,

View File

@@ -3,7 +3,6 @@ using Dlhis.Common.Response;
using Dlhis.Common.Services.Implements;
using Kurisu.Core.DataAccess.Dto;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace Dlhis.Common.ApiLog
@@ -27,6 +26,7 @@ namespace Dlhis.Common.ApiLog
/// 获取api日志
/// </summary>
/// <returns></returns>
[Authorize(Roles = "admin")]
[HttpGet("logs")]
public async Task<Pagination<ApiLogResponse>> GetLogsAsync([FromQuery] ApiLogRequest request)
{

View File

@@ -33,9 +33,9 @@
//服务器IP
"Endpoint": "http://192.168.199.124:9000",
//账号
"AccessKey": "oQ7tD55EVNElIoO3D43r",
"AccessKey": "bmQOlK0COe5nL56kzGd3",
//密码
"SecretKey": "3eWLaAFQ9fnFx8pOp5SgJogoF47ecAH6dcCWlyAp",
"SecretKey": "Udc5uBrGcT2yukfGXQtHKpqLQ27L1FmbrLyYunBr",
//默认存储桶
"DefaultBucket": "apk"
}

View File

@@ -43,9 +43,9 @@
//服务器IP
"Endpoint": "http://192.168.199.124:9000",
//账号
"AccessKey": "Zbjj05OFtR19e5TJopQU",
"AccessKey": "bmQOlK0COe5nL56kzGd3",
//密码
"SecretKey": "UMXtNdZhufhAAyYJ3XND4cEgZNUsgOWtbUzksizK",
"SecretKey": "Udc5uBrGcT2yukfGXQtHKpqLQ27L1FmbrLyYunBr",
//apk默认存储桶
"DefaultBucket": "apk"
},

View File

@@ -139,5 +139,12 @@ public class BalanceRecordEntity : SugarBaseEntity, ITenantId
[SugarColumn(ColumnDescription = "备注")]
public string Remark { get; set; }
/// <summary>
/// 餐饮应用类型
/// </summary>
[SugarColumn(ColumnDescription = "餐饮应用类型", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))]
public CanteenApplicaitonTypeEnumType ApplicationType { get; set; }
public string TenantId { get; set; }
}

View File

@@ -9,7 +9,7 @@ namespace Dlhis.Entity.Canteen.Entities;
/// 菜品表
/// </summary>
[SugarTable(TableName = "Dishes", TableDescription = "菜品表")]
public class DishesEntity : SugarBaseEntity, ITenantId
public class DishesEntity : SugarBaseEntity, IImageUrl, ITenantId
{
/// <summary>
/// 分类
@@ -20,6 +20,7 @@ public class DishesEntity : SugarBaseEntity, ITenantId
/// <summary>
/// 营业点
/// </summary>
[SugarColumn(ColumnDescription = "营业点", IsNullable = false)]
public Guid BusinessPlaceCode { get; set; }
/// <summary>
@@ -47,6 +48,12 @@ public class DishesEntity : SugarBaseEntity, ITenantId
[SugarColumn(ColumnDescription = "单价")]
public decimal Price { get; set; }
/// <summary>
/// 单位
/// </summary>
[SugarColumn(ColumnDescription = "单位", IsJson = true, DefaultValue = "[]")]
public List<string> Units { get; set; }
/// <summary>
/// 图片
/// </summary>

View File

@@ -22,7 +22,7 @@ public class DishesMenuEntity : SugarBaseEntity, ITenantId, IVersion
/// 菜单类型
/// </summary>
[SugarColumn(SqlParameterDbType = typeof(EnumToStringConvert))]
public CanteenMenuEnumType Type { get; set; }
public CanteenApplicaitonTypeEnumType Type { get; set; }
/// <summary>
/// 所属营业点

View File

@@ -3,26 +3,23 @@
namespace Dlhis.Entity.Canteen.Enums;
/// <summary>
/// 菜品类型 CanteenMenuEnumType
/// 餐饮应用类型
/// </summary>
[Description("菜品类型")]
public enum CanteenMenuEnumType
[Description("餐饮应用类型")]
public enum CanteenApplicaitonTypeEnumType
{
[Description("设备消费")]
Device = 100,
/// <summary>
/// 订餐
/// </summary>
[Description("订餐")]
Booking = 1,
Booking = 200,
/// <summary>
/// 扫码点餐
/// </summary>
[Description("扫码点餐")]
QrCode=2,
/// <summary>
/// 通用
/// </summary>
[Description("通用")]
General = 3,
QrCode = 300,
}

View File

@@ -20,6 +20,11 @@ public enum CanteenOrderStatusEnumType
[Description("成功")]
Successful = 1,
/// <summary>
/// 取消
/// </summary>
[Description("取消")]
Cancel = 95,
/// <summary>
/// 失败

View File

@@ -0,0 +1,6 @@
namespace Dlhis.Entity;
public interface IImageUrl
{
public string ImageUrl { get; set; }
}