emoticon_api/ARW.Service/Business/BusinessService/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryService.cs
2023-10-22 17:23:10 +08:00

92 lines
2.9 KiB
C#

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 Infrastructure;
using ARW.Model;
using ARW.Repository;
using ARW.Repository.Business.Custom.GoodsBrowsingHistorys;
using ARW.Service.Business.IBusinessService.Custom.GoodsBrowsingHistorys;
using ARW.Model.Dto.Business.Custom.GoodsBrowsingHistorys;
using ARW.Model.Models.Business.Custom.GoodsBrowsingHistorys;
using ARW.Model.Vo.Business.Custom.GoodsBrowsingHistorys;
namespace ARW.Service.Business.BusinessService.Custom.GoodsBrowsingHistorys
{
/// <summary>
/// 商品浏览记录接口实现类
///
/// @author lwh
/// @date 2023-10-22
/// </summary>
[AppService(ServiceType = typeof(IGoodsBrowsingHistoryService), ServiceLifetime = LifeTime.Transient)]
public class GoodsBrowsingHistoryServiceImpl : BaseService<GoodsBrowsingHistory>, IGoodsBrowsingHistoryService
{
private readonly GoodsBrowsingHistoryRepository _GoodsBrowsingHistoryRepository;
public GoodsBrowsingHistoryServiceImpl(GoodsBrowsingHistoryRepository GoodsBrowsingHistoryRepository)
{
this._GoodsBrowsingHistoryRepository = GoodsBrowsingHistoryRepository;
}
#region
/// <summary>
/// 查询商品浏览记录分页列表
/// </summary>
public async Task<PagedInfo<GoodsBrowsingHistoryVo>> GetGoodsBrowsingHistoryList(GoodsBrowsingHistoryQueryDto parm)
{
//开始拼装查询条件d
var predicate = Expressionable.Create<GoodsBrowsingHistory>();
var query = _GoodsBrowsingHistoryRepository
.Queryable()
.Where(predicate.ToExpression())
.OrderBy(s => s.Create_time,OrderByType.Desc)
.Select(s => new GoodsBrowsingHistoryVo
{
GoodsBrowsingHistoryId = s.GoodsBrowsingHistoryId,
GoodsBrowsingHistoryGuid = s.GoodsBrowsingHistoryGuid,
CustomerGuid = s.CustomerGuid,
GoodsGuid = s.GoodsGuid,
});
return await query.ToPageAsync(parm);
}
/// <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 "添加成功!";
}
}
#region Excel处理
#endregion
#endregion
}
}