package com.huimv.environ.eco.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.huimv.common.utils.Result;
import com.huimv.common.utils.ResultCode;
import com.huimv.environ.eco.entity.BaseRoom;
import com.huimv.environ.eco.service.IBaseRoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author astupidcoder
 * @since 2021-11-11
 */
@RestController
@RequestMapping("/room")
public class BaseRoomController {

    @Autowired
    private IBaseRoomService baseRoomService;

    @GetMapping("/getAllRoomEnvironment")
    private Result getAllRoomEnvironment(@RequestParam(name = "farmId") Integer farmId){
        return  baseRoomService.getAllRoomEnvironment(farmId);

    }

    @GetMapping("list")
    public Result list(@RequestParam(name = "farmId") Integer farmId){
        return new Result(ResultCode.SUCCESS,baseRoomService.list(new QueryWrapper<BaseRoom>().eq("farm_id",farmId)));
    }

    @PostMapping("/listByRoom")
    public Result listByRoom(@RequestBody Map<String, String> map){
        return  baseRoomService.listByRoom(map);
    }

    @GetMapping("/listBy")
    public Result listByRoom(@RequestParam(name = "uid") String uid){
        return new Result(ResultCode.SUCCESS,baseRoomService.list(new QueryWrapper<BaseRoom>().eq("box_id",uid)));
    }


    @GetMapping("/listLargeScreen")
    public Result listLargeScreen(@RequestParam(name = "farmId") String farmId){
        return baseRoomService.listLargeScreen(farmId);
    }

    @PostMapping("/listAllWaterEnvPowerApp")
    public Result listAllWaterEnvPowerApp(@RequestBody Map<String, String> map){
        return baseRoomService.listAllWaterEnvPowerApp(map);
    }


}
