 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.IndoorEnvironmentEntity;
import com.huimv.management.service.IndoorEnvironmentService;
import com.huimv.common.utils.PageUtils;
import com.huimv.common.utils.R;



/**
 * 室内环境信息Controller
 *
 * @author yinhao
 *
 */
@Api(tags = "室内环境信息")
@RestController
@RequestMapping("management/indoorEnvironment")
public class IndoorEnvironmentController {
    @Autowired
    private IndoorEnvironmentService indoorEnvironmentService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = indoorEnvironmentService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		IndoorEnvironmentEntity indoorEnvironment = indoorEnvironmentService.getById(id);

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

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody IndoorEnvironmentEntity indoorEnvironment){
		indoorEnvironmentService.save(indoorEnvironment);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public R update(@RequestBody IndoorEnvironmentEntity indoorEnvironment){
		indoorEnvironmentService.updateById(indoorEnvironment);

        return R.ok();
    }

    /**
     * 删除
     */
    @GetMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		indoorEnvironmentService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
