using Microsoft.AspNetCore.Mvc;
using DOAN.Model.Dto;
using DOAN.Admin.WebApi.Filters;
using DOAN.Model.MES.dev;
using DOAN.Model.MES.dev.Dto;
using DOAN.Service.MES.dev.IService;
//创建时间:2024-12-30
namespace DOAN.Admin.WebApi.Controllers
{
///
/// 备品备件库位
///
[Verify]
[Route("mes/deviceManagement/Parts/DevicePartsStorageLocations")]
public class DevicePartsStorageLocationsController : BaseController
{
///
/// 备品备件库位接口
///
private readonly IDevicePartsStorageLocationsService _DevicePartsStorageLocationsService;
public DevicePartsStorageLocationsController(IDevicePartsStorageLocationsService DevicePartsStorageLocationsService)
{
_DevicePartsStorageLocationsService = DevicePartsStorageLocationsService;
}
///
/// 查询备品备件库位列表
///
///
///
[HttpGet("list")]
[ActionPermissionFilter(Permission = "deviceManagement:devicepartsstoragelocations:list")]
public IActionResult QueryDevicePartsStorageLocations([FromQuery] DevicePartsStorageLocationsQueryDto parm)
{
var response = _DevicePartsStorageLocationsService.GetList(parm);
return SUCCESS(response);
}
//TODO 查询备品备件库位编号
[HttpGet("list_location_code")]
public IActionResult QueryDevicePartsStorageLocationsLocationCode(string query)
{
var response = _DevicePartsStorageLocationsService.QueryDevicePartsStorageLocationsLocationCode(query);
return SUCCESS(response);
}
///
/// 查询备品备件库位详情
///
///
///
[HttpGet("{LocationId}")]
[ActionPermissionFilter(Permission = "deviceManagement:devicepartsstoragelocations:query")]
public IActionResult GetDevicePartsStorageLocations(int LocationId)
{
var response = _DevicePartsStorageLocationsService.GetInfo(LocationId);
var info = response.Adapt();
return SUCCESS(info);
}
///
/// 添加备品备件库位
///
///
[HttpPost]
[ActionPermissionFilter(Permission = "deviceManagement:devicepartsstoragelocations:add")]
[Log(Title = "备品备件库位", BusinessType = BusinessType.INSERT)]
public IActionResult AddDevicePartsStorageLocations([FromBody] DevicePartsStorageLocationsDto parm)
{
var modal = parm.Adapt().ToCreate(HttpContext);
var response = _DevicePartsStorageLocationsService.AddDevicePartsStorageLocations(modal);
return SUCCESS(response);
}
///
/// 更新备品备件库位
///
///
[HttpPut]
[ActionPermissionFilter(Permission = "deviceManagement:devicepartsstoragelocations:edit")]
[Log(Title = "备品备件库位", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateDevicePartsStorageLocations([FromBody] DevicePartsStorageLocationsDto parm)
{
var modal = parm.Adapt().ToUpdate(HttpContext);
var response = _DevicePartsStorageLocationsService.UpdateDevicePartsStorageLocations(modal);
return ToResponse(response);
}
///
/// 删除备品备件库位
///
///
[HttpDelete("{ids}")]
[ActionPermissionFilter(Permission = "deviceManagement:devicepartsstoragelocations:delete")]
[Log(Title = "备品备件库位", BusinessType = BusinessType.DELETE)]
public IActionResult DeleteDevicePartsStorageLocations(string ids)
{
int[] idsArr = Tools.SpitIntArrary(ids);
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
var response = _DevicePartsStorageLocationsService.Delete(idsArr);
return ToResponse(response);
}
}
}