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.GoodsManager.GoodsSpecs.GoodsSpecRels; using ARW.Service.Business.IBusinessService.GoodsManager.GoodsSpecs.GoodsSpecRels; using ARW.Model.Dto.Business.GoodsManager.GoodsSpecs.GoodsSpecRels; using ARW.Model.Models.Business.GoodsManager.GoodsSpecs.GoodsSpecRels; using ARW.Model.Vo.Business.GoodsManager.GoodsSpecs.GoodsSpecRels; using ARW.Model.Models.Business.GoodsManager.GoodsSpecs.SpecValues; using ARW.Repository.Business.GoodsManager.GoodsSpecs.SpecValues; using System.Diagnostics.Eventing.Reader; namespace ARW.Service.Business.BusinessService.GoodsManager.GoodsSpecs.GoodsSpecRels { /// /// 商品与规格值关系记录接口实现类 /// /// @author lwh /// @date 2023-06-19 /// [AppService(ServiceType = typeof(IGoodsSpecRelService), ServiceLifetime = LifeTime.Transient)] public class GoodsSpecRelServiceImpl : BaseService, IGoodsSpecRelService { private readonly GoodsSpecRelRepository _GoodsSpecRelRepository; public GoodsSpecRelServiceImpl(GoodsSpecRelRepository GoodsSpecRelRepository) { this._GoodsSpecRelRepository = GoodsSpecRelRepository; } #region 业务逻辑代码 /// /// 查询商品与规格值关系记录分页列表 /// public async Task> GetGoodsSpecRelList(GoodsSpecRelQueryDto parm) { //开始拼装查询条件d var predicate = Expressionable.Create(); var query = _GoodsSpecRelRepository .Queryable() .Where(predicate.ToExpression()) .OrderBy(s => s.Create_time, OrderByType.Desc) .Select(s => new GoodsSpecRelVo { GoodsSpecRelId = s.GoodsSpecRelId, GoodsGuid = s.GoodsGuid, SpecId = s.SpecId, SpecValueId = s.SpecValueId, }); return await query.ToPageAsync(parm); } /// /// 新增商品与规格值关系 /// /// 商品与规格值关系列表 public async Task InsertGoodsSpecRelAsync(List goodsSpecRelList) { await _GoodsSpecRelRepository.InsertRangeAsync(goodsSpecRelList); } /// /// 更新商品与规格值关系 /// /// 商品与规格值关系列表 /// public async Task UpdateGoodsSpecRelAsync(List goodsSpecRelList, long goodsGuid) { await _GoodsSpecRelRepository.DeleteAsync(s => s.GoodsGuid == goodsGuid); await _GoodsSpecRelRepository.InsertRangeAsync(goodsSpecRelList); } #endregion } }