package com.fs.watch.controller;

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

/**
 * 血糖
 */
@RestController
@RequestMapping("/watch/blood/glucose")
public class WatchBloodGlucoseDataController {

    @Autowired
    private WatchBloodGlucoseDataService watchBloodGlucoseDataService;

    @PostMapping("/insert")
    public AjaxResult insertBloodGlucoseData(@RequestBody WatchBloodGlucoseData data){
        return AjaxResult.success(watchBloodGlucoseDataService.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.watchBloodGlucoseDataService.queryByDateAndDeviceId(date,deviceId));
    }
}
