package com.fs.watch.controller;

import com.fs.common.core.domain.AjaxResult;
import com.fs.watch.domain.WatchSpo2Data;
import com.fs.watch.service.WatchSpo2DataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/watch/spo2/data")
public class WatchSpo2DataController {
    @Autowired
    private WatchSpo2DataService watchSpo2DataService;

    @PostMapping("/insert")
    public AjaxResult insertSpo2Data(@RequestBody WatchSpo2Data data){
        return AjaxResult.success(watchSpo2DataService.insert(data));
    }

    /**
     * 查询某天的数据
     * @param  date 日期
     * @param  deviceId 主键
     * @return 某天的数据
     */
    @GetMapping("/queryByDateAndDeviceId")
    public AjaxResult queryByDateAndDeviceId(@RequestParam(value = "date",required = false) String date,
                                             @RequestParam(value = "deviceId") String deviceId) {
        return AjaxResult.success(this.watchSpo2DataService.queryByDateAndDeviceIdAndState(date,deviceId));
    }
}
