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.Model.Dto.Business.GoodsManager.GoodsServicess.GoodsServicesRels; using ARW.Model.Models.Business.GoodsManager.GoodsServicess.GoodsServicesRels; using ARW.Model.Vo.Business.GoodsManager.GoodsServicess.GoodsServicesRels; using ARW.Repository.Business.GoodsManager.GoodsServicess.GoodsServicesRels; using ARW.Service.Business.IBusinessService.GoodsManager.GoodsServicess.GoodsServicesRels; using ARW.Model.Models.Business.LogisticsManage.DeliveryRules; using ARW.Repository.Business.LogisticsManage.DeliveryRules; namespace ARW.Service.Business.BusinessService.GoodsManager.GoodsServicess.GoodsServicesRels { /// /// 商品服务与承诺关系表接口实现类 /// /// @author lwh /// @date 2023-06-18 /// [AppService(ServiceType = typeof(IGoodsServicesRelService), ServiceLifetime = LifeTime.Transient)] public class GoodsServicesRelServiceImpl : BaseService, IGoodsServicesRelService { private readonly GoodsServicesRelRepository _GoodsServicesRelRepository; public GoodsServicesRelServiceImpl(GoodsServicesRelRepository GoodsServicesRelRepository) { _GoodsServicesRelRepository = GoodsServicesRelRepository; } #region 业务逻辑代码 /// /// 查询商品服务与承诺关系表分页列表 /// public async Task> GetGoodsServicesRelList(GoodsServicesRelQueryDto parm) { //开始拼装查询条件d var predicate = Expressionable.Create(); var query = _GoodsServicesRelRepository .Queryable() .Where(predicate.ToExpression()) .OrderBy(s => s.Id, OrderByType.Desc) .Select(s => new GoodsServicesRelVo { Id = s.Id, ShopGuid = s.ShopGuid, GoodsGuid = s.GoodsGuid, ServiceId = s.ServiceId, }); return await query.ToPageAsync(parm); } /// /// 获取当前商品的服务与承诺Id /// /// /// public async Task> GetCurrentGoodsServicesRel(GoodsServicesRelQueryDto parm) { var idList = new List(); var goodsServiceList = await _GoodsServicesRelRepository.GetListAsync(s => s.GoodsGuid == parm.GoodsGuid); if (goodsServiceList.Count > 0) idList = goodsServiceList.Select(s => s.ServiceId).ToList(); return idList; } /// /// 新增商品服务与承诺关系 /// /// 商品服务与承诺关系列表 public async Task InsertGoodsServicesRelAsync(List goodsServicesRelList) { await _GoodsServicesRelRepository.InsertRangeAsync(goodsServicesRelList); } /// /// 更新商品服务与承诺关系 /// /// 商品服务与承诺关系列表 /// 商品guid /// public async Task UpdateGoodsServicesRelAsync(List goodsServicesRelList, long goodsGuid) { await _GoodsServicesRelRepository.DeleteAsync(s => s.GoodsGuid == goodsGuid); await _GoodsServicesRelRepository.InsertRangeAsync(goodsServicesRelList); } #endregion } }