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 { /// /// 商品收藏控制器Api /// /// @author lwh /// @date 2023-10-22 /// [Verify] [Route("api/[controller]")] public class GoodsCollectionApiController : BaseController { private readonly IGoodsCollectionServiceApi _GoodsCollectionServiceApi; /// /// 依赖注入 /// /// 商品收藏商品收藏Api服务 public GoodsCollectionApiController(IGoodsCollectionServiceApi GoodsCollectionServiceApi) { _GoodsCollectionServiceApi = GoodsCollectionServiceApi; } /// /// 获取商品收藏列表(Api) /// /// 查询参数 /// [HttpGet("getGoodsCollectionList")] public async Task GetGoodsCollectionListApi([FromQuery] GoodsCollectionQueryDtoApi parm) { var user = JwtUtil.GetLoginUser(App.HttpContext); parm.CustomerGuid = user.UserId; var res = await _GoodsCollectionServiceApi.GetGoodsCollectionListApi(parm); return SUCCESS(res); } /// /// 添加或修改商品收藏 /// /// /// [HttpPost("addOrUpdateGoodsCollection")] [Log(Title = "添加或修改商品收藏", BusinessType = BusinessType.ADDORUPDATE)] public async Task 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().ToUpdate(HttpContext); else modal = parm.Adapt().ToCreate(HttpContext); var res = await _GoodsCollectionServiceApi.AddOrUpdateGoodsCollection(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 = _GoodsCollectionServiceApi.Delete(idsArr); return SUCCESS("删除成功!"); } } }