package com.inspect.metadata.montdata.controller;

import com.inspect.metadata.montdata.domain.BasedataMontNestStaData;
import com.inspect.metadata.montdata.service.IBasedataMontNestStaDataService;
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/neststadata"})
public class BasedataMontNestStaDataController extends BaseController {
    @Resource
    private IBasedataMontNestStaDataService basedataMontNestStaDataService;

    @RequiresPermissions({"basedata/montdata:neststadata:list"})
    @GetMapping({"/list"})
    public TableDataInfo list(BasedataMontNestStaData basedataMontNeststadata) {
        this.startPage();
        List<BasedataMontNestStaData> list = this.basedataMontNestStaDataService.selectBasedataMontNestStaDataList(basedataMontNeststadata);
        return this.getDataTable(list);
    }

    @RequiresPermissions({"basedata/montdata:neststadata:export"})
    @Log(
            title = "机巢状态数据",
            businessType = BizType.EXPORT
    )
    @PostMapping({"/export"})
    public void export(HttpServletResponse response, BasedataMontNestStaData basedataMontNeststadata) {
        List<BasedataMontNestStaData> list = this.basedataMontNestStaDataService.selectBasedataMontNestStaDataList(basedataMontNeststadata);
        ExcelUtil<BasedataMontNestStaData> util = new ExcelUtil<>(BasedataMontNestStaData.class);
        util.exportExcel(response, list, "机巢状态数据数据");
    }

    @RequiresPermissions({"basedata/montdata:neststadata:query"})
    @GetMapping({"/{mont_neststadata_id}"})
    public AjaxResult getInfo(@PathVariable("mont_neststadata_id") Long montNestStaDataId) {
        return AjaxResult.success(this.basedataMontNestStaDataService.selectBasedataMontNestStaDataByMontNestStaDataId(montNestStaDataId));
    }

    @RequiresPermissions({"basedata/montdata:neststadata:add"})
    @Log(
            title = "机巢状态数据",
            businessType = BizType.INSERT
    )
    @PostMapping
    public AjaxResult add(@RequestBody BasedataMontNestStaData basedataMontNeststadata) {
        return this.toAjax(this.basedataMontNestStaDataService.insertBasedataMontNestStaData(basedataMontNeststadata));
    }

    @RequiresPermissions({"basedata/montdata:neststadata:edit"})
    @Log(
            title = "机巢状态数据",
            businessType = BizType.UPDATE
    )
    @PostMapping({"/edit"})
    public AjaxResult edit(@RequestBody BasedataMontNestStaData basedataMontNeststadata) {
        return this.toAjax(this.basedataMontNestStaDataService.updateBasedataMontNestStaData(basedataMontNeststadata));
    }

    @RequiresPermissions({"basedata/montdata:neststadata:remove"})
    @Log(
            title = "机巢状态数据",
            businessType = BizType.DELETE
    )
    @PostMapping({"/remove/{mont_neststadata_ids}"})
    public AjaxResult remove(@PathVariable("mont_neststadata_ids") Long[] montNestStaDataIds) {
        return this.toAjax(this.basedataMontNestStaDataService.deleteBasedataMontNestStaDataByMontNestStaDataIds(montNestStaDataIds));
    }
}
