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.

97 lines
2.8 KiB

using System.ComponentModel.DataAnnotations;
using Entity.DbModel.Station;
using Entity.Dto.Req;
using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc;
using Service.Station;
namespace WebStarter.Controllers;
/// <summary>
/// 换电异常原因配置
/// </summary>
[ApiController]
[Route("api/[controller]")]
public class SwapFailReasonConfigController
{
private readonly SwapFailReasonConfigService _swapFailReasonConfigService;
/// <summary>
/// 换电异常原因配置
/// </summary>
/// <param name="swapFailReasonConfig"></param>
public SwapFailReasonConfigController(SwapFailReasonConfigService swapFailReasonConfig)
{
_swapFailReasonConfigService = swapFailReasonConfig;
}
/// <summary>
/// 换电异常原因配置
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("page")]
public async Task<Result<PageResult<SwapFailReasonConfig>>> BatteryOpModelPageList(
[FromBody] PageSwapFailReasonConfigReq input)
{
return Result<PageResult<SwapFailReasonConfig>>.Success(await _swapFailReasonConfigService.Page(input));
}
/// <summary>
/// 获取异常原因列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("GetList")]
public async Task<Result<List<SwapFailReasonConfig>>> GetList()
{
return Result<List<SwapFailReasonConfig>>.Success(await _swapFailReasonConfigService.QueryAsync());
}
/// <summary>
/// 添加换电异常原因配置
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("add")]
public async Task<Result<string>> Add([FromBody] AddSwapFailReasonConfigReq input)
{
var data = await _swapFailReasonConfigService.Add(input);
return Result<string>.Success(data);
}
/// <summary>
/// 修改换电异常原因配置
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
[Route("update")]
public async Task<Result<bool>> Update([FromBody] UpdateSwapFailReasonConfigReq req)
{
var data = await _swapFailReasonConfigService.Update(req);
if (data)
return Result<bool>.Success(data);
else
return Result<bool>.Fail(data);
}
/// <summary>
/// 删除换电异常原因配置
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("delete")]
public async Task<Result<bool>> Delete([FromBody] [Required] DeleteSwapFailReasonConfigpReq input)
{
var data = await _swapFailReasonConfigService.Delete(input);
if (data)
return Result<bool>.Success(data);
else
return Result<bool>.Fail(data);
}
}