12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using Microsoft.AspNetCore.Mvc;
- using System;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using IMCS.CCS.Services;
- using IMCS.CCS.Entitys;
- namespace IMCS.CCS.Controllers
- {
- [ApiController]
- [Route("api/[controller]")]
- public class DeviceController : ControllerBase
- {
- private readonly IDeviceService _deviceService;
- public DeviceController(IDeviceService deviceService)
- {
- _deviceService = deviceService;
- }
- [HttpGet("GetDeviceList")]
- public List<Device> GetDeviceList()
- {
- return _deviceService.GetDeviceList();
- }
- /// <summary>
- /// 获取设备详情:GET: api/Device/5
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("{id}")]
- public async Task<ActionResult<Device>> GetDevice(int id)
- {
- var result = await _deviceService.GetDeviceById(id);
- if (result == null)
- {
- //return NotFound();
- }
- return result;
- }
- /// <summary>
- /// 修改设备信息:PUT: api/Users/5
- /// </summary>
- /// <param name="device"></param>
- /// <returns></returns>
- [HttpPut]
- public async Task<ActionResult<bool>> PutDevice(Device device)
- {
- return await _deviceService.UpdateDevice(device);
- }
- /// <summary>
- /// 新增设备:POST: api/Devices
- /// </summary>
- /// <param name="device"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<ActionResult<bool>> PostDevice(Device device)
- {
- return await _deviceService.CreateDevice(device);
- }
- }
- }
|