using AutoMapper;
using Entity.Api.Req;
using Entity.Api.Resp;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc;
using Service.Station;
namespace WebStarter.Controllers;
///
/// 换电订单
///
[ApiController]
[Route("api/[controller]")]
public class SwapOrderController : ControllerBase
{
private readonly SwapOrderService swapOrderService;
public SwapOrderController(SwapOrderService swapOrderService)
{
this.swapOrderService = swapOrderService;
}
///
/// 查询分页数据
///
///
[HttpPost("QueryPage")]
public async Task>> QueryPage([FromBody] QuerySwapOrderPageReq req)
{
return Result>.Success(swapOrderService.QuerySwapOrder(req));
}
///
/// 新增
///
///
[HttpPost("Add")]
public async Task> Add([FromBody] AddSwapOrderReq req)
{
//映射数据
var config = new MapperConfiguration(cfg => cfg.CreateMap().ReverseMap());
IMapper mapper = config.CreateMapper();
SwapOrder swapOrder = mapper.Map(req);
if (swapOrderService.Insert(swapOrder) != 0)
{
return Result.Success("新增成功");
}
else
{
return Result.Fail("新增失败");
}
}
///
/// 修改换电订单
///
///
///
[HttpPost("Modify")]
public async Task> Modify([FromBody] ModifySwapOrderReq req)
{
//映射数据
var config = new MapperConfiguration(cfg => cfg.CreateMap().ReverseMap());
IMapper mapper = config.CreateMapper();
SwapOrder swapOrder = mapper.Map(req);
if (swapOrderService.Update(swapOrder))
{
return Result.Success("更改成功");
}
else
{
return Result.Fail("更改失败");
}
}
///
/// 删除
///
/// ids id列表
///
[HttpPost("DeleteByIds")]
public async Task> DeleteByIds([FromBody] List ids)
{
if (swapOrderService.DeleteByIds(ids))
{
return Result.Success("删除成功");
}
else
{
return Result.Fail("删除失败");
}
}
///
/// 换电订单上报云端
///
///
[HttpGet("UploadCloud/{id}")]
public async Task> UploadCloud(long id)
{
return Result.Success(null);
}
}