package com.inspect.metadata.statis.controller;

import com.inspect.metadata.statis.domain.BasedataStatisRobotUavOnlineDay;
import com.inspect.metadata.statis.service.IBasedataStatisRobotUavOnlineDayService;
import com.inspect.base.core.utils.poi.ExcelUtil;
import com.inspect.base.core.web.controller.BaseController;
import com.inspect.base.core.web.domain.AjaxResult;
import com.inspect.base.core.web.page.TableDataInfo;
import com.inspect.common.log.annotation.Log;
import com.inspect.common.log.enums.BizType;
import com.inspect.common.security.annotation.RequiresPermissions;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/statis/robotuavOnlineDay"})
public class BasedataStatisRobotUavOnlineDayController extends BaseController {
    @Resource
    private IBasedataStatisRobotUavOnlineDayService basedataStatisRobotUavOnlineDayService;

    @RequiresPermissions({"basedata/statis:robotuavOnlineDay:list"})
    @GetMapping({"/list"})
    public TableDataInfo list(BasedataStatisRobotUavOnlineDay basedataStatisRobotuavOnlineDay) {
        this.startPage();
        List<BasedataStatisRobotUavOnlineDay> list = this.basedataStatisRobotUavOnlineDayService.selectBasedataStatisRobotuavOnlineDayList(basedataStatisRobotuavOnlineDay);
        return this.getDataTable(list);
    }

    @RequiresPermissions({"basedata/statis:robotuavOnlineDay:export"})
    @Log(
            title = "机器人无人机在线时长统计",
            businessType = BizType.EXPORT
    )
    @PostMapping({"/export"})
    public void export(HttpServletResponse response, BasedataStatisRobotUavOnlineDay basedataStatisRobotuavOnlineDay) {
        List<BasedataStatisRobotUavOnlineDay> list = this.basedataStatisRobotUavOnlineDayService.selectBasedataStatisRobotuavOnlineDayList(basedataStatisRobotuavOnlineDay);
        ExcelUtil<BasedataStatisRobotUavOnlineDay> util = new ExcelUtil<>(BasedataStatisRobotUavOnlineDay.class);
        util.exportExcel(response, list, "机器人无人机在线时长统计数据");
    }

    @RequiresPermissions({"basedata/statis:robotuavOnlineDay:query"})
    @GetMapping({"/{robotuavOnlineStatId}"})
    public AjaxResult getInfo(@PathVariable("robotuavOnlineStatId") Long robotUavOnlineStatId) {
        return AjaxResult.success(this.basedataStatisRobotUavOnlineDayService.selectBasedataStatisRobotUavOnlineDayByRobotUavOnlineStatId(robotUavOnlineStatId));
    }

    @RequiresPermissions({"basedata/statis:robotuavOnlineDay:add"})
    @Log(
            title = "机器人无人机在线时长统计",
            businessType = BizType.INSERT
    )
    @PostMapping
    public AjaxResult add(@RequestBody BasedataStatisRobotUavOnlineDay basedataStatisRobotuavOnlineDay) {
        return this.toAjax(this.basedataStatisRobotUavOnlineDayService.insertBasedataStatisRobotUavOnlineDay(basedataStatisRobotuavOnlineDay));
    }

    @RequiresPermissions({"basedata/statis:robotuavOnlineDay:edit"})
    @Log(
            title = "机器人无人机在线时长统计",
            businessType = BizType.UPDATE
    )
    @PostMapping({"/edit"})
    public AjaxResult edit(@RequestBody BasedataStatisRobotUavOnlineDay basedataStatisRobotuavOnlineDay) {
        return this.toAjax(this.basedataStatisRobotUavOnlineDayService.updateBasedataStatisRobotUavOnlineDay(basedataStatisRobotuavOnlineDay));
    }

    @RequiresPermissions({"basedata/statis:robotuavOnlineDay:remove"})
    @Log(
            title = "机器人无人机在线时长统计",
            businessType = BizType.DELETE
    )
    @PostMapping({"/remove/{robotuavOnlineStatIds}"})
    public AjaxResult remove(@PathVariable("robotuavOnlineStatIds") Long[] robotUavOnlineStatIds) {
        return this.toAjax(this.basedataStatisRobotUavOnlineDayService.deleteBasedataStatisRobotUavOnlineDayByRobotUavOnlineStatIds(robotUavOnlineStatIds));
    }
}
