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.
98 lines
3.4 KiB
98 lines
3.4 KiB
using Kean.Application.Command.ViewModels;
|
|
using Kean.Application.Query.ViewModels;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Kean.Presentation.Rest.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 仓库服务
|
|
/// </summary>
|
|
[ApiController, Route("api/warehouses")]
|
|
public class WarehousesController : ControllerBase
|
|
{
|
|
private readonly Application.Query.Interfaces.IWarehouseService _warehouseQueryService; // 仓库信息查询服务
|
|
private readonly Application.Command.Interfaces.ITaskService _taskCommandService; // 任务命令服务
|
|
|
|
/// <summary>
|
|
/// 依赖注入
|
|
/// </summary>
|
|
public WarehousesController(
|
|
Application.Query.Interfaces.IWarehouseService warehouseQueryService,
|
|
Application.Command.Interfaces.ITaskService taskCommandService)
|
|
{
|
|
_warehouseQueryService = warehouseQueryService;
|
|
_taskCommandService = taskCommandService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取仓库列表
|
|
/// </summary>
|
|
/// <response code="200">成功</response>
|
|
[HttpGet]
|
|
[ProducesResponseType(200)]
|
|
public async Task<IActionResult> GetList(
|
|
[FromQuery] string sort,
|
|
[FromQuery] int? offset,
|
|
[FromQuery] int? limit)
|
|
{
|
|
var items = await _warehouseQueryService.GetWarehouseList(sort, offset, limit);
|
|
if (offset.HasValue || limit.HasValue)
|
|
{
|
|
var total = await _warehouseQueryService.GetWarehouseCount();
|
|
return StatusCode(200, new { items, total });
|
|
}
|
|
else
|
|
{
|
|
return StatusCode(200, new { items, total = items.Count() });
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取应急站台列表
|
|
/// </summary>
|
|
/// <response code="200">成功</response>
|
|
[HttpGet("emergency")]
|
|
[ProducesResponseType(200)]
|
|
public async Task<IActionResult> GetEmergencyList(
|
|
[FromQuery] string stationCode,
|
|
[FromQuery] string stationModel,
|
|
[FromQuery] string inout)
|
|
{
|
|
var total = await _warehouseQueryService.GetEmergencyCount(stationCode, stationModel, inout);
|
|
|
|
var items = await _warehouseQueryService.GetEmergencyList(stationCode, stationModel, inout);
|
|
return StatusCode(200, new
|
|
{
|
|
items,
|
|
total = total
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改应急站台
|
|
/// </summary>
|
|
/// <response code="200">成功</response>
|
|
/// <response code="409">信息已存在</response>
|
|
/// <response code="410">信息已删除</response>
|
|
/// <response code="422">请求内容错误</response>
|
|
[HttpPut("emergency/{id}")]
|
|
[ProducesResponseType(200)]
|
|
[ProducesResponseType(409)]
|
|
[ProducesResponseType(410)]
|
|
[ProducesResponseType(422)]
|
|
public async Task<IActionResult> ModifyEmergency(string id, EmergencyStation emergencyStation, [FromMiddleware] int session)
|
|
{
|
|
Failure failure = await _taskCommandService.Emergency(id, emergencyStation.StationModel, session);
|
|
if (failure == null)
|
|
{
|
|
return StatusCode(201);
|
|
}
|
|
else
|
|
{
|
|
return StatusCode(422, failure);
|
|
}
|
|
}
|
|
}
|
|
}
|