package com.fs.watch.controller;

import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.watch.domain.WatchFatigueData;
import com.fs.watch.param.WatchDataQueryParam;
import com.fs.watch.service.WatchFatigueDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/watch/fatigue")
public class WatchFatigueDataController extends BaseController {
    @Autowired
    private WatchFatigueDataService watchFatigueDataService;

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

    /**
     * 查询某天的数据 分页
     * @param  param 查询参数
     * @return 查询某天的数据
     */
    @GetMapping("/page")
    public AjaxResult queryByDateAndDeviceId(WatchDataQueryParam param) {
        startPage();
        return AjaxResult.success(getDataTable(watchFatigueDataService.page(param)));
    }


}
