package com.inspect.metadata.montdata.controller;

import com.inspect.metadata.montdata.domain.BasedataMontEvnData;
import com.inspect.metadata.montdata.service.IBasedataMontEvnDataService;
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 java.util.Map;
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/evndata"})
public class BasedataMontEvnDataController extends BaseController {
    @Resource
    private IBasedataMontEvnDataService basedataMontEvnDataService;

    @RequiresPermissions({"basedata/montdata:evndata:list"})
    @GetMapping({"/list"})
    public TableDataInfo list(BasedataMontEvnData basedataMontEvndata) {
        this.startPage();
        List<BasedataMontEvnData> list = this.basedataMontEvnDataService.selectBasedataMontEvnDataList(basedataMontEvndata);
        return this.getDataTable(list);
    }

    @RequiresPermissions({"basedata/montdata:evndata:export"})
    @Log(
            title = "环境数据",
            businessType = BizType.EXPORT
    )
    @PostMapping({"/export"})
    public void export(HttpServletResponse response, BasedataMontEvnData basedataMontEvndata) {
        List<BasedataMontEvnData> list = this.basedataMontEvnDataService.selectBasedataMontEvnDataList(basedataMontEvndata);
        ExcelUtil<BasedataMontEvnData> util = new ExcelUtil<>(BasedataMontEvnData.class);
        util.exportExcel(response, list, "环境数据数据");
    }

    @RequiresPermissions({"basedata/montdata:evndata:query"})
    @GetMapping({"/{mont_evndata_id}"})
    public AjaxResult getInfo(@PathVariable("mont_evndata_id") Long montEvnDataId) {
        return AjaxResult.success(this.basedataMontEvnDataService.selectBasedataMontEvnDataByMontEvnDataId(montEvnDataId));
    }

    @RequiresPermissions({"basedata/montdata:evndata:add"})
    @Log(
            title = "环境数据",
            businessType = BizType.INSERT
    )
    @PostMapping
    public AjaxResult add(@RequestBody BasedataMontEvnData basedataMontEvndata) {
        return this.toAjax(this.basedataMontEvnDataService.insertBasedataMontEvnData(basedataMontEvndata));
    }

    @RequiresPermissions({"basedata/montdata:evndata:edit"})
    @Log(
            title = "环境数据",
            businessType = BizType.UPDATE
    )
    @PostMapping({"/edit"})
    public AjaxResult edit(@RequestBody BasedataMontEvnData basedataMontEvndata) {
        return this.toAjax(this.basedataMontEvnDataService.updateBasedataMontEvnData(basedataMontEvndata));
    }

    @RequiresPermissions({"basedata/montdata:evndata:remove"})
    @Log(
            title = "环境数据",
            businessType = BizType.DELETE
    )
    @PostMapping({"/remove/{mont_evndata_ids}"})
    public AjaxResult remove(@PathVariable("mont_evndata_ids") Long[] montEvnDataIds) {
        return this.toAjax(this.basedataMontEvnDataService.deleteBasedataMontEvnDataByMontEvnDataIds(montEvnDataIds));
    }

    @GetMapping({"/evnList"})
    public AjaxResult evnList() {
        List<BasedataMontEvnData> list = this.basedataMontEvnDataService.evnList();
        return AjaxResult.success(list);
    }
}
