feat 添加店铺商品类目接口
This commit is contained in:
parent
65d7c2461a
commit
d1a61f866c
@ -24,7 +24,7 @@ namespace ARW.Model.Dto.Api.GoodsManager.Goodss
|
||||
/// <summary>
|
||||
/// 店铺商品类目
|
||||
/// </summary>
|
||||
public long? ShopGoodsCategoryGuid { get; set; }
|
||||
public long ShopGoodsCategoryGuid { get; set; }
|
||||
public string GoodsName { get; set; }
|
||||
public string GoodsCoding { get; set; }
|
||||
public int GoodsSort { get; set; }
|
||||
|
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using ARW.Model.Models.Business.GoodsManager.ShopGoodsCategorys;
|
||||
|
||||
namespace ARW.Model.Dto.Api.GoodsManager.ShopGoodsCategorys
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 店铺商品类目查询对象Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-07-20
|
||||
/// </summary>
|
||||
public class ShopGoodsCategoryQueryDtoApi : PagerInfo
|
||||
{
|
||||
[Required(ErrorMessage = "ShopGuid不能为空")]
|
||||
public long ShopGuid { get; set; }
|
||||
public string ShopGoodsCategoryName { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -72,6 +72,9 @@ namespace ARW.Model.Vo.Api.GoodsManager.Goodss
|
||||
/// </summary>
|
||||
public string Images { get; set; }
|
||||
|
||||
public string Thumb { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :价格(最低)
|
||||
|
@ -0,0 +1,54 @@
|
||||
using Newtonsoft.Json;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using ARW.Model.Models.Business.GoodsManager.ShopGoodsCategorys;
|
||||
using System.Collections.Generic;
|
||||
using ARW.Model.Vo.Api.GoodsManager.Goodss;
|
||||
|
||||
namespace ARW.Model.Vo.Api.GoodsManager.ShopGoodsCategorys
|
||||
{
|
||||
/// <summary>
|
||||
/// 店铺商品类目展示对象Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-07-20
|
||||
/// </summary>
|
||||
public class ShopGoodsCategoryVoApi
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(IsTreeKey = true)]
|
||||
[EpplusIgnore]
|
||||
public long ShopGoodsCategoryGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :父级guid
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(IsTreeKey = true)]
|
||||
[EpplusTableColumn(Header = "父级guid")]
|
||||
public long ShopGoodsCategoryParentGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :名称
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "名称")]
|
||||
public string Label { get; set; }
|
||||
|
||||
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public List<GoodsVoApi> Items { get; set; }
|
||||
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public List<ShopGoodsCategoryVoApi> Children { get; set; }
|
||||
}
|
||||
|
||||
}
|
@ -79,7 +79,7 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss
|
||||
//}
|
||||
|
||||
predicate = predicate.AndIF(parm.ShopGuid != null, s => s.ShopGuid == parm.ShopGuid);
|
||||
predicate = predicate.AndIF(parm.ShopGoodsCategoryGuid != null, s => s.ShopGoodsCategoryGuid == parm.ShopGoodsCategoryGuid);
|
||||
predicate = predicate.AndIF(parm.ShopGoodsCategoryGuid != 0, s => s.ShopGoodsCategoryGuid == parm.ShopGoodsCategoryGuid);
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.GoodsName), s => s.GoodsName.Contains(parm.GoodsName));
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.GoodsCoding), s => s.GoodsCoding.Contains(parm.GoodsCoding));
|
||||
predicate = predicate.AndIF(parm.MinPrice != 0, s => s.GoodsPriceLowest >= parm.MinPrice);
|
||||
@ -121,6 +121,54 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss
|
||||
return await query.ToPageAsync(parm);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询商品列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<GoodsVoApi>> GetGoodsApi(GoodsQueryDtoApi parm)
|
||||
{
|
||||
//开始拼装查询条件
|
||||
var predicate = Expressionable.Create<Goods>();
|
||||
|
||||
predicate = predicate.AndIF(parm.ShopGoodsCategoryGuid != 0, s => s.ShopGoodsCategoryGuid == parm.ShopGoodsCategoryGuid);
|
||||
|
||||
var query = _GoodsRepository
|
||||
.Queryable()
|
||||
.LeftJoin<Shop>((s, c) => s.ShopGuid == c.ShopGuid)
|
||||
.Where(predicate.ToExpression())
|
||||
.Where(s => s.GoodsShelfStatus == 1)
|
||||
.OrderBy(s => s.GoodsSort, OrderByType.Asc)
|
||||
.Select((s, c) => new GoodsVoApi
|
||||
{
|
||||
SpuId = s.GoodsGuid,
|
||||
ShopGuid = s.ShopGuid,
|
||||
ShopName = c.ShopName,
|
||||
CategoryIds = s.ShopGoodsCategoryGuid,
|
||||
Title = s.GoodsName,
|
||||
GoodsCoding = s.GoodsCoding,
|
||||
Video = s.GoodsMainImageVideo,
|
||||
PrimaryImage = s.GoodsVideoCover,
|
||||
Images = s.GoodsPicture,
|
||||
Price = s.GoodsPriceLowest,
|
||||
OriginPrice = s.GoodsDashedPriceLowest,
|
||||
SpuStockQuantity = s.GoodsTotalInventory,
|
||||
SoldNum = s.GoodsSalesInitial + s.GoodsSalesActual,
|
||||
IsPutOnSale = s.GoodsShelfStatus,
|
||||
});
|
||||
|
||||
|
||||
var list = await query.ToListAsync();
|
||||
|
||||
foreach (var item in list)
|
||||
{
|
||||
item.Thumb = item.Images.Split(',').First();
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询商品详情(Api)
|
||||
/// </summary>
|
||||
|
@ -0,0 +1,96 @@
|
||||
using Infrastructure.Attribute;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ARW.Model;
|
||||
using ARW.Repository;
|
||||
using ARW.Repository.Business.GoodsManager.ShopGoodsCategorys;
|
||||
using ARW.Service.Api.IBusinessService.GoodsManager.ShopGoodsCategorys;
|
||||
using ARW.Model.Dto.Api.GoodsManager.ShopGoodsCategorys;
|
||||
using ARW.Model.Models.Business.GoodsManager.ShopGoodsCategorys;
|
||||
using ARW.Model.Vo.Api.GoodsManager.ShopGoodsCategorys;
|
||||
using Senparc.CO2NET.Extensions;
|
||||
using ARW.Service.Api.IBusinessService.GoodsManager.Goodss;
|
||||
using ARW.Model.Dto.Api.GoodsManager.Goodss;
|
||||
|
||||
namespace ARW.Service.Api.BusinessService.GoodsManager.ShopGoodsCategorys
|
||||
{
|
||||
/// <summary>
|
||||
/// 店铺商品类目接口实现类Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-07-20
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IShopGoodsCategoryServiceApi), ServiceLifetime = LifeTime.Transient)]
|
||||
public class ShopGoodsCategoryServiceImplApi : BaseService<ShopGoodsCategory>, IShopGoodsCategoryServiceApi
|
||||
{
|
||||
private readonly IGoodsServiceApi _GoodsServiceApi;
|
||||
|
||||
private readonly ShopGoodsCategoryRepository _ShopGoodsCategoryRepository;
|
||||
|
||||
public ShopGoodsCategoryServiceImplApi(ShopGoodsCategoryRepository ShopGoodsCategoryRepository, IGoodsServiceApi goodsServiceApi)
|
||||
{
|
||||
this._ShopGoodsCategoryRepository = ShopGoodsCategoryRepository;
|
||||
_GoodsServiceApi = goodsServiceApi;
|
||||
}
|
||||
|
||||
#region Api接口代码
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询店铺商品类目树形列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ShopGoodsCategoryVoApi>> GetShopGoodsCategoryTreeListApi(ShopGoodsCategoryQueryDtoApi parm)
|
||||
{
|
||||
//开始拼装查询条件
|
||||
var predicate = Expressionable.Create<ShopGoodsCategory>();
|
||||
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.ShopGoodsCategoryName), s => s.ShopGoodsCategoryName.Contains(parm.ShopGoodsCategoryName));
|
||||
var query = _ShopGoodsCategoryRepository
|
||||
.Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.Where((s) => s.ShopGoodsCategoryDisplayStatus == 1)
|
||||
.Where((s) => s.ShopGuid == parm.ShopGuid)
|
||||
.OrderBy(s => s.ShopGoodsCategorySort, OrderByType.Asc)
|
||||
.Select((s) => new ShopGoodsCategoryVoApi
|
||||
{
|
||||
ShopGoodsCategoryGuid = s.ShopGoodsCategoryGuid,
|
||||
ShopGoodsCategoryParentGuid = s.ShopGoodsCategoryParentGuid,
|
||||
Label = s.ShopGoodsCategoryName,
|
||||
});
|
||||
|
||||
var treeList = await query.ToTreeAsync(it => it.Children, it => it.ShopGoodsCategoryParentGuid, 0);
|
||||
|
||||
treeList = await GetGoodsList(treeList);
|
||||
|
||||
return treeList;
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<ShopGoodsCategoryVoApi>> GetGoodsList(List<ShopGoodsCategoryVoApi> treeList)
|
||||
{
|
||||
foreach (var item in treeList)
|
||||
{
|
||||
var goodsQueryDtoApi = new GoodsQueryDtoApi
|
||||
{
|
||||
ShopGoodsCategoryGuid = item.ShopGoodsCategoryGuid
|
||||
};
|
||||
item.Items = await _GoodsServiceApi.GetGoodsApi(goodsQueryDtoApi);
|
||||
if (item.Children != null)
|
||||
{
|
||||
await GetGoodsList(item.Children);
|
||||
}
|
||||
}
|
||||
return treeList;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -25,7 +25,15 @@ namespace ARW.Service.Api.IBusinessService.GoodsManager.Goodss
|
||||
/// <returns></returns>
|
||||
Task<PagedInfo<GoodsVoApi>> GetGoodsListApi(GoodsQueryDtoApi parm);
|
||||
|
||||
/// <summary>
|
||||
|
||||
/// <summary>
|
||||
/// 获取商品列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<GoodsVoApi>> GetGoodsApi(GoodsQueryDtoApi parm);
|
||||
|
||||
/// <summary>
|
||||
/// 获取商品详情(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
|
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ARW.Model;
|
||||
using ARW.Model.Dto.Api.GoodsManager.ShopGoodsCategorys;
|
||||
using ARW.Model.Models.Business.GoodsManager.ShopGoodsCategorys;
|
||||
using ARW.Model.Vo.Api.GoodsManager.ShopGoodsCategorys;
|
||||
|
||||
namespace ARW.Service.Api.IBusinessService.GoodsManager.ShopGoodsCategorys
|
||||
{
|
||||
/// <summary>
|
||||
/// 店铺商品类目接口类Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-07-20
|
||||
/// </summary>
|
||||
public interface IShopGoodsCategoryServiceApi : IBaseService<ShopGoodsCategory>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取店铺商品类目树形列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<ShopGoodsCategoryVoApi>> GetShopGoodsCategoryTreeListApi(ShopGoodsCategoryQueryDtoApi parm);
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Enums;
|
||||
using Infrastructure.Model;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ARW.Admin.WebApi.Extensions;
|
||||
using ARW.Admin.WebApi.Filters;
|
||||
using ARW.Common;
|
||||
using ARW.Admin.WebApi.Controllers;
|
||||
using ARW.Model.Dto.Api.GoodsManager.ShopGoodsCategorys;
|
||||
using ARW.Service.Api.IBusinessService.GoodsManager.ShopGoodsCategorys;
|
||||
using ARW.Model.Models.Business.GoodsManager.ShopGoodsCategorys;
|
||||
using ARW.Model.Vo.Api.GoodsManager.ShopGoodsCategorys;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Geocoding;
|
||||
|
||||
namespace ARW.WebApi.Controllers.Api.ShopManager.ShopGoodsCategorys
|
||||
{
|
||||
/// <summary>
|
||||
/// 店铺商品类目控制器Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-07-20
|
||||
/// </summary>
|
||||
//[Verify]
|
||||
[Route("api/[controller]")]
|
||||
public class ShopGoodsCategoryApiController : BaseController
|
||||
{
|
||||
private readonly IShopGoodsCategoryServiceApi _ShopGoodsCategoryServiceApi;
|
||||
|
||||
/// <summary>
|
||||
/// 依赖注入
|
||||
/// </summary>
|
||||
/// <param name="ShopGoodsCategoryServiceApi">店铺商品类目店铺商品类目Api服务</param>
|
||||
public ShopGoodsCategoryApiController(IShopGoodsCategoryServiceApi ShopGoodsCategoryServiceApi)
|
||||
{
|
||||
_ShopGoodsCategoryServiceApi = ShopGoodsCategoryServiceApi;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取店铺商品类目树形列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm">查询参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getShopGoodsCategoryTreeList")]
|
||||
public async Task<IActionResult> GetShopGoodsCategoryTreeListApi([FromQuery] ShopGoodsCategoryQueryDtoApi parm)
|
||||
{
|
||||
var res = await _ShopGoodsCategoryServiceApi.GetShopGoodsCategoryTreeListApi(parm);
|
||||
if (res == null)
|
||||
res = new List<ShopGoodsCategoryVoApi>();
|
||||
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user