 package com.huimv.management.controller;

import java.util.Arrays;
import java.util.Map;

import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.huimv.management.entity.DeviceEntity;
import com.huimv.management.service.DeviceService;
import com.huimv.common.utils.PageUtils;
import com.huimv.common.utils.R;



/**
 * 慧牧环控设备
 *
 * @author yinhao
 * @version ${version}
 * @date 2021-07-05 10:42:14
 */
@Api(tags = "环控设备Controller")
@RestController
@RequestMapping("management/device")
public class DeviceController {
    @Autowired
    private DeviceService deviceService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = deviceService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{deviceId}")
    public R info(@PathVariable("deviceId") String deviceId){
		DeviceEntity device = deviceService.getById(deviceId);

        return R.ok().put("device", device);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody DeviceEntity device){
		deviceService.save(device);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody DeviceEntity device){
		deviceService.updateById(device);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody String[] deviceIds){
		deviceService.removeByIds(Arrays.asList(deviceIds));

        return R.ok();
    }

}
