山东雷驰
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.
 
 
 
 

53 lines
1.6 KiB

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