package com.inspect.metadata.statis.controller;

import com.inspect.metadata.statis.domain.BasedataStatisNvr;
import com.inspect.metadata.statis.service.IBasedataStatisNvrService;
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/statisnvr"})
public class BasedataStatisNvrController extends BaseController {
    @Resource
    private IBasedataStatisNvrService basedataStatisNvrService;

    @RequiresPermissions({"basedata/statis:statisnvr:list"})
    @GetMapping({"/list"})
    public TableDataInfo list(BasedataStatisNvr basedataStatisNvr) {
        this.startPage();
        List<BasedataStatisNvr> list = this.basedataStatisNvrService.selectBasedataStatisNvrList(basedataStatisNvr);
        return this.getDataTable(list);
    }

    @RequiresPermissions({"basedata/statis:statisnvr:export"})
    @Log(
            title = "基础数据-硬盘录像机统计",
            businessType = BizType.EXPORT
    )
    @PostMapping({"/export"})
    public void export(HttpServletResponse response, BasedataStatisNvr basedataStatisNvr) {
        List<BasedataStatisNvr> list = this.basedataStatisNvrService.selectBasedataStatisNvrList(basedataStatisNvr);
        ExcelUtil<BasedataStatisNvr> util = new ExcelUtil<>(BasedataStatisNvr.class);
        util.exportExcel(response, list, "基础数据-硬盘录像机统计数据");
    }

    @RequiresPermissions({"basedata/statis:statisnvr:query"})
    @GetMapping({"/{statisNvrId}"})
    public AjaxResult getInfo(@PathVariable("statisNvrId") Long statisNvrId) {
        return AjaxResult.success(this.basedataStatisNvrService.selectBasedataStatisNvrByStatisNvrId(statisNvrId));
    }

    @RequiresPermissions({"basedata/statis:statisnvr:add"})
    @Log(
            title = "基础数据-硬盘录像机统计",
            businessType = BizType.INSERT
    )
    @PostMapping
    public AjaxResult add(@RequestBody BasedataStatisNvr basedataStatisNvr) {
        return this.toAjax(this.basedataStatisNvrService.insertBasedataStatisNvr(basedataStatisNvr));
    }

    @RequiresPermissions({"basedata/statis:statisnvr:edit"})
    @Log(
            title = "基础数据-硬盘录像机统计",
            businessType = BizType.UPDATE
    )
    @PostMapping({"/edit"})
    public AjaxResult edit(@RequestBody BasedataStatisNvr basedataStatisNvr) {
        return this.toAjax(this.basedataStatisNvrService.updateBasedataStatisNvr(basedataStatisNvr));
    }

    @RequiresPermissions({"basedata/statis:statisnvr:remove"})
    @Log(
            title = "基础数据-硬盘录像机统计",
            businessType = BizType.DELETE
    )
    @PostMapping({"/remove/{statisNvrIds}"})
    public AjaxResult remove(@PathVariable Long[] statisNvrIds) {
        return this.toAjax(this.basedataStatisNvrService.deleteBasedataStatisNvrByStatisNvrIds(statisNvrIds));
    }
}
