package com.inspect.metadata.montdata.controller;

import com.inspect.metadata.montdata.domain.BasedataMontPatDevAlmAbn;
import com.inspect.metadata.montdata.service.IBasedataMontPatDevAlmAbnService;
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/patdevalmabn"})
public class BasedataMontPatDevAlmAbnController extends BaseController {
    @Resource
    private IBasedataMontPatDevAlmAbnService basedataMontPatDevAlmAbnService;

    @RequiresPermissions({"basedata/montdata:patdevalmabn:list"})
    @GetMapping({"/list"})
    public TableDataInfo list(BasedataMontPatDevAlmAbn basedataMontPatdevalmabn) {
        this.startPage();
        List<BasedataMontPatDevAlmAbn> list = this.basedataMontPatDevAlmAbnService.selectBasedataMontPatDevAlmAbnList(basedataMontPatdevalmabn);
        return this.getDataTable(list);
    }

    @RequiresPermissions({"basedata/montdata:patdevalmabn:export"})
    @Log(title = "巡视设备异常告警", businessType = BizType.EXPORT)
    @PostMapping({"/export"})
    public void export(HttpServletResponse response, BasedataMontPatDevAlmAbn basedataMontPatdevalmabn) {
        List<BasedataMontPatDevAlmAbn> list = this.basedataMontPatDevAlmAbnService.selectBasedataMontPatDevAlmAbnList(basedataMontPatdevalmabn);
        ExcelUtil<BasedataMontPatDevAlmAbn> util = new ExcelUtil<>(BasedataMontPatDevAlmAbn.class);
        util.exportExcel(response, list, "巡视设备异常告警数据");
    }

    @RequiresPermissions({"basedata/montdata:patdevalmabn:query"})
    @GetMapping({"/{mont_patdevalmabn_id}"})
    public AjaxResult getInfo(@PathVariable("mont_patdevalmabn_id") Long montPatDevAlmAbnId) {
        return AjaxResult.success(this.basedataMontPatDevAlmAbnService.selectBasedataMontPatDevAlmAbnByMontPatDevAlmAbnId(montPatDevAlmAbnId));
    }

    @RequiresPermissions({"basedata/montdata:patdevalmabn:add"})
    @Log(title = "巡视设备异常告警", businessType = BizType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasedataMontPatDevAlmAbn basedataMontPatdevalmabn) {
        return this.toAjax(this.basedataMontPatDevAlmAbnService.insertBasedataMontPatDevAlmAbn(basedataMontPatdevalmabn));
    }

    @RequiresPermissions({"basedata/montdata:patdevalmabn:edit"})
    @Log(title = "巡视设备异常告警", businessType = BizType.UPDATE)
    @PostMapping({"/edit"})
    public AjaxResult edit(@RequestBody BasedataMontPatDevAlmAbn basedataMontPatdevalmabn) {
        return this.toAjax(this.basedataMontPatDevAlmAbnService.updateBasedataMontPatDevAlmAbn(basedataMontPatdevalmabn));
    }

    @RequiresPermissions({"basedata/montdata:patdevalmabn:remove"})
    @Log(title = "巡视设备异常告警", businessType = BizType.DELETE)
    @PostMapping({"/remove/{mont_patdevalmabn_ids}"})
    public AjaxResult remove(@PathVariable("mont_patdevalmabn_ids") Long[] montPatDevAlmAbnIds) {
        return this.toAjax(this.basedataMontPatDevAlmAbnService.deleteBasedataMontPatDevAlmAbnByMontPatDevAlmAbnIds(montPatDevAlmAbnIds));
    }
}
