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.

113 lines
3.4 KiB

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 EquipAlarmLevelController : ControllerBase
{
private readonly EquipAlarmLevelService equipAlarmLevelService;
public EquipAlarmLevelController(EquipAlarmLevelService equipAlarmLevelService)
{
this.equipAlarmLevelService = equipAlarmLevelService;
}
/// <summary>
/// 查询故障等级信息
/// </summary>
/// <param name="eqmFaultLevelReq"> 查询参数</param>
/// <returns></returns>
[HttpPost]
[Route("QueryEquipAlarmLevel")]
public Result<PageResult<EquipAlarmLevelResp>> QueryEquipAlarmLevel(
[FromBody] QueryEquipAlarmLevelReq eqmFaultLevelReq)
{
return Result<PageResult<EquipAlarmLevelResp>>.Success(
equipAlarmLevelService.QueryEqmFaultInfo(eqmFaultLevelReq));
}
/// <summary>
/// 添加故障等级信息
/// </summary>
/// <param name="eqmFaultLevelReq"> 添加参数</param>
/// <returns></returns>
[HttpPost]
[Route("AddEquipAlarmLevel")]
public Result<bool> AddEquipAlarmLevel([FromBody] AddEquipAlarmLevelReq eqmFaultLevelReq)
{
//映射数据
var config =
new MapperConfiguration(cfg => cfg.CreateMap<EquipAlarmLevel, AddEquipAlarmLevelReq>().ReverseMap());
IMapper mapper = config.CreateMapper();
EquipAlarmLevel baseEqmFaultLevel = mapper.Map<EquipAlarmLevel>(eqmFaultLevelReq);
//TODO Id换成等级字段
var eqmFaultLevel = equipAlarmLevelService.QueryByClause(u => u.Id == eqmFaultLevelReq.Id);
if (eqmFaultLevel != null)
{
return Result<bool>.Fail("插入失败!已有改等级信息");
}
else
{
equipAlarmLevelService.Insert(baseEqmFaultLevel);
// 更改
7 months ago
return Result<bool>.Success(true, "插入成功");
}
}
/// <summary>
/// 更改故障等级信息
/// </summary>
/// <param name="eqmFaultLevelReq">更改信息 </param>
/// <returns></returns>
[HttpPost]
[Route("ModifyEquipAlarmLevel")]
public Result<bool> ModifyEquipAlarmLevel([FromBody] ModifyEquipAlarmLevelReq eqmFaultLevelReq)
{
var config =
new MapperConfiguration(cfg => cfg.CreateMap<EquipAlarmLevel, ModifyEquipAlarmLevelReq>().ReverseMap());
IMapper mapper = config.CreateMapper();
EquipAlarmLevel baseEqmFaultLevel = mapper.Map<EquipAlarmLevel>(eqmFaultLevelReq);
if (equipAlarmLevelService.Update(baseEqmFaultLevel))
{
7 months ago
return Result<bool>.Success(true,"更改成功");
}
else
{
return Result<bool>.Fail("更改失败");
}
}
/// <summary>
/// 删除故障等级信息
/// </summary>
/// <param name="ids">自增id数组</param>
/// <returns></returns>
[HttpPost]
[Route("RemoveEquipAlarmLevel")]
public Result<bool> RemoveEquipAlarmLevel([FromBody] int[] ids)
{
if (equipAlarmLevelService.DeleteByIds(ids))
{
7 months ago
return Result<bool>.Success(true,"删除成功");
}
else
{
return Result<bool>.Fail("删除失败");
}
}
7 months ago
}