|
|
|
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;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 换电订单
|
|
|
|
/// </summary>
|
|
|
|
[ApiController]
|
|
|
|
[Route("api/[controller]")]
|
|
|
|
public class SwapOrderController : ControllerBase
|
|
|
|
{
|
|
|
|
private readonly SwapOrderService swapOrderService;
|
|
|
|
|
|
|
|
public SwapOrderController(SwapOrderService swapOrderService)
|
|
|
|
{
|
|
|
|
this.swapOrderService = swapOrderService;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 查询分页数据
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("QueryPage")]
|
|
|
|
public async Task<Result<PageResult<SwapOrderResp>>> QueryPage([FromBody] QuerySwapOrderPageReq req)
|
|
|
|
{
|
|
|
|
|
|
|
|
return Result<PageResult<SwapOrderResp>>.Success(swapOrderService.QuerySwapOrder(req));
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 新增
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("Add")]
|
|
|
|
public async Task<Result<bool>> Add([FromBody] AddSwapOrderReq req)
|
|
|
|
{
|
|
|
|
//映射数据
|
|
|
|
var config = new MapperConfiguration(cfg => cfg.CreateMap<SwapOrder, ModifySwapOrderReq>().ReverseMap());
|
|
|
|
IMapper mapper = config.CreateMapper();
|
|
|
|
SwapOrder swapOrder = mapper.Map<SwapOrder>(req);
|
|
|
|
|
|
|
|
if (swapOrderService.Insert(swapOrder) != 0)
|
|
|
|
{
|
|
|
|
return Result<bool>.Success("新增成功");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return Result<bool>.Fail("新增失败");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 修改换电订单
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="req"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("Modify")]
|
|
|
|
public async Task<Result<bool>> Modify([FromBody] ModifySwapOrderReq req)
|
|
|
|
{
|
|
|
|
//映射数据
|
|
|
|
var config = new MapperConfiguration(cfg => cfg.CreateMap<SwapOrder, ModifySwapOrderReq>().ReverseMap());
|
|
|
|
IMapper mapper = config.CreateMapper();
|
|
|
|
SwapOrder swapOrder = mapper.Map<SwapOrder>(req);
|
|
|
|
|
|
|
|
if (swapOrderService.Update(swapOrder))
|
|
|
|
{
|
|
|
|
return Result<bool>.Success("更改成功");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return Result<bool>.Fail("更改失败");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 删除
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="ids">ids id列表</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("DeleteByIds")]
|
|
|
|
public async Task<Result<bool>> DeleteByIds([FromBody] List<long> ids)
|
|
|
|
{
|
|
|
|
if (swapOrderService.DeleteByIds(ids))
|
|
|
|
{
|
|
|
|
return Result<bool>.Success("删除成功");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return Result<bool>.Fail("删除失败");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 换电订单上报云端
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet("UploadCloud/{id}")]
|
|
|
|
public async Task<Result<bool>> UploadCloud(long id)
|
|
|
|
{
|
|
|
|
|
|
|
|
return Result<bool>.Success(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|