using Infrastructure;
using Infrastructure.Attribute;
using Infrastructure.Controllers;
using Infrastructure.Enums;
using Infrastructure.Model;
using Mapster;
using MDM.Model.Plant;
using MDM.Model.Plant.Dto;
using MDM.Services.IPlantService;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using RIZO.Admin.WebApi.Filters;
using RIZO.Common;
using RIZO.ServiceCore.Middleware;
//创建时间:2025-11-15
namespace MDM.Controllers.Plant
{
///
/// PLC点位
///
[Verify]
[Route("MasterDataManagement/Plant/PlantPlcIoPoint")]
public class PlantPlcIoPointController : BaseController
{
///
/// PLC点位接口
///
private readonly IPlantPlcIoPointService _PlantPlcIoPointService;
public PlantPlcIoPointController(IPlantPlcIoPointService PlantPlcIoPointService)
{
_PlantPlcIoPointService = PlantPlcIoPointService;
}
///
/// 查询PLC点位列表
///
///
///
[HttpGet("list")]
[ActionPermissionFilter(Permission = "business:plantplciopoint:list")]
public IActionResult QueryPlantPlcIoPoint([FromQuery] PlantPlcIoPointQueryDto parm)
{
var response = _PlantPlcIoPointService.GetList(parm);
return SUCCESS(response);
}
///
/// 查询PLC点位详情
///
///
///
[HttpGet("{Id}")]
[ActionPermissionFilter(Permission = "business:plantplciopoint:query")]
public IActionResult GetPlantPlcIoPoint(int Id)
{
var response = _PlantPlcIoPointService.GetInfo(Id);
var info = response.Adapt();
return SUCCESS(info);
}
///
/// 添加PLC点位
///
///
[HttpPost]
[ActionPermissionFilter(Permission = "business:plantplciopoint:add")]
[Log(Title = "PLC点位", BusinessType = BusinessType.INSERT)]
public IActionResult AddPlantPlcIoPoint([FromBody] PlantPlcIoPointDto parm)
{
var modal = parm.Adapt().ToCreate(HttpContext);
var response = _PlantPlcIoPointService.AddPlantPlcIoPoint(modal);
return SUCCESS(response);
}
///
/// 更新PLC点位
///
///
[HttpPut]
[ActionPermissionFilter(Permission = "business:plantplciopoint:edit")]
[Log(Title = "PLC点位", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdatePlantPlcIoPoint([FromBody] PlantPlcIoPointDto parm)
{
var modal = parm.Adapt().ToUpdate(HttpContext);
var response = _PlantPlcIoPointService.UpdatePlantPlcIoPoint(modal);
return ToResponse(response);
}
///
/// 删除PLC点位
///
///
[HttpDelete("{ids}")]
[ActionPermissionFilter(Permission = "business:plantplciopoint:delete")]
[Log(Title = "PLC点位", BusinessType = BusinessType.DELETE)]
public IActionResult DeletePlantPlcIoPoint(string ids)
{
int[] idsArr = Tools.SpitIntArrary(ids);
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
var response = _PlantPlcIoPointService.Delete(idsArr);
return ToResponse(response);
}
}
}