|
- using BPA.KitChen.GroupMealOrder.Application.BaseDto;
- using BPA.KitChen.GroupMealOrder.Application.Service.Order;
- using BPA.KitChen.GroupMealOrder.Application.Service.Order.Dtos;
- using BPA.KitChen.GroupMealOrder.Application.Service.ThirdAuthorize.Dtos;
- using BPA.KitChen.GroupMealOrder.Core.Entity;
- using BPA.KitChen.GroupMealOrder.SqlSugar;
- using Furion.DependencyInjection;
- using Furion.DynamicApiController;
- using Furion.FriendlyException;
- using Microsoft.AspNetCore.Hosting;
- 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.GroupMealOrder.Application.Service.ThirdAuthorize
- {
-
- [ApiDescriptionSettings("订单管理", Tag = "第三方授权", SplitCamelCase = false)]
- public class ThirdAuthorize : IDynamicApiController, ITransient, IThirdAuthorize
- {
- private readonly SqlSugarScope db;
-
- public ThirdAuthorize(IWebHostEnvironment hostingEnvironment)
- {
- db = SqlSugarDb.Db;
- }
-
- /// <summary>
- /// 获取第三方
- /// </summary>
- /// <param name="inputDto"></param>
- /// <returns></returns>
- [HttpPost("/api/ThirdAuthorize/Page")]
- public async Task<PageUtil> Page(ThirdAuthorizeInfoDto inputDto)
- {
- var total = new RefAsync<int>();
- var data = await db.Queryable<BPA_ShopAuthorize>()
- .OrderBy(a => a.CreateAt, OrderByType.Desc)
- .ToPageListAsync(inputDto.Current, inputDto.PageSize, total);
-
- return new PageUtil()
- {
- Data = data,
- Total = total
-
- };
- }
-
-
- /// <summary>
- /// 创建 授权
- /// </summary>
- /// <param name="inputDto"></param>
- /// <returns></returns>
- [HttpPost("/api/ThirdAuthorize/Create")]
- public async Task<bool> Create(BPA_ShopAuthorize inputDto)
- {
- var data=await db.Queryable<BPA_ShopAuthorize>().Where(x=>x.StoreId==inputDto.StoreId).FirstAsync();
- if (data != null)
- {
- throw Oops.Oh($"店铺已授权");
- }
- inputDto.AuthorizeCode=Guid.NewGuid().ToString();
- var res=await db.Insertable(inputDto).ExecuteCommandAsync();
- return res > 0;
- }
-
- /// <summary>
- /// 修改 重新赋值授权码
- /// </summary>
- /// <param name="inputDto"></param>
- /// <returns></returns>
- [HttpPost("/api/ThirdAuthorize/Update")]
- public async Task<bool> Update(BPA_ShopAuthorize inputDto)
- {
- var data = await db.Queryable<BPA_ShopAuthorize>().Where(x =>x.Id==inputDto.Id).FirstAsync();
- data.AuthorizeCode = Guid.NewGuid().ToString();
- var res=await db.Updateable(data).ExecuteCommandAsync();
- return res > 0;
- }
-
- /// <summary>
- /// 修改 重新赋值授权码
- /// </summary>
- /// <param name="inputDto"></param>
- /// <returns></returns>
- [HttpPost("/api/ThirdAuthorize/Del")]
- public async Task<bool> Del(string id)
- {
- var res = await SqlSugarDb.Db.Updateable<BPA_ShopAuthorize>()
- .SetColumns(it => new BPA_ShopAuthorize { IsDeleted = 1 })//类只能在表达示里面不能提取
- .Where(it => it.Id == id)
- .ExecuteCommandAsync();
- return res > 0;
- }
- }
- }
|