package com.inspect.metadata.montdata.controller;

import com.inspect.metadata.montdata.domain.BasedataMontPatDevOnline;
import com.inspect.metadata.montdata.service.IBasedataMontPatDevOnlineService;
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({"/montdata/patdevonline"})
public class BasedataMontPatDevOnlineController extends BaseController {
    @Resource
    private IBasedataMontPatDevOnlineService basedataMontPatDevOnlineService;

    @RequiresPermissions({"basedata/montdata:patdevonline:list"})
    @GetMapping({"/list"})
    public TableDataInfo list(BasedataMontPatDevOnline basedataMontPatdevOnline) {
        this.startPage();
        List<BasedataMontPatDevOnline> list = this.basedataMontPatDevOnlineService.selectBasedataMontPatDevOnlineList(basedataMontPatdevOnline);
        return this.getDataTable(list);
    }

    @RequiresPermissions({"basedata/montdata:patdevonline:export"})
    @Log(
            title = "巡视设备在线离线状态别",
            businessType = BizType.EXPORT
    )
    @PostMapping({"/export"})
    public void export(HttpServletResponse response, BasedataMontPatDevOnline basedataMontPatdevOnline) {
        List<BasedataMontPatDevOnline> list = this.basedataMontPatDevOnlineService.selectBasedataMontPatDevOnlineList(basedataMontPatdevOnline);
        ExcelUtil<BasedataMontPatDevOnline> util = new ExcelUtil<>(BasedataMontPatDevOnline.class);
        util.exportExcel(response, list, "巡视设备在线离线状态别数据");
    }

    @RequiresPermissions({"basedata/montdata:patdevonline:query"})
    @GetMapping({"/{patdevOnlineId}"})
    public AjaxResult getInfo(@PathVariable("patdevOnlineId") Long patDevOnlineId) {
        return AjaxResult.success(this.basedataMontPatDevOnlineService.selectBasedataMontPatDevOnlineByPatDevOnlineId(patDevOnlineId));
    }

    @RequiresPermissions({"basedata/montdata:patdevonline:add"})
    @Log(
            title = "巡视设备在线离线状态别",
            businessType = BizType.INSERT
    )
    @PostMapping
    public AjaxResult add(@RequestBody BasedataMontPatDevOnline basedataMontPatdevOnline) {
        return this.toAjax(this.basedataMontPatDevOnlineService.insertBasedataMontPatDevOnline(basedataMontPatdevOnline));
    }

    @RequiresPermissions({"basedata/montdata:patdevonline:edit"})
    @Log(
            title = "巡视设备在线离线状态别",
            businessType = BizType.UPDATE
    )
    @PostMapping({"/edit"})
    public AjaxResult edit(@RequestBody BasedataMontPatDevOnline basedataMontPatdevOnline) {
        return this.toAjax(this.basedataMontPatDevOnlineService.updateBasedataMontPatDevOnline(basedataMontPatdevOnline));
    }

    @RequiresPermissions({"basedata/montdata:patdevonline:remove"})
    @Log(
            title = "巡视设备在线离线状态别",
            businessType = BizType.DELETE
    )
    @PostMapping({"/remove/{patdevOnlineIds}"})
    public AjaxResult remove(@PathVariable("patdevOnlineIds") Long[] patDevOnlineIds) {
        return this.toAjax(this.basedataMontPatDevOnlineService.deleteBasedataMontPatDevOnlineByPatDevOnlineIds(patDevOnlineIds));
    }
}
