using Microsoft.AspNetCore.Mvc; using System.Linq; using System.Threading.Tasks; namespace Kean.Presentation.Rest.Controllers { /// /// 库区服务 /// [ApiController, Route("api/areas")] public class AreasController : ControllerBase { private readonly Application.Query.Interfaces.IWarehouseService _warehouseQueryService; // 库房信息查询服务 /// /// 依赖注入 /// public AreasController( Application.Query.Interfaces.IWarehouseService warehouseQueryService) { _warehouseQueryService = warehouseQueryService; } /// /// 获取库区列表 /// /// 成功 [HttpGet] [ProducesResponseType(200)] public async Task 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() }); } } } }