package com.inspect.metadata.montdata.controller;

import com.inspect.metadata.montdata.domain.BasedataMontPatDevRunData;
import com.inspect.metadata.montdata.service.IBasedataMontPatDevRunDataService;
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/patdevrundata"})
public class BasedataMontPatDevRunDataController extends BaseController {
    @Resource
    private IBasedataMontPatDevRunDataService basedataMontPatDevRunDataService;

    @RequiresPermissions({"basedata/montdata:patdevrundata:list"})
    @GetMapping({"/list"})
    public TableDataInfo list(BasedataMontPatDevRunData basedataMontPatdevrundata) {
        this.startPage();
        List<BasedataMontPatDevRunData> list = this.basedataMontPatDevRunDataService.selectBasedataMontPatDevRunDataList(basedataMontPatdevrundata);
        return this.getDataTable(list);
    }

    @RequiresPermissions({"basedata/montdata:patdevrundata:export"})
    @Log(
            title = "巡视设备运行数据",
            businessType = BizType.EXPORT
    )
    @PostMapping({"/export"})
    public void export(HttpServletResponse response, BasedataMontPatDevRunData basedataMontPatdevrundata) {
        List<BasedataMontPatDevRunData> list = this.basedataMontPatDevRunDataService.selectBasedataMontPatDevRunDataList(basedataMontPatdevrundata);
        ExcelUtil<BasedataMontPatDevRunData> util = new ExcelUtil<>(BasedataMontPatDevRunData.class);
        util.exportExcel(response, list, "巡视设备运行数据数据");
    }

    @RequiresPermissions({"basedata/montdata:patdevrundata:query"})
    @GetMapping({"/{mont_patdevrundata_id}"})
    public AjaxResult getInfo(@PathVariable("mont_patdevrundata_id") Long montPatDevRunDataId) {
        return AjaxResult.success(this.basedataMontPatDevRunDataService.selectBasedataMontPatDevRunDataByMontPatDevRunDataId(montPatDevRunDataId));
    }

    @RequiresPermissions({"basedata/montdata:patdevrundata:add"})
    @Log(
            title = "巡视设备运行数据",
            businessType = BizType.INSERT
    )
    @PostMapping
    public AjaxResult add(@RequestBody BasedataMontPatDevRunData basedataMontPatdevrundata) {
        return this.toAjax(this.basedataMontPatDevRunDataService.insertBasedataMontPatDevRunData(basedataMontPatdevrundata));
    }

    @RequiresPermissions({"basedata/montdata:patdevrundata:edit"})
    @Log(
            title = "巡视设备运行数据",
            businessType = BizType.UPDATE
    )
    @PostMapping({"/edit"})
    public AjaxResult edit(@RequestBody BasedataMontPatDevRunData basedataMontPatdevrundata) {
        return this.toAjax(this.basedataMontPatDevRunDataService.updateBasedataMontPatDevRunData(basedataMontPatdevrundata));
    }

    @RequiresPermissions({"basedata/montdata:patdevrundata:remove"})
    @Log(
            title = "巡视设备运行数据",
            businessType = BizType.DELETE
    )
    @PostMapping({"/remove/{mont_patdevrundata_ids}"})
    public AjaxResult remove(@PathVariable("mont_patdevrundata_ids") Long[] montPatDevRunDataIds) {
        return this.toAjax(this.basedataMontPatDevRunDataService.deleteBasedataMontPatDevRunDataByMontPatDevRunDataIds(montPatDevRunDataIds));
    }
}
