Browse Source

新增产品接口

GOIAggregation
sanji 2 years ago
parent
commit
83fcd4aa3a
  1. 24
      SiNan.API/Controllers/ProductController.cs
  2. 32
      SiNan.Business/ProductBusiness.cs
  3. 15
      SiNan.Model/Dto/PlatformRequest.cs
  4. 19
      SiNan.Model/Dto/Request/Product/SearchProductRequest.cs
  5. 30
      SiNan.Model/Dto/Request/Product/SearchProductSkuRequest.cs
  6. 9
      SiNan.Model/Dto/Response/Product/ProductListResponse.cs

24
SiNan.API/Controllers/ProductController.cs

@ -18,9 +18,31 @@ namespace SiNan.API.Controllers
/// </summary>
/// <param name="request"></param>
[HttpPost]
public void SetMaxDeficitThreshold([FromBody]SetMaxDeficitThresholdRequest request)
public void SetMaxDeficitThreshold([FromBody] SetMaxDeficitThresholdRequest request)
{
productBusiness.SetMaxDeficitThreshold(request);
}
/// <summary>
/// 获取产品列表
/// </summary>
/// <param name="searchProductRequest"></param>
/// <returns></returns>
[HttpPost]
public ProductListResponse GetProductList([FromBody] SearchProductRequest searchProductRequest)
{
return productBusiness.GetProductList(searchProductRequest);
}
/// <summary>
/// 获取sku列表
/// </summary>
/// <param name="searchProductSkuRequest"></param>
/// <returns></returns>
[HttpPost]
public IList<ProductSkuResponse> GetProductSkuList([FromBody] SearchProductSkuRequest searchProductSkuRequest)
{
return productBusiness.GetProductSkuList(searchProductSkuRequest);
}
}
}

32
SiNan.Business/ProductBusiness.cs

@ -1,4 +1,6 @@
using SiNan.Common.Log;
using Newtonsoft.Json;
using SiNan.Common.Http;
using SiNan.Common.Log;
using SiNan.Common.Models;
using SiNan.Model.Db;
using SiNan.Model.Dto;
@ -8,9 +10,10 @@ namespace SiNan.Business
{
public class ProductBusiness : BaseBusiness, IDenpendency
{
public ProductBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator) : base(fsql, nLogManager, idGenerator)
private RestApiService restApiService;
public ProductBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, RestApiService restApiService) : base(fsql, nLogManager, idGenerator)
{
this.restApiService = restApiService;
}
public void SetMaxDeficitThreshold(SetMaxDeficitThresholdRequest request)
@ -31,5 +34,28 @@ namespace SiNan.Business
fsql.Update<ProductSku>(request.Sku).Set(p => p.MaxDeficitThreshold, spuMaxDeficitThreshold).ExecuteAffrows();
});
}
public ProductListResponse GetProductList(SearchProductRequest searchProductRequest)
{
var sendResult = restApiService.SendRequest("http://bbwytest.qiyue666.com", "api/product/GetProductList", searchProductRequest, null, HttpMethod.Post);
if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
var response = JsonConvert.DeserializeObject<ApiResponse<ProductListResponse>>(sendResult.Content);
if (!response.Success)
throw new BusinessException(response.Msg) { Code = response.Code };
return response.Data;
}
public IList<ProductSkuResponse> GetProductSkuList(SearchProductSkuRequest searchProductSkuRequest)
{
var sendResult = restApiService.SendRequest("http://bbwytest.qiyue666.com", "api/product/GetProductSkuList", searchProductSkuRequest, null, HttpMethod.Post);
if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
var response = JsonConvert.DeserializeObject<ApiResponse<IList<ProductSkuResponse>>>(sendResult.Content);
if (!response.Success)
throw new BusinessException(response.Msg) { Code = response.Code };
return response.Data;
}
}
}

15
SiNan.Model/Dto/PlatformRequest.cs

@ -0,0 +1,15 @@
namespace SiNan.Model.Dto
{
public class PlatformRequest
{
public Enums.Platform Platform { get; set; }
public string AppKey { get; set; }
public string AppSecret { get; set; }
public string AppToken { get; set; }
public bool SaveResponseLog { get; set; }
}
}

19
SiNan.Model/Dto/Request/Product/SearchProductRequest.cs

@ -0,0 +1,19 @@
namespace SiNan.Model.Dto
{
public class SearchProductRequest : PlatformRequest
{
public string Spu { get; set; }
/// <summary>
/// 货号
/// </summary>
public string ProductItem { get; set; }
public string ProductName { get; set; }
public int PageIndex { get; set; }
public int PageSize { get; set; }
}
}

30
SiNan.Model/Dto/Request/Product/SearchProductSkuRequest.cs

@ -0,0 +1,30 @@
namespace SiNan.Model.Dto
{
public class SearchProductSkuRequest : PlatformRequest
{
/// <summary>
/// 当Spu有值时会忽略Sku
/// </summary>
public string Spu { get; set; }
/// <summary>
/// 多个Sku逗号间隔
/// </summary>
public string Sku { get; set; }
/// <summary>
/// 是否包含源
/// </summary>
public bool IsContainSource { get; set; }
/// <summary>
/// 检查sku数量是否匹配,仅在使用sku条件查询时生效
/// </summary>
public bool IsCheckSkuCount { get; set; }
/// <summary>
/// 检查环节
/// </summary>
public string CheckStep { get; set; }
}
}

9
SiNan.Model/Dto/Response/Product/ProductListResponse.cs

@ -0,0 +1,9 @@
namespace SiNan.Model.Dto
{
public class ProductListResponse
{
public int Count { get; set; }
public IList<ProductResponse> Items { get; set; }
}
}
Loading…
Cancel
Save