From a2c521bb604ad55c1e0dd03076667a1f3824af96 Mon Sep 17 00:00:00 2001 From: "AERWEN\\26795" <123456789a> Date: Sun, 22 Oct 2023 17:23:10 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E6=B7=BB=E5=8A=A0=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E6=B5=8F=E8=A7=88=E7=AE=A1=E7=90=86=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GoodsBrowsingHistoryApiDto.cs | 33 +++++++ .../GoodsBrowsingHistoryDto.cs | 48 +++++++++ .../GoodsBrowsingHistory.cs | 59 +++++++++++ .../GoodsBrowsingHistoryApiVo.cs | 77 +++++++++++++++ .../GoodsBrowsingHistorys/GoodsBrowsingVo.cs | 67 +++++++++++++ .../GoodsBrowsingHistoryVo.cs | 45 +++++++++ .../GoodsBrowsingHistoryRepository.cs | 20 ++++ .../GoodsBrowsingHistoryServiceApi.cs | 97 ++++++++++++++++++ .../IGoodsBrowsingHistoryServiceApi.cs | 38 +++++++ .../GoodsBrowsingHistoryService.cs | 91 +++++++++++++++++ .../IGoodsBrowsingHistoryService.cs | 41 ++++++++ .../GoodsBrowsingHistoryApiController.cs | 99 +++++++++++++++++++ 12 files changed, 715 insertions(+) create mode 100644 ARW.Model/Dto/Api/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryApiDto.cs create mode 100644 ARW.Model/Dto/Business/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryDto.cs create mode 100644 ARW.Model/Models/Business/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistory.cs create mode 100644 ARW.Model/Vo/Api/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryApiVo.cs create mode 100644 ARW.Model/Vo/Api/Custom/GoodsBrowsingHistorys/GoodsBrowsingVo.cs create mode 100644 ARW.Model/Vo/Business/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryVo.cs create mode 100644 ARW.Repository/Business/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryRepository.cs create mode 100644 ARW.Service/Api/BusinessService/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryServiceApi.cs create mode 100644 ARW.Service/Api/IBusinessService/Custom/GoodsBrowsingHistorys/IGoodsBrowsingHistoryServiceApi.cs create mode 100644 ARW.Service/Business/BusinessService/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryService.cs create mode 100644 ARW.Service/Business/IBusinessService/Custom/GoodsBrowsingHistorys/IGoodsBrowsingHistoryService.cs create mode 100644 ARW.WebApi/Controllers/Api/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryApiController.cs diff --git a/ARW.Model/Dto/Api/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryApiDto.cs b/ARW.Model/Dto/Api/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryApiDto.cs new file mode 100644 index 0000000..ca9a878 --- /dev/null +++ b/ARW.Model/Dto/Api/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryApiDto.cs @@ -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 +{ + + /// + /// 商品浏览记录查询对象Api + /// + /// @author lwh + /// @date 2023-10-22 + /// + public class GoodsBrowsingHistoryQueryDtoApi : PagerInfo + { + public long CustomerGuid { get; set; } + } + + + /// + /// 商品浏览记录详情输入对象Api + /// + /// @author lwh + /// @date 2023-10-22 + /// + public class GoodsBrowsingHistoryDtoApi + { + [Required(ErrorMessage = "GoodsBrowsingHistoryGuid不能为空")] + public long GoodsBrowsingHistoryGuid { get; set; } + } + +} diff --git a/ARW.Model/Dto/Business/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryDto.cs b/ARW.Model/Dto/Business/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryDto.cs new file mode 100644 index 0000000..6fda5e3 --- /dev/null +++ b/ARW.Model/Dto/Business/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryDto.cs @@ -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 +{ + /// + /// 商品浏览记录输入对象 + /// + /// @author lwh + /// @date 2023-10-22 + /// + 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; } + + + + + + } + + + /// + /// 商品浏览记录查询对象 + /// + /// @author lwh + /// @date 2023-10-22 + /// + public class GoodsBrowsingHistoryQueryDto : PagerInfo + { + + public string ids { get; set; } + } + + + + +} diff --git a/ARW.Model/Models/Business/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistory.cs b/ARW.Model/Models/Business/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistory.cs new file mode 100644 index 0000000..2803b77 --- /dev/null +++ b/ARW.Model/Models/Business/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistory.cs @@ -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 +{ + /// + /// 商品浏览记录,数据实体对象 + /// + /// @author lwh + /// @date 2023-10-22 + /// + [SugarTable("tb_goods_browsing_history")] + public class GoodsBrowsingHistory : BusinessBase + { + + /// + /// 描述 : + /// 空值 : false + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "goods_browsing_history_id")] + public int GoodsBrowsingHistoryId { get; set; } + + + /// + /// 描述 : + /// 空值 : false + /// + [JsonConverter(typeof(ValueToStringConverter))] + [SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "goods_browsing_history_guid")] + public long GoodsBrowsingHistoryGuid { get; set; } + + + /// + /// 描述 :客户guid + /// 空值 : false + /// + [JsonConverter(typeof(ValueToStringConverter))] + [SugarColumn(ColumnName = "customer_guid")] + public long CustomerGuid { get; set; } + + + /// + /// 描述 :商品guid + /// 空值 : false + /// + [JsonConverter(typeof(ValueToStringConverter))] + [SugarColumn(ColumnName = "goods_guid")] + public long GoodsGuid { get; set; } + + + + + + + } +} \ No newline at end of file diff --git a/ARW.Model/Vo/Api/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryApiVo.cs b/ARW.Model/Vo/Api/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryApiVo.cs new file mode 100644 index 0000000..0ca14a8 --- /dev/null +++ b/ARW.Model/Vo/Api/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryApiVo.cs @@ -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 +{ + /// + /// 商品浏览记录展示对象Api + /// + /// @author lwh + /// @date 2023-10-22 + /// + public class GoodsBrowsingHistoryVoApi + { + /// + /// 描述 :浏览时间 + /// + public string CraeteTime { get; set; } + + + [JsonConverter(typeof(ValueToStringConverter))] + public long GoodsGuid { get; set; } + + + /// + /// 描述 :商品guid + /// + [JsonConverter(typeof(ValueToStringConverter))] + public long SpuId { get; set; } + + + /// + /// 描述 :商品名称 + /// + public string Title { get; set; } + + + /// + /// 描述 :商品封面 + /// + public string Thumb { get; set; } + + + /// + /// 描述 :收藏人数 + /// + public int CollectionNum { get; set; } + + + /// + /// 描述 :商品价格 + /// + public decimal Price { get; set; } + + + /// + /// 描述 :商品划线价格 + /// + public decimal OriginPrice { get; set; } + + + /// + /// 描述 :商品库存总量 + /// + public int SpuStockQuantity { get; set; } + + + /// + /// 描述 :是否上架 + /// + public int IsPutOnSale { get; set; } + + } + +} diff --git a/ARW.Model/Vo/Api/Custom/GoodsBrowsingHistorys/GoodsBrowsingVo.cs b/ARW.Model/Vo/Api/Custom/GoodsBrowsingHistorys/GoodsBrowsingVo.cs new file mode 100644 index 0000000..13d7b4f --- /dev/null +++ b/ARW.Model/Vo/Api/Custom/GoodsBrowsingHistorys/GoodsBrowsingVo.cs @@ -0,0 +1,67 @@ +using Newtonsoft.Json; +using OfficeOpenXml.Attributes; +using SqlSugar; +using System; + +namespace ARW.Model.Vo.Api.Custom.GoodsBrowsingHistorys +{ + /// + /// 商品浏览记录展示对象Api + /// + /// @author lwh + /// @date 2023-10-22 + /// + public class GoodsBrowsingVo + { + + /// + /// 描述 :商品guid + /// + [JsonConverter(typeof(ValueToStringConverter))] + public long SpuId { get; set; } + + + /// + /// 描述 :商品名称 + /// + public string Title { get; set; } + + + /// + /// 描述 :商品封面 + /// + public string Thumb { get; set; } + + + /// + /// 描述 :收藏人数 + /// + public int CollectionNum { get; set; } + + + /// + /// 描述 :商品价格 + /// + public decimal Price { get; set; } + + + /// + /// 描述 :商品划线价格 + /// + public decimal OriginPrice { get; set; } + + + /// + /// 描述 :商品库存总量 + /// + public int SpuStockQuantity { get; set; } + + + /// + /// 描述 :是否上架 + /// + public int IsPutOnSale { get; set; } + + } + +} diff --git a/ARW.Model/Vo/Business/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryVo.cs b/ARW.Model/Vo/Business/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryVo.cs new file mode 100644 index 0000000..bc4744c --- /dev/null +++ b/ARW.Model/Vo/Business/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryVo.cs @@ -0,0 +1,45 @@ +using Newtonsoft.Json; +using OfficeOpenXml.Attributes; +using SqlSugar; +using System; + +namespace ARW.Model.Vo.Business.Custom.GoodsBrowsingHistorys +{ + /// + /// 商品浏览记录展示对象 + /// + /// @author lwh + /// @date 2023-10-22 + /// + public class GoodsBrowsingHistoryVo + { + + + /// + /// 描述 : + /// + public int GoodsBrowsingHistoryId { get; set; } + + + /// + /// 描述 : + /// + [JsonConverter(typeof(ValueToStringConverter))] + public long GoodsBrowsingHistoryGuid { get; set; } + + + /// + /// 描述 :客户guid + /// + [JsonConverter(typeof(ValueToStringConverter))] + public long CustomerGuid { get; set; } + + + /// + /// 描述 :商品guid + /// + [JsonConverter(typeof(ValueToStringConverter))] + public long GoodsGuid { get; set; } + + } +} diff --git a/ARW.Repository/Business/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryRepository.cs b/ARW.Repository/Business/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryRepository.cs new file mode 100644 index 0000000..f124f0e --- /dev/null +++ b/ARW.Repository/Business/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryRepository.cs @@ -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 +{ + /// + /// 商品浏览记录仓储 + /// + /// @author lwh + /// @date 2023-10-22 + /// + [AppService(ServiceLifetime = LifeTime.Transient)] + public class GoodsBrowsingHistoryRepository : BaseRepository + { + #region 业务逻辑代码 + #endregion + } +} \ No newline at end of file diff --git a/ARW.Service/Api/BusinessService/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryServiceApi.cs b/ARW.Service/Api/BusinessService/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryServiceApi.cs new file mode 100644 index 0000000..eb9ed0e --- /dev/null +++ b/ARW.Service/Api/BusinessService/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryServiceApi.cs @@ -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 +{ + /// + /// 商品浏览记录接口实现类Api + /// + /// @author lwh + /// @date 2023-10-22 + /// + [AppService(ServiceType = typeof(IGoodsBrowsingHistoryServiceApi), ServiceLifetime = LifeTime.Transient)] + public class GoodsBrowsingHistoryServiceImplApi : BaseService, IGoodsBrowsingHistoryServiceApi + { + private readonly GoodsBrowsingHistoryRepository _GoodsBrowsingHistoryRepository; + + public GoodsBrowsingHistoryServiceImplApi(GoodsBrowsingHistoryRepository GoodsBrowsingHistoryRepository) + { + this._GoodsBrowsingHistoryRepository = GoodsBrowsingHistoryRepository; + } + + #region Api接口代码 + + + /// + /// 查询商品浏览记录列表(Api) + /// + /// + /// + public async Task> GetGoodsBrowsingHistoryListApi(GoodsBrowsingHistoryQueryDtoApi parm) + { + //开始拼装查询条件d + var predicate = Expressionable.Create(); + predicate = predicate.AndIF(parm.CustomerGuid != 0, s => s.CustomerGuid == parm.CustomerGuid); + + var query = _GoodsBrowsingHistoryRepository + .Queryable() + .Where(predicate.ToExpression()) + .LeftJoin((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; + } + + + /// + /// 添加或修改商品浏览记录 + /// + public async Task AddOrUpdateGoodsBrowsingHistory(GoodsBrowsingHistory model) + { + if (model.GoodsBrowsingHistoryId != 0) + { + var response = await _GoodsBrowsingHistoryRepository.UpdateAsync(model); + return "修改成功!"; + } + else + { + + var response = await _GoodsBrowsingHistoryRepository.InsertReturnSnowflakeIdAsync(model); + return "添加成功!"; + } + } + + + #endregion + + } +} diff --git a/ARW.Service/Api/IBusinessService/Custom/GoodsBrowsingHistorys/IGoodsBrowsingHistoryServiceApi.cs b/ARW.Service/Api/IBusinessService/Custom/GoodsBrowsingHistorys/IGoodsBrowsingHistoryServiceApi.cs new file mode 100644 index 0000000..b5fccd2 --- /dev/null +++ b/ARW.Service/Api/IBusinessService/Custom/GoodsBrowsingHistorys/IGoodsBrowsingHistoryServiceApi.cs @@ -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 +{ + /// + /// 商品浏览记录接口类Api + /// + /// @author lwh + /// @date 2023-10-22 + /// + public interface IGoodsBrowsingHistoryServiceApi : IBaseService + { + /// + /// 获取商品浏览记录分页列表(Api) + /// + /// + /// + Task> GetGoodsBrowsingHistoryListApi(GoodsBrowsingHistoryQueryDtoApi parm); + + + /// + /// 添加或修改商品浏览记录(Api) + /// + /// + /// + Task AddOrUpdateGoodsBrowsingHistory(GoodsBrowsingHistory parm); + + } +} diff --git a/ARW.Service/Business/BusinessService/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryService.cs b/ARW.Service/Business/BusinessService/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryService.cs new file mode 100644 index 0000000..abb6b0e --- /dev/null +++ b/ARW.Service/Business/BusinessService/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryService.cs @@ -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 +{ + /// + /// 商品浏览记录接口实现类 + /// + /// @author lwh + /// @date 2023-10-22 + /// + [AppService(ServiceType = typeof(IGoodsBrowsingHistoryService), ServiceLifetime = LifeTime.Transient)] + public class GoodsBrowsingHistoryServiceImpl : BaseService, IGoodsBrowsingHistoryService + { + private readonly GoodsBrowsingHistoryRepository _GoodsBrowsingHistoryRepository; + + public GoodsBrowsingHistoryServiceImpl(GoodsBrowsingHistoryRepository GoodsBrowsingHistoryRepository) + { + this._GoodsBrowsingHistoryRepository = GoodsBrowsingHistoryRepository; + } + + #region 业务逻辑代码 + + + /// + /// 查询商品浏览记录分页列表 + /// + public async Task> GetGoodsBrowsingHistoryList(GoodsBrowsingHistoryQueryDto parm) + { + //开始拼装查询条件d + var predicate = Expressionable.Create(); + + 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); + } + + /// + /// 添加或修改商品浏览记录 + /// + public async Task 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 + + } +} diff --git a/ARW.Service/Business/IBusinessService/Custom/GoodsBrowsingHistorys/IGoodsBrowsingHistoryService.cs b/ARW.Service/Business/IBusinessService/Custom/GoodsBrowsingHistorys/IGoodsBrowsingHistoryService.cs new file mode 100644 index 0000000..726872a --- /dev/null +++ b/ARW.Service/Business/IBusinessService/Custom/GoodsBrowsingHistorys/IGoodsBrowsingHistoryService.cs @@ -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 +{ + /// + /// 商品浏览记录接口类 + /// + /// @author lwh + /// @date 2023-10-22 + /// + public interface IGoodsBrowsingHistoryService : IBaseService + { + /// + /// 获取商品浏览记录分页列表 + /// + /// + /// + Task> GetGoodsBrowsingHistoryList(GoodsBrowsingHistoryQueryDto parm); + + + /// + /// 添加或修改商品浏览记录 + /// + /// + /// + Task AddOrUpdateGoodsBrowsingHistory(GoodsBrowsingHistory parm); + + + + + + } +} diff --git a/ARW.WebApi/Controllers/Api/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryApiController.cs b/ARW.WebApi/Controllers/Api/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryApiController.cs new file mode 100644 index 0000000..17e8b69 --- /dev/null +++ b/ARW.WebApi/Controllers/Api/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryApiController.cs @@ -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 +{ + /// + /// 商品浏览记录控制器Api + /// + /// @author lwh + /// @date 2023-10-22 + /// + [Verify] + [Route("api/[controller]")] + public class GoodsBrowsingHistoryApiController : BaseController + { + private readonly IGoodsBrowsingHistoryServiceApi _GoodsBrowsingHistoryServiceApi; + + /// + /// 依赖注入 + /// + /// 商品浏览记录商品浏览记录Api服务 + public GoodsBrowsingHistoryApiController(IGoodsBrowsingHistoryServiceApi GoodsBrowsingHistoryServiceApi) + { + _GoodsBrowsingHistoryServiceApi = GoodsBrowsingHistoryServiceApi; + } + + + /// + /// 获取商品浏览记录列表(Api) + /// + /// 查询参数 + /// + [HttpGet("getGoodsBrowsingHistoryList")] + public async Task GetGoodsBrowsingHistoryListApi([FromQuery] GoodsBrowsingHistoryQueryDtoApi parm) + { + var user = JwtUtil.GetLoginUser(App.HttpContext); + parm.CustomerGuid = user.UserId; + + var res = await _GoodsBrowsingHistoryServiceApi.GetGoodsBrowsingHistoryListApi(parm); + return SUCCESS(res); + } + + + /// + /// 添加或修改商品浏览记录 + /// + /// + /// + [HttpPost("addOrUpdateGoodsBrowsingHistory")] + [Log(Title = "添加或修改商品浏览记录", BusinessType = BusinessType.ADDORUPDATE)] + public async Task 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().ToUpdate(HttpContext); + else modal = parm.Adapt().ToCreate(HttpContext); + + var res = await _GoodsBrowsingHistoryServiceApi.AddOrUpdateGoodsBrowsingHistory(modal); + return SUCCESS(res); + } + + + /// + /// 删除商品浏览记录 + /// + /// + [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("删除成功!"); + } + + } +}