key1_beacon_api/ARW.Service/Business/BusinessService/GoodsManager/GoodsSpecs/GoodsSpecRels/GoodsSpecRelService.cs
2023-06-24 23:21:02 +08:00

93 lines
3.2 KiB
C#

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
{
/// <summary>
/// 商品与规格值关系记录接口实现类
///
/// @author lwh
/// @date 2023-06-19
/// </summary>
[AppService(ServiceType = typeof(IGoodsSpecRelService), ServiceLifetime = LifeTime.Transient)]
public class GoodsSpecRelServiceImpl : BaseService<GoodsSpecRel>, IGoodsSpecRelService
{
private readonly GoodsSpecRelRepository _GoodsSpecRelRepository;
public GoodsSpecRelServiceImpl(GoodsSpecRelRepository GoodsSpecRelRepository)
{
this._GoodsSpecRelRepository = GoodsSpecRelRepository;
}
#region
/// <summary>
/// 查询商品与规格值关系记录分页列表
/// </summary>
public async Task<PagedInfo<GoodsSpecRelVo>> GetGoodsSpecRelList(GoodsSpecRelQueryDto parm)
{
//开始拼装查询条件d
var predicate = Expressionable.Create<GoodsSpecRel>();
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);
}
/// <summary>
/// 新增商品与规格值关系
/// </summary>
/// <param name="goodsSpecRelList">商品与规格值关系列表</param>
public async Task InsertGoodsSpecRelAsync(List<GoodsSpecRel> goodsSpecRelList)
{
await _GoodsSpecRelRepository.InsertRangeAsync(goodsSpecRelList);
}
/// <summary>
/// 更新商品与规格值关系
/// </summary>
/// <param name="goodsSpecRelList">商品与规格值关系列表</param>
/// <returns></returns>
public async Task UpdateGoodsSpecRelAsync(List<GoodsSpecRel> goodsSpecRelList, long goodsGuid)
{
await _GoodsSpecRelRepository.DeleteAsync(s => s.GoodsGuid == goodsGuid);
await _GoodsSpecRelRepository.InsertRangeAsync(goodsSpecRelList);
}
#endregion
}
}