团餐订单
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

102 lines
3.5 KiB

  1. using BPA.KitChen.GroupMealOrder.Application.BaseDto;
  2. using BPA.KitChen.GroupMealOrder.Application.Service.Order;
  3. using BPA.KitChen.GroupMealOrder.Application.Service.Order.Dtos;
  4. using BPA.KitChen.GroupMealOrder.Application.Service.ThirdAuthorize.Dtos;
  5. using BPA.KitChen.GroupMealOrder.Core.Entity;
  6. using BPA.KitChen.GroupMealOrder.SqlSugar;
  7. using Furion.DependencyInjection;
  8. using Furion.DynamicApiController;
  9. using Furion.FriendlyException;
  10. using Microsoft.AspNetCore.Hosting;
  11. using Microsoft.AspNetCore.Mvc;
  12. using SqlSugar;
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Linq;
  16. using System.Text;
  17. using System.Threading.Tasks;
  18. namespace BPA.KitChen.GroupMealOrder.Application.Service.ThirdAuthorize
  19. {
  20. [ApiDescriptionSettings("订单管理", Tag = "第三方授权", SplitCamelCase = false)]
  21. public class ThirdAuthorize : IDynamicApiController, ITransient, IThirdAuthorize
  22. {
  23. private readonly SqlSugarScope db;
  24. public ThirdAuthorize(IWebHostEnvironment hostingEnvironment)
  25. {
  26. db = SqlSugarDb.Db;
  27. }
  28. /// <summary>
  29. /// 获取第三方
  30. /// </summary>
  31. /// <param name="inputDto"></param>
  32. /// <returns></returns>
  33. [HttpPost("/api/ThirdAuthorize/Page")]
  34. public async Task<PageUtil> Page(ThirdAuthorizeInfoDto inputDto)
  35. {
  36. var total = new RefAsync<int>();
  37. var data = await db.Queryable<BPA_ShopAuthorize>()
  38. .OrderBy(a => a.CreateAt, OrderByType.Desc)
  39. .ToPageListAsync(inputDto.Current, inputDto.PageSize, total);
  40. return new PageUtil()
  41. {
  42. Data = data,
  43. Total = total
  44. };
  45. }
  46. /// <summary>
  47. /// 创建 授权
  48. /// </summary>
  49. /// <param name="inputDto"></param>
  50. /// <returns></returns>
  51. [HttpPost("/api/ThirdAuthorize/Create")]
  52. public async Task<bool> Create(BPA_ShopAuthorize inputDto)
  53. {
  54. var data=await db.Queryable<BPA_ShopAuthorize>().Where(x=>x.StoreId==inputDto.StoreId).FirstAsync();
  55. if (data != null)
  56. {
  57. throw Oops.Oh($"店铺已授权");
  58. }
  59. inputDto.AuthorizeCode=Guid.NewGuid().ToString();
  60. var res=await db.Insertable(inputDto).ExecuteCommandAsync();
  61. return res > 0;
  62. }
  63. /// <summary>
  64. /// 修改 重新赋值授权码
  65. /// </summary>
  66. /// <param name="inputDto"></param>
  67. /// <returns></returns>
  68. [HttpPost("/api/ThirdAuthorize/Update")]
  69. public async Task<bool> Update(BPA_ShopAuthorize inputDto)
  70. {
  71. var data = await db.Queryable<BPA_ShopAuthorize>().Where(x =>x.Id==inputDto.Id).FirstAsync();
  72. data.AuthorizeCode = Guid.NewGuid().ToString();
  73. var res=await db.Updateable(data).ExecuteCommandAsync();
  74. return res > 0;
  75. }
  76. /// <summary>
  77. /// 修改 重新赋值授权码
  78. /// </summary>
  79. /// <param name="inputDto"></param>
  80. /// <returns></returns>
  81. [HttpPost("/api/ThirdAuthorize/Del")]
  82. public async Task<bool> Del(string id)
  83. {
  84. var res = await SqlSugarDb.Db.Updateable<BPA_ShopAuthorize>()
  85. .SetColumns(it => new BPA_ShopAuthorize { IsDeleted = 1 })//类只能在表达示里面不能提取
  86. .Where(it => it.Id == id)
  87. .ExecuteCommandAsync();
  88. return res > 0;
  89. }
  90. }
  91. }