fixed 修改商品收藏和浏览记录的接口
This commit is contained in:
parent
4a29dfea07
commit
ceb1ca4419
@ -235,6 +235,11 @@ namespace ARW.Model.Vo.Api.GoodsManager.Goodss
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public List<GoosSkuApiVo> SkuList { get; set; }
|
public List<GoosSkuApiVo> SkuList { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否收藏
|
||||||
|
/// </summary>
|
||||||
|
public bool IsCollect { get; set; } = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ using ARW.Repository.Business.LogisticsManage.DeliveryRules;
|
|||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
using ARW.Model.Models.Business.LogisticsManage.DeliveryRules;
|
using ARW.Model.Models.Business.LogisticsManage.DeliveryRules;
|
||||||
using ARW.Model.Vo.Business.GoodsManager.Goodss;
|
using ARW.Model.Vo.Business.GoodsManager.Goodss;
|
||||||
|
using ARW.Service.Business.IBusinessService.Custom.GoodsCollections;
|
||||||
|
|
||||||
namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss
|
namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss
|
||||||
{
|
{
|
||||||
@ -50,9 +51,10 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss
|
|||||||
private readonly DeliveryRepository _DeliveryRepository;
|
private readonly DeliveryRepository _DeliveryRepository;
|
||||||
private readonly DeliveryRuleRepository _DeliveryRuleRepository;
|
private readonly DeliveryRuleRepository _DeliveryRuleRepository;
|
||||||
private readonly CustomerAddressRepository _CustomerAddressRepository;
|
private readonly CustomerAddressRepository _CustomerAddressRepository;
|
||||||
|
private readonly IGoodsCollectionService _GoodsCollectionService;
|
||||||
|
|
||||||
|
|
||||||
public GoodsServiceImplApi(GoodsRepository GoodsRepository, GoodsSpecRelRepository goodsSpecRelRepository, SpecRepository specRepository, SpecValueRepository specValueRepository, GoodsSkuRepository goodsSkuRepository, GoodsCategoryRepository goodsCategoryRepository, DeliveryRepository deliveryRepository, CustomerAddressRepository customerAddressRepository, DeliveryRuleRepository deliveryRuleRepository)
|
public GoodsServiceImplApi(GoodsRepository GoodsRepository, GoodsSpecRelRepository goodsSpecRelRepository, SpecRepository specRepository, SpecValueRepository specValueRepository, GoodsSkuRepository goodsSkuRepository, GoodsCategoryRepository goodsCategoryRepository, DeliveryRepository deliveryRepository, CustomerAddressRepository customerAddressRepository, DeliveryRuleRepository deliveryRuleRepository, IGoodsCollectionService goodsCollectionService)
|
||||||
{
|
{
|
||||||
this._GoodsRepository = GoodsRepository;
|
this._GoodsRepository = GoodsRepository;
|
||||||
_GoodsSpecRelRepository = goodsSpecRelRepository;
|
_GoodsSpecRelRepository = goodsSpecRelRepository;
|
||||||
@ -63,6 +65,7 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss
|
|||||||
_DeliveryRepository = deliveryRepository;
|
_DeliveryRepository = deliveryRepository;
|
||||||
_CustomerAddressRepository = customerAddressRepository;
|
_CustomerAddressRepository = customerAddressRepository;
|
||||||
_DeliveryRuleRepository = deliveryRuleRepository;
|
_DeliveryRuleRepository = deliveryRuleRepository;
|
||||||
|
_GoodsCollectionService = goodsCollectionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Api接口代码
|
#region Api接口代码
|
||||||
@ -254,7 +257,7 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parm"></param>
|
/// <param name="parm"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<string> GetGoodsDetails(GoodsDtoApi parm)
|
public async Task<string> GetGoodsDetails(GoodsDtoApi parm, long userId)
|
||||||
{
|
{
|
||||||
|
|
||||||
var query = _GoodsRepository
|
var query = _GoodsRepository
|
||||||
@ -287,7 +290,7 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss
|
|||||||
|
|
||||||
|
|
||||||
var json = await query.ToJsonAsync();
|
var json = await query.ToJsonAsync();
|
||||||
var data = await GetSpecList(json);
|
var data = await GetSpecList(json, userId);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +300,7 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="json"></param>
|
/// <param name="json"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<string> GetSpecList(string json)
|
public async Task<string> GetSpecList(string json, long userId)
|
||||||
{
|
{
|
||||||
if (json != "[]")
|
if (json != "[]")
|
||||||
{
|
{
|
||||||
@ -339,6 +342,13 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss
|
|||||||
data.SkuList = await GetSkuListWithSpecValuesAsync(skuList);
|
data.SkuList = await GetSkuListWithSpecValuesAsync(skuList);
|
||||||
|
|
||||||
data.SpecList = goodsSpecListVo;
|
data.SpecList = goodsSpecListVo;
|
||||||
|
|
||||||
|
if (userId != 0)
|
||||||
|
{
|
||||||
|
var isCollect = await _GoodsCollectionService.IsAnyAsync(s => s.CustomerGuid == userId && s.GoodsGuid == data.SpuId);
|
||||||
|
data.IsCollect = isCollect;
|
||||||
|
}
|
||||||
|
|
||||||
json = data.ToJson();
|
json = data.ToJson();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ namespace ARW.Service.Api.IBusinessService.GoodsManager.Goodss
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parm"></param>
|
/// <param name="parm"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<string> GetGoodsDetails(GoodsDtoApi parm);
|
Task<string> GetGoodsDetails(GoodsDtoApi parm,long userId);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,13 +85,14 @@ namespace ARW.WebApi.Controllers.Api.Custom.GoodsCollections
|
|||||||
/// 删除商品收藏
|
/// 删除商品收藏
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpDelete("{ids}")]
|
[HttpPost("CancelGoodsCollection")]
|
||||||
[Log(Title = "商品收藏删除", BusinessType = BusinessType.DELETE)]
|
[Log(Title = "商品收藏删除", BusinessType = BusinessType.DELETE)]
|
||||||
public IActionResult Delete(string ids)
|
public async Task<IActionResult> CancelGoodsCollection([FromBody] GoodsCollectionDto parm)
|
||||||
{
|
{
|
||||||
long[] idsArr = Tools.SpitLongArrary(ids);
|
var user = JwtUtil.GetLoginUser(App.HttpContext);
|
||||||
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
|
//long[] idsArr = Tools.SpitLongArrary(ids);
|
||||||
var response = _GoodsCollectionServiceApi.Delete(idsArr);
|
//if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
|
||||||
|
var response = await _GoodsCollectionServiceApi.DeleteAsync(s => s.GoodsGuid == parm.GoodsGuid && s.CustomerGuid == user.UserId);
|
||||||
return SUCCESS("删除成功!");
|
return SUCCESS("删除成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ using ARW.Model.Vo.Api.GoodsManager.Goodss;
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Geocoding;
|
using Geocoding;
|
||||||
using ARW.Service.Api.IBusinessService.GoodsManager.GoodsCategorys;
|
using ARW.Service.Api.IBusinessService.GoodsManager.GoodsCategorys;
|
||||||
|
using ARW.Admin.WebApi.Framework;
|
||||||
|
|
||||||
namespace ARW.WebApi.Controllers.Api.GoodsManager.Goodss
|
namespace ARW.WebApi.Controllers.Api.GoodsManager.Goodss
|
||||||
{
|
{
|
||||||
@ -76,8 +77,9 @@ namespace ARW.WebApi.Controllers.Api.GoodsManager.Goodss
|
|||||||
public async Task<IActionResult> GetGoodsDetails([FromQuery] GoodsDtoApi parm)
|
public async Task<IActionResult> GetGoodsDetails([FromQuery] GoodsDtoApi parm)
|
||||||
{
|
{
|
||||||
//if (parm == null) throw new CustomException("参数错误!");
|
//if (parm == null) throw new CustomException("参数错误!");
|
||||||
|
var user = JwtUtil.GetLoginUser(App.HttpContext);
|
||||||
|
|
||||||
var res = await _GoodsServiceApi.GetGoodsDetails(parm);
|
var res = await _GoodsServiceApi.GetGoodsDetails(parm, user.UserId);
|
||||||
|
|
||||||
if (res != "[]")
|
if (res != "[]")
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user