增加Shop API
This commit is contained in:
1 parent
3769193696
commit
5d017740c6
83 files changed
+4451
-696
No files matched your search
@@ -0,0 +1,33 @@
|
||||
using System.Text.Json;
|
||||
using MAX.Framework.Commons;
|
||||
using MAX.Framework.Validation;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Store.Shops.Dtos;
|
||||
using Store.Shops.Entities;
|
||||
|
||||
namespace Store.Shops.Services;
|
||||
|
||||
public sealed partial class ShopManagementService
|
||||
{
|
||||
public async Task<IReadOnlyList<PddClientInfo>> GetPddClients()
|
||||
{
|
||||
await Actor();
|
||||
var clients = configuration.GetSection("Shops:PddClients").Get<List<PddClientInfo>>() ?? [];
|
||||
if (clients.Count == 0 || clients.Any(c => string.IsNullOrWhiteSpace(c.ClientId)
|
||||
|| string.IsNullOrWhiteSpace(c.ClientSecret) || string.IsNullOrWhiteSpace(c.RedirectUri)))
|
||||
throw new AppException("尚未完整配置拼多多应用信息");
|
||||
return clients;
|
||||
}
|
||||
|
||||
public async Task<JsonElement> GetPddToken(PddTokenRequest request, CancellationToken ct = default)
|
||||
{
|
||||
RequestValidator.Validate(request);
|
||||
var actor = await Actor();
|
||||
var name = actor.UserName;
|
||||
var member = "," + name + ",";
|
||||
if (!await db.Select<PddShopEntity>().Where(s => s.MallId == request.MallId
|
||||
&& (s.UserName == name || ("," + s.SubUserName + ",").Contains(member))).AnyAsync(ct))
|
||||
throw new AppException("店铺不存在或无读取令牌权限");
|
||||
return await e57.GetToken(request.MallId, ct);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user