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

58 lines
1.9 KiB

using Microsoft.AspNetCore.Mvc;
using System.Linq;
using System.Threading.Tasks;
namespace Kean.Presentation.Rest.Controllers
{
/// <summary>
/// 货位服务
/// </summary>
[ApiController, Route("api/cells")]
public class CellsController : ControllerBase
{
private readonly Application.Query.Interfaces.IWarehouseService _warehouseQueryService; // 库房信息查询服务
/// <summary>
/// 依赖注入
/// </summary>
public CellsController(
Application.Query.Interfaces.IWarehouseService warehouseQueryService)
{
_warehouseQueryService = warehouseQueryService;
}
/// <summary>
/// 获取货位列表
/// </summary>
/// <response code="200">成功</response>
[HttpGet]
[ProducesResponseType(200)]
public async Task<IActionResult> GetList(
[FromQuery] int[] area,
[FromQuery] string type,
[FromQuery] bool? @in,
[FromQuery] bool? @out,
[FromQuery] string name,
[FromQuery] string sort,
[FromQuery] int? offset,
[FromQuery] int? limit,
[FromQuery] string laneway,
[FromQuery] string cellTag)
{
if (area.Length == 0)
{
area = null;
}
var items = await _warehouseQueryService.GetCellList(area, type, @in, @out, name, null, sort, offset, limit, laneway, cellTag);
if (offset.HasValue || limit.HasValue)
{
var total = await _warehouseQueryService.GetCellCount(area, type, @in, @out, name, null, laneway, cellTag);
return StatusCode(200, new { items, total });
}
else
{
return StatusCode(200, new { items, total = items.Count() });
}
}
}
}