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 ChargeOrderController : ControllerBase { private readonly ChargeOrderService chargeOrderService; public ChargeOrderController(ChargeOrderService chargeOrderService) { this.chargeOrderService = chargeOrderService; } /// /// 查询分页数据 /// /// [HttpPost("QueryPage")] public async Task>> QueryPage([FromBody] QueryChargeOrderReq req) { PageResult queryChargeOrder = chargeOrderService.QueryChargeOrder(req); return Result>.Success(queryChargeOrder); } /// /// 修改充电订单 /// /// /// [HttpPost("Modify")] public async Task> Modify([FromBody] ModifyChargeOrderReq req) { //映射数据 var config = new MapperConfiguration(cfg => cfg.CreateMap().ReverseMap()); IMapper mapper = config.CreateMapper(); ChargeOrder chargeOrder = mapper.Map(req); if (chargeOrderService.Update(chargeOrder)) { return Result.Success(true,"更改成功"); } else { return Result.Fail("更改失败"); } } /// /// 充电订单导出 /// /// /// [HttpPost] [Route("export")] public async Task ExportChargeOrder([FromBody] QueryChargeOrderReq req) { // 获取请求头中的语言信息 var language = Request.Headers["Accept-Language"].ToString().ToLower(); return await chargeOrderService.ExportChargeOrder(req,language); } }