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.

68 lines
1.8 KiB

6 months ago
using AutoMapper;
using Entity.Api.Req;
using Entity.Api.Resp;
6 months ago
using Entity.DbModel.Station;
using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc;
6 months ago
using Service.Station;
namespace WebStarter.Controllers;
6 months ago
/// <summary>
/// 充电订单
/// </summary>
[ApiController]
[Route("api/[controller]")]
public class ChargeOrderController : ControllerBase
{
6 months ago
private readonly ChargeOrderService chargeOrderService;
6 months ago
public ChargeOrderController(ChargeOrderService chargeOrderService)
{
this.chargeOrderService = chargeOrderService;
}
/// <summary>
6 months ago
/// 查询分页数据
6 months ago
/// </summary>
/// <returns></returns>
[HttpPost("QueryPage")]
public async Task<Result<PageResult<ChargeOrderResp>>> QueryPage([FromBody] QueryChargeOrderReq req)
{
6 months ago
return Result<PageResult<ChargeOrderResp>>.Success(chargeOrderService.QueryChargeOrder(req));
6 months ago
}
/// <summary>
6 months ago
/// 修改充电订单
6 months ago
/// </summary>
6 months ago
/// <param name="req"></param>
6 months ago
/// <returns></returns>
6 months ago
[HttpPost("Modify")]
public async Task<Result<bool>> Modify([FromBody] ModifyChargeOrderReq req)
{
//映射数据
var config = new MapperConfiguration(cfg => cfg.CreateMap<ChargeOrder, ModifyChargeOrderReq>().ReverseMap());
IMapper mapper = config.CreateMapper();
ChargeOrder chargeOrder = mapper.Map<ChargeOrder>(req);
if (chargeOrderService.Update(chargeOrder))
{
6 months ago
return Result<bool>.Success("更改成功");
}
6 months ago
else
{
6 months ago
return Result<bool>.Fail("更改失败");
}
6 months ago
}
/// <summary>
/// 充电订单上报云端
/// </summary>
/// <returns></returns>
[HttpGet("UploadCloud/{id}")]
6 months ago
public async Task<Result<bool>> UploadCloud(int id)
6 months ago
{
6 months ago
return await chargeOrderService.Upload2Cloud(id);
6 months ago
}
}