90 lines
3.0 KiB
C#
90 lines
3.0 KiB
C#
using Infrastructure.Attribute;
|
|
using SqlSugar;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using ARW.Model;
|
|
using ARW.Repository;
|
|
using ARW.Repository.Business.Custom.GoodsBrowsingHistorys;
|
|
using ARW.Service.Api.IBusinessService.Custom.GoodsBrowsingHistorys;
|
|
using ARW.Model.Dto.Api.Custom.GoodsBrowsingHistorys;
|
|
using ARW.Model.Models.Business.Custom.GoodsBrowsingHistorys;
|
|
using ARW.Model.Vo.Api.Custom.GoodsBrowsingHistorys;
|
|
|
|
namespace ARW.Service.Api.BusinessService.Custom.GoodsBrowsingHistorys
|
|
{
|
|
/// <summary>
|
|
/// 商品浏览记录接口实现类Api
|
|
///
|
|
/// @author lwh
|
|
/// @date 2023-10-22
|
|
/// </summary>
|
|
[AppService(ServiceType = typeof(IGoodsBrowsingHistoryServiceApi), ServiceLifetime = LifeTime.Transient)]
|
|
public class GoodsBrowsingHistoryServiceImplApi : BaseService<GoodsBrowsingHistory>, IGoodsBrowsingHistoryServiceApi
|
|
{
|
|
private readonly GoodsBrowsingHistoryRepository _GoodsBrowsingHistoryRepository;
|
|
|
|
public GoodsBrowsingHistoryServiceImplApi(GoodsBrowsingHistoryRepository GoodsBrowsingHistoryRepository)
|
|
{
|
|
this._GoodsBrowsingHistoryRepository = GoodsBrowsingHistoryRepository;
|
|
}
|
|
|
|
#region Api接口代码
|
|
|
|
|
|
/// <summary>
|
|
/// 查询商品浏览记录列表(Api)
|
|
/// </summary>
|
|
/// <param name="parm"></param>
|
|
/// <returns></returns>
|
|
public async Task<PagedInfo<GoodsBrowsingHistoryVoApi>> GetGoodsBrowsingHistoryListApi(GoodsBrowsingHistoryQueryDtoApi parm)
|
|
{
|
|
//开始拼装查询条件d
|
|
var predicate = Expressionable.Create<GoodsBrowsingHistory>();
|
|
predicate = predicate.AndIF(parm.CustomerGuid != 0, s => s.CustomerGuid == parm.CustomerGuid);
|
|
|
|
var query = _GoodsBrowsingHistoryRepository
|
|
.Queryable()
|
|
.Where(predicate.ToExpression())
|
|
.OrderBy(s => s.Create_time, OrderByType.Desc)
|
|
.Select(s => new GoodsBrowsingHistoryVoApi
|
|
{
|
|
SpuId = s.GoodsGuid,
|
|
CraeteTime = s.Create_time.ToString("yyyy-MM-dd"),
|
|
});
|
|
|
|
|
|
var list = await query.ToPageAsync(parm);
|
|
|
|
foreach (var item in list.Result)
|
|
{
|
|
item.Thumb = item.Thumb.Split(",").First();
|
|
}
|
|
|
|
return list;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 添加或修改商品浏览记录
|
|
/// </summary>
|
|
public async Task<string> AddOrUpdateGoodsBrowsingHistory(GoodsBrowsingHistory model)
|
|
{
|
|
if (model.GoodsBrowsingHistoryId != 0)
|
|
{
|
|
var response = await _GoodsBrowsingHistoryRepository.UpdateAsync(model);
|
|
return "修改成功!";
|
|
}
|
|
else
|
|
{
|
|
|
|
var response = await _GoodsBrowsingHistoryRepository.InsertReturnSnowflakeIdAsync(model);
|
|
return "添加成功!";
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|