micro_mall_api/ARW.Service/Business/BusinessService/GoodsManager/GoodsServicess/GoodsServicesRels/GoodsServicesRelService.cs
2023-06-24 23:21:02 +08:00

94 lines
3.3 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.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
{
/// <summary>
/// 商品服务与承诺关系表接口实现类
///
/// @author lwh
/// @date 2023-06-18
/// </summary>
[AppService(ServiceType = typeof(IGoodsServicesRelService), ServiceLifetime = LifeTime.Transient)]
public class GoodsServicesRelServiceImpl : BaseService<GoodsServicesRel>, IGoodsServicesRelService
{
private readonly GoodsServicesRelRepository _GoodsServicesRelRepository;
public GoodsServicesRelServiceImpl(GoodsServicesRelRepository GoodsServicesRelRepository)
{
_GoodsServicesRelRepository = GoodsServicesRelRepository;
}
#region
/// <summary>
/// 查询商品服务与承诺关系表分页列表
/// </summary>
public async Task<PagedInfo<GoodsServicesRelVo>> GetGoodsServicesRelList(GoodsServicesRelQueryDto parm)
{
//开始拼装查询条件d
var predicate = Expressionable.Create<GoodsServicesRel>();
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);
}
/// <summary>
/// 新增商品服务与承诺关系
/// </summary>
/// <param name="goodsServicesRelList">商品服务与承诺关系列表</param>
public async Task InsertGoodsServicesRelAsync(List<GoodsServicesRel> goodsServicesRelList)
{
await _GoodsServicesRelRepository.InsertRangeAsync(goodsServicesRelList);
}
/// <summary>
/// 更新商品服务与承诺关系
/// </summary>
/// <param name="goodsServicesRelList">商品服务与承诺关系列表</param>
/// <param name="goodsGuid">商品guid</param>
/// <returns></returns>
public async Task UpdateGoodsServicesRelAsync(List<GoodsServicesRel> goodsServicesRelList, long goodsGuid)
{
await _GoodsServicesRelRepository.DeleteAsync(s => s.GoodsGuid == goodsGuid);
await _GoodsServicesRelRepository.InsertRangeAsync(goodsServicesRelList);
}
#endregion
}
}