using JNPF.Common.Core.Manager; using JNPF.Common.Extension; using JNPF.Common.Filter; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.Extend.Entitys; using JNPF.Extend.Entitys.Dto.ProductGoods; using Microsoft.AspNetCore.Mvc; using SqlSugar; namespace JNPF.Extend; /// /// 选择产品. /// [ApiDescriptionSettings(Tag = "Extend", Name = "Goods", Order = 600)] [Route("api/extend/saleOrder/[controller]")] public class ProductGoodsService : IDynamicApiController, ITransient { /// /// 服务基础仓储. /// private readonly ISqlSugarRepository _repository; /// /// 用户管理. /// private readonly IUserManager _userManager; public ProductGoodsService( ISqlSugarRepository repository, IUserManager userManager) { _repository = repository; _userManager = userManager; } #region GET /// /// 产品列表. /// /// [HttpGet("")] public async Task GetList([FromQuery] ProductGoodsListQueryInput input) { var data = await _repository.AsQueryable() .Where(it => it.DeleteMark == null) .WhereIF(!string.IsNullOrEmpty(input.classifyId), it => it.ClassifyId.Equals(input.classifyId)) .WhereIF(!string.IsNullOrEmpty(input.code), it => it.Code.Contains(input.code)) .WhereIF(!string.IsNullOrEmpty(input.fullName), it => it.FullName.Contains(input.fullName)) .Select(it => new ProductGoodsListOutput { id = it.Id, code = it.Code, fullName = it.FullName, qty = it.Qty, }).MergeTable().OrderByIF(string.IsNullOrEmpty(input.sidx), it => it.id).OrderByIF(!string.IsNullOrEmpty(input.sidx), input.sidx + " " + input.sort).ToPagedListAsync(input.currentPage, input.pageSize); return PageResult.SqlSugarPageResult(data); } /// /// 商品编码. /// /// [HttpGet("Selector")] public async Task GetSelectorList([FromQuery] PageInputBase input) { var data = await _repository.AsQueryable() .Where(it => it.DeleteMark == null) .WhereIF(input.keyword.IsNotEmptyOrNull(), x => x.Code.Contains(input.keyword)) .Select(it => new ProductGoodsListOutput { id = it.Id, classifyId = it.ClassifyId, code = it.Code, fullName = it.FullName, qty = it.Qty, type = it.Type, amount = it.Amount, money = it.Money, }).ToListAsync(); return new { list = data }; } #endregion }