feat 添加商品收藏管理接口
This commit is contained in:
parent
b604980938
commit
61a7a5c084
@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using ARW.Model.Models.Business.Custom.GoodsCollections;
|
||||||
|
|
||||||
|
namespace ARW.Model.Dto.Api.Custom.GoodsCollections
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品收藏查询对象Api
|
||||||
|
///
|
||||||
|
/// @author lwh
|
||||||
|
/// @date 2023-10-22
|
||||||
|
/// </summary>
|
||||||
|
public class GoodsCollectionQueryDtoApi : PagerInfo
|
||||||
|
{
|
||||||
|
public long CustomerGuid { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品收藏详情输入对象Api
|
||||||
|
///
|
||||||
|
/// @author lwh
|
||||||
|
/// @date 2023-10-22
|
||||||
|
/// </summary>
|
||||||
|
public class GoodsCollectionDtoApi
|
||||||
|
{
|
||||||
|
[Required(ErrorMessage = "GoodsCollectionGuid不能为空")]
|
||||||
|
public long GoodsCollectionGuid { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using ARW.Model.Models.Business.Custom.GoodsCollections;
|
||||||
|
|
||||||
|
namespace ARW.Model.Dto.Business.Custom.GoodsCollections
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品收藏输入对象
|
||||||
|
///
|
||||||
|
/// @author lwh
|
||||||
|
/// @date 2023-10-22
|
||||||
|
/// </summary>
|
||||||
|
public class GoodsCollectionDto
|
||||||
|
{
|
||||||
|
|
||||||
|
public int GoodsCollectionId { get; set; }
|
||||||
|
|
||||||
|
public long GoodsCollectionGuid { 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 GoodsCollectionQueryDto : 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.GoodsCollections
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品收藏,数据实体对象
|
||||||
|
///
|
||||||
|
/// @author lwh
|
||||||
|
/// @date 2023-10-22
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("tb_goods_collection")]
|
||||||
|
public class GoodsCollection : BusinessBase
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :
|
||||||
|
/// 空值 : false
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "goods_collection_id")]
|
||||||
|
public int GoodsCollectionId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :
|
||||||
|
/// 空值 : false
|
||||||
|
/// </summary>
|
||||||
|
[JsonConverter(typeof(ValueToStringConverter))]
|
||||||
|
[SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "goods_collection_guid")]
|
||||||
|
public long GoodsCollectionGuid { 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,67 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using OfficeOpenXml.Attributes;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace ARW.Model.Vo.Api.Custom.GoodsCollections
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品收藏展示对象Api
|
||||||
|
///
|
||||||
|
/// @author lwh
|
||||||
|
/// @date 2023-10-22
|
||||||
|
/// </summary>
|
||||||
|
public class GoodsCollectionVoApi
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <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.GoodsCollections
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品收藏展示对象
|
||||||
|
///
|
||||||
|
/// @author lwh
|
||||||
|
/// @date 2023-10-22
|
||||||
|
/// </summary>
|
||||||
|
public class GoodsCollectionVo
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :
|
||||||
|
/// </summary>
|
||||||
|
public int GoodsCollectionId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :
|
||||||
|
/// </summary>
|
||||||
|
[JsonConverter(typeof(ValueToStringConverter))]
|
||||||
|
public long GoodsCollectionGuid { 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.GoodsCollections;
|
||||||
|
|
||||||
|
namespace ARW.Repository.Business.Custom.GoodsCollections
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品收藏仓储
|
||||||
|
///
|
||||||
|
/// @author lwh
|
||||||
|
/// @date 2023-10-22
|
||||||
|
/// </summary>
|
||||||
|
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||||
|
public class GoodsCollectionRepository : BaseRepository<GoodsCollection>
|
||||||
|
{
|
||||||
|
#region 业务逻辑代码
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,104 @@
|
|||||||
|
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.GoodsCollections;
|
||||||
|
using ARW.Service.Api.IBusinessService.Custom.GoodsCollections;
|
||||||
|
using ARW.Model.Dto.Api.Custom.GoodsCollections;
|
||||||
|
using ARW.Model.Models.Business.Custom.GoodsCollections;
|
||||||
|
using ARW.Model.Vo.Api.Custom.GoodsCollections;
|
||||||
|
using ARW.Model.Models.Business.GoodsManager.Goodss;
|
||||||
|
using Org.BouncyCastle.Crypto.Prng;
|
||||||
|
using Infrastructure;
|
||||||
|
|
||||||
|
namespace ARW.Service.Api.BusinessService.Custom.GoodsCollections
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品收藏接口实现类Api
|
||||||
|
///
|
||||||
|
/// @author lwh
|
||||||
|
/// @date 2023-10-22
|
||||||
|
/// </summary>
|
||||||
|
[AppService(ServiceType = typeof(IGoodsCollectionServiceApi), ServiceLifetime = LifeTime.Transient)]
|
||||||
|
public class GoodsCollectionServiceImplApi : BaseService<GoodsCollection>, IGoodsCollectionServiceApi
|
||||||
|
{
|
||||||
|
private readonly GoodsCollectionRepository _GoodsCollectionRepository;
|
||||||
|
|
||||||
|
public GoodsCollectionServiceImplApi(GoodsCollectionRepository GoodsCollectionRepository)
|
||||||
|
{
|
||||||
|
this._GoodsCollectionRepository = GoodsCollectionRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Api接口代码
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询商品收藏列表(Api)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<PagedInfo<GoodsCollectionVoApi>> GetGoodsCollectionListApi(GoodsCollectionQueryDtoApi parm)
|
||||||
|
{
|
||||||
|
//开始拼装查询条件d
|
||||||
|
var predicate = Expressionable.Create<GoodsCollection>();
|
||||||
|
predicate = predicate.AndIF(parm.CustomerGuid != 0, s => s.CustomerGuid == parm.CustomerGuid);
|
||||||
|
|
||||||
|
var query = _GoodsCollectionRepository
|
||||||
|
.Queryable()
|
||||||
|
.Where(predicate.ToExpression())
|
||||||
|
.LeftJoin<Goods>((s, c) => s.GoodsGuid == c.GoodsGuid)
|
||||||
|
.OrderBy(s => s.Create_time, OrderByType.Desc)
|
||||||
|
.Select((s, c) => new GoodsCollectionVoApi
|
||||||
|
{
|
||||||
|
SpuId = s.GoodsGuid,
|
||||||
|
Title = c.GoodsName,
|
||||||
|
Thumb = c.GoodsPicture,
|
||||||
|
Price = c.GoodsPriceLowest,
|
||||||
|
OriginPrice = c.GoodsDashedPriceLowest,
|
||||||
|
SpuStockQuantity = c.GoodsTotalInventory,
|
||||||
|
IsPutOnSale = c.GoodsShelfStatus
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
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> AddOrUpdateGoodsCollection(GoodsCollection model)
|
||||||
|
{
|
||||||
|
if (model.GoodsCollectionId != 0)
|
||||||
|
{
|
||||||
|
var response = await _GoodsCollectionRepository.UpdateAsync(model);
|
||||||
|
return "修改成功!";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var isRepeat = await _GoodsCollectionRepository.GetFirstAsync(s => s.CustomerGuid == model.CustomerGuid && s.GoodsGuid == model.GoodsGuid);
|
||||||
|
if (isRepeat != null) throw new CustomException("商品已收藏,请勿重复收藏!");
|
||||||
|
var response = await _GoodsCollectionRepository.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.GoodsCollections;
|
||||||
|
using ARW.Model.Models.Business.Custom.GoodsCollections;
|
||||||
|
using ARW.Model.Vo.Api.Custom.GoodsCollections;
|
||||||
|
|
||||||
|
namespace ARW.Service.Api.IBusinessService.Custom.GoodsCollections
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品收藏接口类Api
|
||||||
|
///
|
||||||
|
/// @author lwh
|
||||||
|
/// @date 2023-10-22
|
||||||
|
/// </summary>
|
||||||
|
public interface IGoodsCollectionServiceApi : IBaseService<GoodsCollection>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取商品收藏分页列表(Api)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<PagedInfo<GoodsCollectionVoApi>> GetGoodsCollectionListApi(GoodsCollectionQueryDtoApi parm);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加或修改商品收藏
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<string> AddOrUpdateGoodsCollection(GoodsCollection 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.GoodsCollections;
|
||||||
|
using ARW.Service.Business.IBusinessService.Custom.GoodsCollections;
|
||||||
|
using ARW.Model.Dto.Business.Custom.GoodsCollections;
|
||||||
|
using ARW.Model.Models.Business.Custom.GoodsCollections;
|
||||||
|
using ARW.Model.Vo.Business.Custom.GoodsCollections;
|
||||||
|
|
||||||
|
namespace ARW.Service.Business.BusinessService.Custom.GoodsCollections
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品收藏接口实现类
|
||||||
|
///
|
||||||
|
/// @author lwh
|
||||||
|
/// @date 2023-10-22
|
||||||
|
/// </summary>
|
||||||
|
[AppService(ServiceType = typeof(IGoodsCollectionService), ServiceLifetime = LifeTime.Transient)]
|
||||||
|
public class GoodsCollectionServiceImpl : BaseService<GoodsCollection>, IGoodsCollectionService
|
||||||
|
{
|
||||||
|
private readonly GoodsCollectionRepository _GoodsCollectionRepository;
|
||||||
|
|
||||||
|
public GoodsCollectionServiceImpl(GoodsCollectionRepository GoodsCollectionRepository)
|
||||||
|
{
|
||||||
|
this._GoodsCollectionRepository = GoodsCollectionRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 业务逻辑代码
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询商品收藏分页列表
|
||||||
|
/// </summary>
|
||||||
|
public async Task<PagedInfo<GoodsCollectionVo>> GetGoodsCollectionList(GoodsCollectionQueryDto parm)
|
||||||
|
{
|
||||||
|
//开始拼装查询条件d
|
||||||
|
var predicate = Expressionable.Create<GoodsCollection>();
|
||||||
|
|
||||||
|
var query = _GoodsCollectionRepository
|
||||||
|
.Queryable()
|
||||||
|
.Where(predicate.ToExpression())
|
||||||
|
.OrderBy(s => s.Create_time,OrderByType.Desc)
|
||||||
|
.Select(s => new GoodsCollectionVo
|
||||||
|
{
|
||||||
|
GoodsCollectionId = s.GoodsCollectionId,
|
||||||
|
GoodsCollectionGuid = s.GoodsCollectionGuid,
|
||||||
|
CustomerGuid = s.CustomerGuid,
|
||||||
|
GoodsGuid = s.GoodsGuid,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
return await query.ToPageAsync(parm);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加或修改商品收藏
|
||||||
|
/// </summary>
|
||||||
|
public async Task<string> AddOrUpdateGoodsCollection(GoodsCollection model)
|
||||||
|
{
|
||||||
|
if (model.GoodsCollectionId != 0)
|
||||||
|
{
|
||||||
|
var response = await _GoodsCollectionRepository.UpdateAsync(model);
|
||||||
|
return "修改成功!";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
var response = await _GoodsCollectionRepository.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.GoodsCollections;
|
||||||
|
using ARW.Model.Models.Business.Custom.GoodsCollections;
|
||||||
|
using ARW.Model.Vo.Business.Custom.GoodsCollections;
|
||||||
|
|
||||||
|
namespace ARW.Service.Business.IBusinessService.Custom.GoodsCollections
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品收藏接口类
|
||||||
|
///
|
||||||
|
/// @author lwh
|
||||||
|
/// @date 2023-10-22
|
||||||
|
/// </summary>
|
||||||
|
public interface IGoodsCollectionService : IBaseService<GoodsCollection>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取商品收藏分页列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<PagedInfo<GoodsCollectionVo>> GetGoodsCollectionList(GoodsCollectionQueryDto parm);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加或修改商品收藏
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<string> AddOrUpdateGoodsCollection(GoodsCollection parm);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,100 @@
|
|||||||
|
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.GoodsCollections;
|
||||||
|
using ARW.Service.Api.IBusinessService.Custom.GoodsCollections;
|
||||||
|
using ARW.Model.Models.Business.Custom.GoodsCollections;
|
||||||
|
using ARW.Model.Vo.Api.Custom.GoodsCollections;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Geocoding;
|
||||||
|
using ARW.Model.Dto.Business.Custom.GoodsCollections;
|
||||||
|
using ARW.Service.Business.IBusinessService.Custom.GoodsCollections;
|
||||||
|
using ARW.Admin.WebApi.Framework;
|
||||||
|
|
||||||
|
namespace ARW.WebApi.Controllers.Api.Custom.GoodsCollections
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 商品收藏控制器Api
|
||||||
|
///
|
||||||
|
/// @author lwh
|
||||||
|
/// @date 2023-10-22
|
||||||
|
/// </summary>
|
||||||
|
[Verify]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class GoodsCollectionApiController : BaseController
|
||||||
|
{
|
||||||
|
private readonly IGoodsCollectionServiceApi _GoodsCollectionServiceApi;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 依赖注入
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="GoodsCollectionServiceApi">商品收藏商品收藏Api服务</param>
|
||||||
|
public GoodsCollectionApiController(IGoodsCollectionServiceApi GoodsCollectionServiceApi)
|
||||||
|
{
|
||||||
|
_GoodsCollectionServiceApi = GoodsCollectionServiceApi;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取商品收藏列表(Api)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm">查询参数</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("getGoodsCollectionList")]
|
||||||
|
public async Task<IActionResult> GetGoodsCollectionListApi([FromQuery] GoodsCollectionQueryDtoApi parm)
|
||||||
|
{
|
||||||
|
var user = JwtUtil.GetLoginUser(App.HttpContext);
|
||||||
|
parm.CustomerGuid = user.UserId;
|
||||||
|
|
||||||
|
var res = await _GoodsCollectionServiceApi.GetGoodsCollectionListApi(parm);
|
||||||
|
return SUCCESS(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加或修改商品收藏
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("addOrUpdateGoodsCollection")]
|
||||||
|
[Log(Title = "添加或修改商品收藏", BusinessType = BusinessType.ADDORUPDATE)]
|
||||||
|
public async Task<IActionResult> AddOrUpdateGoodsCollection([FromBody] GoodsCollectionDto parm)
|
||||||
|
{
|
||||||
|
if (parm == null) { throw new CustomException("请求参数错误"); }
|
||||||
|
var user = JwtUtil.GetLoginUser(App.HttpContext);
|
||||||
|
parm.CustomerGuid = user.UserId;
|
||||||
|
|
||||||
|
var modal = new GoodsCollection();
|
||||||
|
if (parm.GoodsCollectionId != 0) modal = parm.Adapt<GoodsCollection>().ToUpdate(HttpContext);
|
||||||
|
else modal = parm.Adapt<GoodsCollection>().ToCreate(HttpContext);
|
||||||
|
|
||||||
|
var res = await _GoodsCollectionServiceApi.AddOrUpdateGoodsCollection(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 = _GoodsCollectionServiceApi.Delete(idsArr);
|
||||||
|
return SUCCESS("删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user