emoticon_api/ARW.Service/Business/BusinessService/GoodsManager/GoodsSpecs/GoodsSpecRels/GoodsSpecRelService.cs

92 lines
2.8 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;
namespace ARW.Service.Business.BusinessService.GoodsManager.GoodsSpecs.GoodsSpecRels
{
/// <summary>
/// 商品与规格值关系记录接口实现类
///
/// @author 黎文豪
/// @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>
public async Task<string> AddOrUpdateGoodsSpecRel(GoodsSpecRel model)
{
if (model.GoodsSpecRelId != 0)
{
var response = await _GoodsSpecRelRepository.UpdateAsync(model);
return "修改成功!";
}
else
{
var response = await _GoodsSpecRelRepository.InsertReturnSnowflakeIdAsync(model);
return "添加成功!";
}
}
#region Excel处理
#endregion
#endregion
}
}