package com.bcrjl.miwifi.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bcrjl.miwifi.common.response.BasePageList;
import com.bcrjl.miwifi.common.response.Query;
import com.bcrjl.miwifi.common.response.R;
import com.bcrjl.miwifi.common.util.Condition;
import com.bcrjl.miwifi.model.domain.DeviceDayTraffic;
import com.bcrjl.miwifi.model.param.DeviceDayTrafficParam;
import com.bcrjl.miwifi.service.DeviceDayTrafficService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 设备每日流量统计
 *
 * @author yanqs
 */
@RestController
@RequestMapping("/api/device/traffic")
public class DeviceDayTrafficController {

    @Resource
    private DeviceDayTrafficService deviceDayTrafficService;

    @PostMapping("/update")
    public R updateDeviceDayTraffic(@RequestBody DeviceDayTraffic deviceDayTraffic) {
        return R.data("");
    }

    @GetMapping("/list")
    public R list(DeviceDayTrafficParam param, Query query) {
        IPage<DeviceDayTraffic> deviceDayTrafficIPage = deviceDayTrafficService.pageList(Condition.getPage(query), param);
        return R.data(BasePageList.of(deviceDayTrafficIPage));
    }

    @GetMapping("test")
    public R test(){
        deviceDayTrafficService.writeEverydayDeviceTraffic();
        return R.success();
    }
}
