86 lines
2.2 KiB
C#
86 lines
2.2 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using ZR.Admin.WebApi.Extensions;
|
|
using ZR.Model.mes.md;
|
|
using ZR.Service.mes.md.IService;
|
|
namespace ZR.Admin.WebApi.Controllers.mes.md
|
|
{
|
|
|
|
[Route("mes/md/device")]
|
|
public class MdDeviceController : BaseController
|
|
{
|
|
IMdDeviceService deviceService;
|
|
public MdDeviceController(IMdDeviceService deviceService)
|
|
{
|
|
this.deviceService = deviceService;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="pageNum"></param>
|
|
/// <param name="pageSize"></param>
|
|
/// <param name="deviceCode"></param>
|
|
/// <param name="deviceName"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("list")]
|
|
public IActionResult List(int pageNum, int pageSize, string deviceCode = "", string deviceName = "")
|
|
{
|
|
(int, List<MdDevice>) data = deviceService.GetAll(deviceCode, deviceName, pageNum, pageSize);
|
|
return ToResponse(new ApiResult(200, "success", data));
|
|
}
|
|
|
|
|
|
[HttpPost("addDevice")]
|
|
public IActionResult AddDevice([FromBody] MdDevice device)
|
|
{
|
|
if (device != null)
|
|
device.ToCreate(HttpContext);
|
|
int result = deviceService.AddDevice(device);
|
|
return SUCCESS(result);
|
|
}
|
|
|
|
[HttpPost("updateDevice")]
|
|
public IActionResult UpdateDevice([FromBody] MdDevice device)
|
|
{
|
|
if (device != null)
|
|
{
|
|
device.ToUpdate(HttpContext);
|
|
}
|
|
|
|
int result = deviceService.UpdateDevice(device);
|
|
return SUCCESS(result);
|
|
}
|
|
|
|
|
|
[HttpPost("delDevice")]
|
|
public IActionResult deleteWorkshop([FromBody] List<int> ids)
|
|
{
|
|
if (ids != null)
|
|
{
|
|
int result = deviceService.deleteDevice(ids.ToArray());
|
|
return ToResponse(result);
|
|
}
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
[HttpGet("getworkstationList")]
|
|
public IActionResult GetworkstationList()
|
|
{
|
|
List<MdWorkstation> workstations = deviceService.getworkstationList();
|
|
return SUCCESS(workstations);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|