Browse Source

获取店铺和部门接口增加临时鉴权

qianyi
shanji 3 years ago
parent
commit
84fb9956a0
  1. 6
      BBWY.Client/APIServices/ShopService.cs
  2. 8
      BBWY.Server.API/Controllers/VenderController.cs

6
BBWY.Client/APIServices/ShopService.cs

@ -44,7 +44,11 @@ namespace BBWY.Client.APIServices
/// <returns></returns> /// <returns></returns>
public ApiResponse<IList<DepartmentResponse>> GetDepartmentList() public ApiResponse<IList<DepartmentResponse>> GetDepartmentList()
{ {
return SendRequest<IList<DepartmentResponse>>(globalContext.BBYWApiHost, "api/vender/GetDeparmentList", null, null, HttpMethod.Get); return SendRequest<IList<DepartmentResponse>>(globalContext.BBYWApiHost, "api/vender/GetDeparmentList", null,
new Dictionary<string, string>()
{
{ "bbwyTempKey", "21jfhayu27q" }
}, HttpMethod.Get);
} }

8
BBWY.Server.API/Controllers/VenderController.cs

@ -1,7 +1,9 @@
using BBWY.Server.Business; using BBWY.Common.Models;
using BBWY.Server.Business;
using BBWY.Server.Model.Dto; using BBWY.Server.Model.Dto;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json; using Newtonsoft.Json;
using NLog; using NLog;
using System.Collections.Generic; using System.Collections.Generic;
@ -80,6 +82,10 @@ namespace BBWY.Server.API.Controllers
[HttpGet] [HttpGet]
public IList<DepartmentResponse> GetDeparmentList() public IList<DepartmentResponse> GetDeparmentList()
{ {
if (!Request.Headers.TryGetValue("bbwyTempKey", out StringValues sv))
throw new BusinessException("非法请求");
if (sv.ToString() != "21jfhayu27q")
throw new BusinessException("非法请求");
return venderBusiness.GetDeparmentList(); return venderBusiness.GetDeparmentList();
} }
} }

Loading…
Cancel
Save