feat 添加商品历史浏览管理接口
This commit is contained in:
parent
61a7a5c084
commit
a2c521bb60
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using ARW.Model.Models.Business.Custom.GoodsBrowsingHistorys;
|
||||
|
||||
namespace ARW.Model.Dto.Api.Custom.GoodsBrowsingHistorys
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 商品浏览记录查询对象Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-10-22
|
||||
/// </summary>
|
||||
public class GoodsBrowsingHistoryQueryDtoApi : PagerInfo
|
||||
{
|
||||
public long CustomerGuid { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 商品浏览记录详情输入对象Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-10-22
|
||||
/// </summary>
|
||||
public class GoodsBrowsingHistoryDtoApi
|
||||
{
|
||||
[Required(ErrorMessage = "GoodsBrowsingHistoryGuid不能为空")]
|
||||
public long GoodsBrowsingHistoryGuid { get; set; }
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using ARW.Model.Models.Business.Custom.GoodsBrowsingHistorys;
|
||||
|
||||
namespace ARW.Model.Dto.Business.Custom.GoodsBrowsingHistorys
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品浏览记录输入对象
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-10-22
|
||||
/// </summary>
|
||||
public class GoodsBrowsingHistoryDto
|
||||
{
|
||||
|
||||
public int GoodsBrowsingHistoryId { get; set; }
|
||||
|
||||
public long GoodsBrowsingHistoryGuid { get; set; }
|
||||
|
||||
public long CustomerGuid { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "商品guid不能为空")]
|
||||
public long GoodsGuid { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 商品浏览记录查询对象
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-10-22
|
||||
/// </summary>
|
||||
public class GoodsBrowsingHistoryQueryDto : PagerInfo
|
||||
{
|
||||
|
||||
public string ids { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SqlSugar;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ARW.Model.Models.Business.Custom.GoodsBrowsingHistorys
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品浏览记录,数据实体对象
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-10-22
|
||||
/// </summary>
|
||||
[SugarTable("tb_goods_browsing_history")]
|
||||
public class GoodsBrowsingHistory : BusinessBase
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "goods_browsing_history_id")]
|
||||
public int GoodsBrowsingHistoryId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "goods_browsing_history_guid")]
|
||||
public long GoodsBrowsingHistoryGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :客户guid
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(ColumnName = "customer_guid")]
|
||||
public long CustomerGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品guid
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(ColumnName = "goods_guid")]
|
||||
public long GoodsGuid { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
using Newtonsoft.Json;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ARW.Model.Vo.Api.Custom.GoodsBrowsingHistorys
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品浏览记录展示对象Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-10-22
|
||||
/// </summary>
|
||||
public class GoodsBrowsingHistoryVoApi
|
||||
{
|
||||
/// <summary>
|
||||
/// 描述 :浏览时间
|
||||
/// </summary>
|
||||
public string CraeteTime { get; set; }
|
||||
|
||||
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
public long GoodsGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品guid
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
public long SpuId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品名称
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品封面
|
||||
/// </summary>
|
||||
public string Thumb { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :收藏人数
|
||||
/// </summary>
|
||||
public int CollectionNum { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品价格
|
||||
/// </summary>
|
||||
public decimal Price { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品划线价格
|
||||
/// </summary>
|
||||
public decimal OriginPrice { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品库存总量
|
||||
/// </summary>
|
||||
public int SpuStockQuantity { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :是否上架
|
||||
/// </summary>
|
||||
public int IsPutOnSale { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
using Newtonsoft.Json;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace ARW.Model.Vo.Api.Custom.GoodsBrowsingHistorys
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品浏览记录展示对象Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-10-22
|
||||
/// </summary>
|
||||
public class GoodsBrowsingVo
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品guid
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
public long SpuId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品名称
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品封面
|
||||
/// </summary>
|
||||
public string Thumb { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :收藏人数
|
||||
/// </summary>
|
||||
public int CollectionNum { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品价格
|
||||
/// </summary>
|
||||
public decimal Price { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品划线价格
|
||||
/// </summary>
|
||||
public decimal OriginPrice { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品库存总量
|
||||
/// </summary>
|
||||
public int SpuStockQuantity { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :是否上架
|
||||
/// </summary>
|
||||
public int IsPutOnSale { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
using Newtonsoft.Json;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace ARW.Model.Vo.Business.Custom.GoodsBrowsingHistorys
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品浏览记录展示对象
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-10-22
|
||||
/// </summary>
|
||||
public class GoodsBrowsingHistoryVo
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// </summary>
|
||||
public int GoodsBrowsingHistoryId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
public long GoodsBrowsingHistoryGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :客户guid
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
public long CustomerGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品guid
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
public long GoodsGuid { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using Infrastructure.Attribute;
|
||||
using ARW.Repository.System;
|
||||
using ARW.Model.Models.Business.Custom.GoodsBrowsingHistorys;
|
||||
|
||||
namespace ARW.Repository.Business.Custom.GoodsBrowsingHistorys
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品浏览记录仓储
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-10-22
|
||||
/// </summary>
|
||||
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||
public class GoodsBrowsingHistoryRepository : BaseRepository<GoodsBrowsingHistory>
|
||||
{
|
||||
#region 业务逻辑代码
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
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.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;
|
||||
using Org.BouncyCastle.Crypto.Prng;
|
||||
using ARW.Model.Models.Business.GoodsManager.Goodss;
|
||||
|
||||
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())
|
||||
.LeftJoin<Goods>((s, c) => s.GoodsGuid == c.GoodsGuid)
|
||||
.OrderBy(s => s.Create_time, OrderByType.Desc)
|
||||
.Select((s, c) => new GoodsBrowsingHistoryVoApi
|
||||
{
|
||||
SpuId = s.GoodsGuid,
|
||||
Title = c.GoodsName,
|
||||
Thumb = c.GoodsPicture,
|
||||
Price = c.GoodsPriceLowest,
|
||||
OriginPrice = c.GoodsDashedPriceLowest,
|
||||
SpuStockQuantity = c.GoodsTotalInventory,
|
||||
IsPutOnSale = c.GoodsShelfStatus,
|
||||
CraeteTime = s.Create_time.ToString("yyyy-MM-dd"),
|
||||
});
|
||||
|
||||
|
||||
var list = await query.ToPageAsync(parm);
|
||||
|
||||
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
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ARW.Model;
|
||||
using ARW.Model.Dto.Api.Custom.GoodsBrowsingHistorys;
|
||||
using ARW.Model.Dto.Business.Custom.GoodsBrowsingHistorys;
|
||||
using ARW.Model.Models.Business.Custom.GoodsBrowsingHistorys;
|
||||
using ARW.Model.Vo.Api.Custom.GoodsBrowsingHistorys;
|
||||
|
||||
namespace ARW.Service.Api.IBusinessService.Custom.GoodsBrowsingHistorys
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品浏览记录接口类Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-10-22
|
||||
/// </summary>
|
||||
public interface IGoodsBrowsingHistoryServiceApi : IBaseService<GoodsBrowsingHistory>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取商品浏览记录分页列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<PagedInfo<GoodsBrowsingHistoryVoApi>> GetGoodsBrowsingHistoryListApi(GoodsBrowsingHistoryQueryDtoApi parm);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改商品浏览记录(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> AddOrUpdateGoodsBrowsingHistory(GoodsBrowsingHistory parm);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
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
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ARW.Model;
|
||||
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.IBusinessService.Custom.GoodsBrowsingHistorys
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品浏览记录接口类
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-10-22
|
||||
/// </summary>
|
||||
public interface IGoodsBrowsingHistoryService : IBaseService<GoodsBrowsingHistory>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取商品浏览记录分页列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<PagedInfo<GoodsBrowsingHistoryVo>> GetGoodsBrowsingHistoryList(GoodsBrowsingHistoryQueryDto parm);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改商品浏览记录
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> AddOrUpdateGoodsBrowsingHistory(GoodsBrowsingHistory parm);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
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.Custom.GoodsBrowsingHistorys;
|
||||
using ARW.Service.Api.IBusinessService.Custom.GoodsBrowsingHistorys;
|
||||
using ARW.Model.Models.Business.Custom.GoodsBrowsingHistorys;
|
||||
using ARW.Model.Vo.Api.Custom.GoodsBrowsingHistorys;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Geocoding;
|
||||
using ARW.Model.Dto.Business.Custom.GoodsBrowsingHistorys;
|
||||
using ARW.Service.Business.IBusinessService.Custom.GoodsBrowsingHistorys;
|
||||
using ARW.Admin.WebApi.Framework;
|
||||
|
||||
namespace ARW.WebApi.Controllers.Api.Custom.GoodsBrowsingHistorys
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品浏览记录控制器Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-10-22
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("api/[controller]")]
|
||||
public class GoodsBrowsingHistoryApiController : BaseController
|
||||
{
|
||||
private readonly IGoodsBrowsingHistoryServiceApi _GoodsBrowsingHistoryServiceApi;
|
||||
|
||||
/// <summary>
|
||||
/// 依赖注入
|
||||
/// </summary>
|
||||
/// <param name="GoodsBrowsingHistoryServiceApi">商品浏览记录商品浏览记录Api服务</param>
|
||||
public GoodsBrowsingHistoryApiController(IGoodsBrowsingHistoryServiceApi GoodsBrowsingHistoryServiceApi)
|
||||
{
|
||||
_GoodsBrowsingHistoryServiceApi = GoodsBrowsingHistoryServiceApi;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取商品浏览记录列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm">查询参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getGoodsBrowsingHistoryList")]
|
||||
public async Task<IActionResult> GetGoodsBrowsingHistoryListApi([FromQuery] GoodsBrowsingHistoryQueryDtoApi parm)
|
||||
{
|
||||
var user = JwtUtil.GetLoginUser(App.HttpContext);
|
||||
parm.CustomerGuid = user.UserId;
|
||||
|
||||
var res = await _GoodsBrowsingHistoryServiceApi.GetGoodsBrowsingHistoryListApi(parm);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改商品浏览记录
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("addOrUpdateGoodsBrowsingHistory")]
|
||||
[Log(Title = "添加或修改商品浏览记录", BusinessType = BusinessType.ADDORUPDATE)]
|
||||
public async Task<IActionResult> AddOrUpdateGoodsBrowsingHistory([FromBody] GoodsBrowsingHistoryDto parm)
|
||||
{
|
||||
if (parm == null) { throw new CustomException("请求参数错误"); }
|
||||
var user = JwtUtil.GetLoginUser(App.HttpContext);
|
||||
parm.CustomerGuid = user.UserId;
|
||||
|
||||
var modal = new GoodsBrowsingHistory();
|
||||
if (parm.GoodsBrowsingHistoryId != 0) modal = parm.Adapt<GoodsBrowsingHistory>().ToUpdate(HttpContext);
|
||||
else modal = parm.Adapt<GoodsBrowsingHistory>().ToCreate(HttpContext);
|
||||
|
||||
var res = await _GoodsBrowsingHistoryServiceApi.AddOrUpdateGoodsBrowsingHistory(modal);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 删除商品浏览记录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{ids}")]
|
||||
[Log(Title = "商品浏览记录删除", BusinessType = BusinessType.DELETE)]
|
||||
public IActionResult Delete(string ids)
|
||||
{
|
||||
long[] idsArr = Tools.SpitLongArrary(ids);
|
||||
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
|
||||
var response = _GoodsBrowsingHistoryServiceApi.Delete(idsArr);
|
||||
return SUCCESS("删除成功!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user