|
|
@@ -0,0 +1,134 @@ |
|
|
|
using BPA.KitChen.GroupMeal.Application.Service.Gate.Dtos; |
|
|
|
using BPA.KitChen.GroupMeal.Application.Service.Shop; |
|
|
|
using BPA.KitChen.GroupMeal.Application.Service.Shop.Dtos; |
|
|
|
using BPA.KitChen.GroupMeal.Core.Entity; |
|
|
|
using BPA.KitChen.GroupMeal.SqlSugar; |
|
|
|
using Furion.DependencyInjection; |
|
|
|
using Furion.DynamicApiController; |
|
|
|
using Furion.FriendlyException; |
|
|
|
using Mapster; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using SqlSugar; |
|
|
|
using StackExchange.Profiling.Internal; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
namespace BPA.KitChen.GroupMeal.Application.Service.Gate |
|
|
|
{ |
|
|
|
|
|
|
|
[ApiDescriptionSettings("一卡通", Tag = "档口管理", SplitCamelCase = false)] |
|
|
|
public class GateService: IDynamicApiController, ITransient, IGateService |
|
|
|
{ |
|
|
|
/// <summary> |
|
|
|
/// 新增 |
|
|
|
/// </summary> |
|
|
|
/// <param name="inputDto"></param> |
|
|
|
/// <returns></returns> |
|
|
|
public async Task<bool> Add(GateCreateOrUpdateDto inputDto) |
|
|
|
{ |
|
|
|
var res= await SqlSugarDb.Db.Insertable<BPA_Gate>(inputDto.Adapt<BPA_Gate>()) |
|
|
|
.ExecuteCommandAsync(); |
|
|
|
return res > 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 修改 |
|
|
|
/// </summary> |
|
|
|
/// <param name="inputDto"></param> |
|
|
|
/// <returns></returns> |
|
|
|
public async Task<bool> Update(GateCreateOrUpdateDto inputDto) |
|
|
|
{ |
|
|
|
var data = await SqlSugarDb.Db.Queryable<BPA_Gate>().FirstAsync(x => x.Id == inputDto.Id); |
|
|
|
|
|
|
|
data.Name = inputDto.Name; |
|
|
|
data.Mode = inputDto.Mode; |
|
|
|
data.Price = inputDto.Price; |
|
|
|
data.ShopId = inputDto.ShopId; |
|
|
|
data.Remaek = inputDto.Remaek; |
|
|
|
|
|
|
|
var res = await SqlSugarDb.Db.Updateable<BPA_Gate>(data) |
|
|
|
.ExecuteCommandAsync(); |
|
|
|
return res > 0; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 分页 |
|
|
|
/// </summary> |
|
|
|
/// <param name="inputDto"></param> |
|
|
|
/// <returns></returns> |
|
|
|
[HttpPost] |
|
|
|
public async Task<PageOutDto> GetPage(GatePageDto inputDto) |
|
|
|
{ |
|
|
|
var total = new RefAsync<int>(); |
|
|
|
var data = await SqlSugarDb.Db.Queryable<BPA_Gate>() |
|
|
|
.WhereIF(!string.IsNullOrEmpty(inputDto.ShopId), x => x.ShopId == inputDto.ShopId) |
|
|
|
.WhereIF(!string.IsNullOrEmpty(inputDto.Name), x => x.Name.Contains(inputDto.Name)) |
|
|
|
.WhereIF(inputDto.Mode.HasValue, x => x.Mode == inputDto.Mode) |
|
|
|
.OrderBy(a => a.CreateAt, OrderByType.Desc) |
|
|
|
.ToPageListAsync(inputDto.Current, inputDto.PageSize, total); |
|
|
|
|
|
|
|
return new PageOutDto() |
|
|
|
{ |
|
|
|
Data = data, |
|
|
|
Total = total |
|
|
|
|
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 删除 |
|
|
|
/// </summary> |
|
|
|
/// <param name="id"></param> |
|
|
|
/// <returns></returns> |
|
|
|
public async Task<bool> Del(string id) |
|
|
|
{ |
|
|
|
var data = await SqlSugarDb.Db.Queryable<BPA_Gate>().FirstAsync(x => x.Id == id); |
|
|
|
|
|
|
|
var res = await SqlSugarDb.Db.Updateable<BPA_Gate>() |
|
|
|
.SetColumns(it => new BPA_Gate { IsDelete = true })//类只能在表达示里面不能提取 |
|
|
|
.Where(it => it.Id == id) |
|
|
|
.ExecuteCommandAsync(); |
|
|
|
|
|
|
|
return res > 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 状态 |
|
|
|
/// </summary> |
|
|
|
/// <param name="inputDto"></param> |
|
|
|
/// <returns></returns> |
|
|
|
public async Task<bool> Enable(GateCreateOrUpdateDto inputDto) |
|
|
|
{ |
|
|
|
var data = await SqlSugarDb.Db.Queryable<BPA_Gate>().Where(x => inputDto.Id == x.Id).ToListAsync(); |
|
|
|
foreach (var item in data) |
|
|
|
{ |
|
|
|
item.Status = inputDto.Status; |
|
|
|
} |
|
|
|
var res = await SqlSugarDb.Db.Updateable<BPA_Gate>(data).ExecuteCommandAsync(); |
|
|
|
return res > 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 获取全部 |
|
|
|
/// </summary> |
|
|
|
/// <param name="shopId"></param> |
|
|
|
/// <returns></returns> |
|
|
|
public async Task<List<GateDto>> GetGateAllList(string shopId) |
|
|
|
{ |
|
|
|
|
|
|
|
return await SqlSugarDb.Db.Queryable<BPA_Gate>() |
|
|
|
.Select(x =>new GateDto() |
|
|
|
{ |
|
|
|
Id=x.Id.SelectAll(), |
|
|
|
} ) |
|
|
|
.ToListAsync(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |