package com.ruoyi.web.controller.business;

import com.ruoyi.business.domain.Temper;
import com.ruoyi.business.mapper.TemperMapper;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 温度控制器
 */
@Controller
@RequestMapping("/business/temper")
public class TemperController extends BaseController {

    @Autowired
    private TemperMapper temperMapper;

    /**
     * 获取温度
     * @return 获取的温度
     */
    @PostMapping("/getTemper")
    @ResponseBody
    public AjaxResult getTemper() {
        Temper queryRules = new Temper();
        queryRules.setRkId(1);
        List<Temper> tempers = temperMapper.selectTemperList(queryRules);
        if(tempers.isEmpty()) {
            return success("查询失败，请重试") ;
        }
        return success(tempers.get(0).getRkDegree());
    }

}
