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.
118 lines
3.5 KiB
118 lines
3.5 KiB
7 months ago
|
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
|
||
|
{
|
||
|
// 更改
|
||
|
if (equipAlarmLevelService.Insert(baseEqmFaultLevel) != 0)
|
||
|
{
|
||
|
return Result<bool>.Success("插入成功");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return Result<bool>.Fail("插入失败");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <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))
|
||
|
{
|
||
|
return Result<bool>.Success("更改成功");
|
||
|
}
|
||
|
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))
|
||
|
{
|
||
|
return Result<bool>.Success("删除成功");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return Result<bool>.Fail("删除失败");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|