You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.8 KiB
C#

using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
using DS.WMS.Core.System.Interface;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
namespace DS.WMS.Core.System.Method;
/// <summary>
///
/// </summary>
public class CodeGoodsService:ICodeGoodsService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
/// <summary>
///
/// </summary>
/// <param name="serviceProvider"></param>
public CodeGoodsService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
}
/// <summary>
/// 商品列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public DataResult<List<CodeGoodsViewModel>> GetListByPage(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<code_goods>()
.LeftJoin<code_goodsType>((a, b) => a.GoodsTypeGID == b.GID)
.Select<CodeGoodsViewModel>()
.Where(whereList).ToQueryPage(request.PageCondition);
return data;
}
/// <summary>
/// 获取商品信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public DataResult<CodeGoodsViewModel> GetGoodInfo(string id)
{
var data = db.Queryable<code_goods>()
.LeftJoin<code_goodsType>((a, b) => a.GoodsTypeGID == b.GID)
.Where(a => a.GID == id)
.Select<CodeGoodsViewModel>()
.First();
return DataResult<CodeGoodsViewModel>.Success(data);
}
}