@@ -0,0 +1,92 @@ | |||
using BPA.KitChen.GroupMeal.Application.BaseDto; | |||
using BPA.KitChen.GroupMeal.Application.Service.OneCard.DiningPlate.Dtos; | |||
using BPA.KitChen.GroupMeal.Application.Service.OneCard.DiningPlate.Service; | |||
using BPA.KitChen.GroupMeal.Core.Entity; | |||
using BPA.KitChen.GroupMeal.Core.Enum; | |||
using BPA.KitChen.GroupMeal.SqlSugar; | |||
using Furion.DatabaseAccessor; | |||
using Furion.DynamicApiController; | |||
using Furion.FriendlyException; | |||
using Microsoft.AspNetCore.Components.Forms; | |||
using Microsoft.AspNetCore.Mvc; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.GroupMeal.Application.Service.OneCard.DiningPlate | |||
{ | |||
[ApiDescriptionSettings("餐盘管理", Tag = "餐盘管理")] | |||
public class DiningPlateServices: IDynamicApiController | |||
{ | |||
private readonly IDiningPlateService _diningPlateService; | |||
public DiningPlateServices(IDiningPlateService diningPlateService) | |||
{ | |||
_diningPlateService = diningPlateService; | |||
} | |||
/// <summary> | |||
/// 分页查询 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/DiningPlate/Page")] | |||
public async Task<PageUtil> Page(DiningPlatePageIndexDto inputDto) | |||
{ | |||
return await _diningPlateService.Page(inputDto); | |||
} | |||
/// <summary> | |||
/// 新增餐盘 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/DiningPlate/Add")] | |||
public async Task<bool> Add(DiningPlateCreateOrUpdataDto inputDto) | |||
{ | |||
return await _diningPlateService.Add(inputDto); | |||
} | |||
/// <summary> | |||
/// 修改餐盘 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/DiningPlate/Update")] | |||
public async Task<bool> Update(DiningPlateCreateOrUpdataDto inputDto) | |||
{ | |||
return await _diningPlateService.Update(inputDto); | |||
} | |||
/// <summary> | |||
/// 启用警用 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/DiningPlate/EnableDisable")] | |||
public async Task<bool> EnableDisable(DiningPlateCreateOrUpdataDto inputDto) | |||
{ | |||
return await _diningPlateService.EnableDisable(inputDto); | |||
} | |||
/// <summary> | |||
/// 删除 | |||
/// </summary> | |||
/// <param name="id"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/DiningPlate/Del")] | |||
public async Task<bool> Del(string id) | |||
{ | |||
return await _diningPlateService.Del(id); | |||
} | |||
} | |||
} |
@@ -0,0 +1,59 @@ | |||
using BPA.KitChen.GroupMeal.Application.BaseDto; | |||
using BPA.KitChen.GroupMeal.Core.Entity; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.GroupMeal.Application.Service.OneCard.DiningPlate.Dtos | |||
{ | |||
public class DiningPlateDto : BPA_DiningPlate | |||
{ | |||
/// <summary> | |||
/// 是否占用 | |||
/// </summary> | |||
public bool IsOccupy { get; set; } | |||
} | |||
public class DiningPlateCreateOrUpdataDto: BPA_DiningPlate | |||
{ | |||
/// <summary> | |||
/// 二维码 | |||
/// </summary> | |||
public string QRCode { get; set; } | |||
/// <summary> | |||
/// 芯片码 | |||
/// </summary> | |||
public string ChipCode { get; set; } | |||
/// <summary> | |||
/// 是否占用 | |||
/// </summary> | |||
public bool IsOccupy { get; set; } | |||
} | |||
public class DiningPlatePageIndexDto: PageInputBase | |||
{ | |||
/// <summary> | |||
/// 二维码 | |||
/// </summary> | |||
public string QRCode { get; set; } | |||
/// <summary> | |||
/// 芯片码 | |||
/// </summary> | |||
public string ChipCode { get; set; } | |||
/// <summary> | |||
/// 是否占用 | |||
/// </summary> | |||
public bool? IsOccupy { get; set; } | |||
} | |||
} |
@@ -0,0 +1,155 @@ | |||
using BPA.KitChen.GroupMeal.Application.Service.OneCard.DiningPlate.Dtos; | |||
using BPA.KitChen.GroupMeal.Core.Entity; | |||
using BPA.KitChen.GroupMeal.Core.Enum; | |||
using BPA.KitChen.GroupMeal.SqlSugar; | |||
using Furion.DependencyInjection; | |||
using Furion.FriendlyException; | |||
using MQTTnet.Client; | |||
using NPOI.POIFS.Crypt.Dsig; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.KitChen.GroupMeal.Application.BaseDto; | |||
using BPA.KitChen.GroupMeal.Application.Service.OneCard.Member.MemberInfo.Dtos.MemberTag; | |||
using Microsoft.AspNetCore.Components.Forms; | |||
using MathNet.Numerics.Distributions; | |||
namespace BPA.KitChen.GroupMeal.Application.Service.OneCard.DiningPlate.Service | |||
{ | |||
public class DiningPlateService:ITransient, IDiningPlateService | |||
{ | |||
private readonly SqlSugarScope db; | |||
public DiningPlateService() | |||
{ | |||
db = SqlSugarDb.Db; | |||
} | |||
/// <summary> | |||
/// 分页查询 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
public async Task<PageUtil> Page(DiningPlatePageIndexDto inputDto) | |||
{ | |||
int total = new RefAsync<int>(); | |||
var res = db.Queryable<BPA_DiningPlate>() | |||
.Where(a => a.IsDeleted == 0) | |||
.WhereIF(!string.IsNullOrEmpty(inputDto.QRCode),x=>x.QRCode==inputDto.QRCode) | |||
.WhereIF(!string.IsNullOrEmpty(inputDto.ChipCode), x => x.ChipCode == inputDto.ChipCode) | |||
.OrderBy(x => x.CreateAt, OrderByType.Desc) | |||
.Select(t => new DiningPlateDto | |||
{ | |||
Id = t.Id.SelectAll() | |||
}).ToPageList(inputDto.Current, inputDto.PageSize, ref total); | |||
return new PageUtil() | |||
{ | |||
Data = res, | |||
Total = total | |||
}; | |||
} | |||
/// <summary> | |||
/// 新增餐盘 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
public async Task<bool> Add(DiningPlateCreateOrUpdataDto inputDto) | |||
{ | |||
// | |||
var data = await db.Queryable<BPA_DiningPlate>() | |||
.FirstAsync(x => inputDto.QRCode == x.QRCode || inputDto.ChipCode == x.ChipCode); | |||
if (data!=null) | |||
{ | |||
throw Oops.Oh($"二维码或芯片码已存在"); | |||
} | |||
data = new BPA_DiningPlate() | |||
{ | |||
ChipCode = inputDto.ChipCode, | |||
QRCode = inputDto.QRCode, | |||
Status = CommonStatus.ENABLE, | |||
}; | |||
var res=await db.Insertable(data).ExecuteCommandAsync(); | |||
return res > 0; | |||
} | |||
/// <summary> | |||
/// 修改餐盘 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
public async Task<bool> Update(DiningPlateCreateOrUpdataDto inputDto) | |||
{ | |||
var data1 = await db.Queryable<BPA_DiningPlate>() | |||
.FirstAsync(x => inputDto.QRCode == x.QRCode || inputDto.ChipCode == x.ChipCode); | |||
var data2 = await db.Queryable<BPA_DiningPlate>() | |||
.FirstAsync(x =>x.Id==inputDto.Id); | |||
if (data2==null) | |||
{ | |||
throw Oops.Oh($"操作数据不存在"); | |||
} | |||
else | |||
{ | |||
if (data1!=null&& data1.Id!=data2.Id) | |||
{ | |||
throw Oops.Oh($"二维码或芯片码已存在"); | |||
} | |||
} | |||
data2.ChipCode = inputDto.ChipCode; | |||
data2.QRCode = inputDto.QRCode; | |||
var res = await db.Updateable(data2).ExecuteCommandAsync(); | |||
return res > 0; | |||
} | |||
/// <summary> | |||
/// 启用警用 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
public async Task<bool> EnableDisable(DiningPlateCreateOrUpdataDto inputDto) | |||
{ | |||
var data = await db.Queryable<BPA_DiningPlate>() | |||
.FirstAsync(x => x.Id == inputDto.Id); | |||
if (data == null) | |||
{ | |||
throw Oops.Oh($"操作数据不存在"); | |||
} | |||
data.Status = data.Status== CommonStatus.DISABLE? CommonStatus.ENABLE: CommonStatus.DISABLE; | |||
var res = await db.Updateable(data).ExecuteCommandAsync(); | |||
return res > 0; | |||
} | |||
/// <summary> | |||
/// 删除 | |||
/// </summary> | |||
/// <param name="id"></param> | |||
/// <returns></returns> | |||
public async Task<bool> Del(string id) | |||
{ | |||
var data = await db.Queryable<BPA_DiningPlate>() | |||
.FirstAsync(x => x.Id == id); | |||
if (data == null) | |||
{ | |||
throw Oops.Oh($"操作数据不存在"); | |||
} | |||
var res =await db.Deleteable<BPA_DiningPlate>(data).ExecuteCommandAsync(); | |||
return res > 0; | |||
} | |||
} | |||
} |
@@ -0,0 +1,58 @@ | |||
using BPA.KitChen.GroupMeal.Application.BaseDto; | |||
using BPA.KitChen.GroupMeal.Application.Service.OneCard.DiningPlate.Dtos; | |||
using BPA.KitChen.GroupMeal.Core.Entity; | |||
using BPA.KitChen.GroupMeal.Core.Enum; | |||
using Furion.DatabaseAccessor; | |||
using Furion.FriendlyException; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.GroupMeal.Application.Service.OneCard.DiningPlate.Service | |||
{ | |||
public interface IDiningPlateService | |||
{ | |||
/// <summary> | |||
/// 分页查询 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
Task<PageUtil> Page(DiningPlatePageIndexDto inputDto); | |||
/// <summary> | |||
/// 新增餐盘 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
Task<bool> Add(DiningPlateCreateOrUpdataDto inputDto); | |||
/// <summary> | |||
/// 修改餐盘 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
Task<bool> Update(DiningPlateCreateOrUpdataDto inputDto); | |||
/// <summary> | |||
/// 启用警用 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
Task<bool> EnableDisable(DiningPlateCreateOrUpdataDto inputDto); | |||
/// <summary> | |||
/// 删除 | |||
/// </summary> | |||
/// <param name="id"></param> | |||
/// <returns></returns> | |||
Task<bool> Del(string id); | |||
} | |||
} |
@@ -0,0 +1,31 @@ | |||
using BPA.KitChen.GroupMeal.Core.Entity.Base; | |||
using BPA.KitChen.GroupMeal.Core.Enum; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.GroupMeal.Core.Entity | |||
{ | |||
/// <summary> | |||
/// 餐盘 | |||
/// </summary> | |||
[SugarTable("bpa_diningplate")] | |||
public class BPA_DiningPlate: IBaseGroupIdEntity | |||
{ | |||
/// <summary> | |||
/// 二维码 | |||
/// </summary> | |||
public string QRCode { get; set; } | |||
/// <summary> | |||
/// 芯片码 | |||
/// </summary> | |||
public string ChipCode { get; set; } | |||
} | |||
} |