package com.inspect.metadata.montdata.controller;

import com.inspect.metadata.montdata.domain.BasedataMontTaskStaData;
import com.inspect.metadata.montdata.service.IBasedataMontTaskStaDataService;
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({"/taskstadata"})
public class BasedataMontTaskStaDataController extends BaseController {
    @Resource
    private IBasedataMontTaskStaDataService basedataMontTaskStaDataService;

    @RequiresPermissions({"basedata/montdata:taskstadata:list"})
    @GetMapping({"/list"})
    public TableDataInfo list(BasedataMontTaskStaData basedataMontTaskstadata) {
        this.startPage();
        List<BasedataMontTaskStaData> list = this.basedataMontTaskStaDataService.selectBasedataMontTaskStaDataList(basedataMontTaskstadata);
        return this.getDataTable(list);
    }

    @RequiresPermissions({"basedata/montdata:taskstadata:export"})
    @Log(
            title = "任务状态数据",
            businessType = BizType.EXPORT
    )
    @PostMapping({"/export"})
    public void export(HttpServletResponse response, BasedataMontTaskStaData basedataMontTaskstadata) {
        List<BasedataMontTaskStaData> list = this.basedataMontTaskStaDataService.selectBasedataMontTaskStaDataList(basedataMontTaskstadata);
        ExcelUtil<BasedataMontTaskStaData> util = new ExcelUtil<>(BasedataMontTaskStaData.class);
        util.exportExcel(response, list, "任务状态数据数据");
    }

    @RequiresPermissions({"basedata/montdata:taskstadata:query"})
    @GetMapping({"/{taskstadata_id}"})
    public AjaxResult getInfo(@PathVariable("taskstadata_id") Long taskStaDataId) {
        return AjaxResult.success(this.basedataMontTaskStaDataService.selectBasedataMontTaskStaDataByTaskStaDataId(taskStaDataId));
    }

    @RequiresPermissions({"basedata/montdata:taskstadata:add"})
    @Log(
            title = "任务状态数据",
            businessType = BizType.INSERT
    )
    @PostMapping
    public AjaxResult add(@RequestBody BasedataMontTaskStaData basedataMontTaskstadata) {
        return this.toAjax(this.basedataMontTaskStaDataService.insertBasedataMontTaskStaData(basedataMontTaskstadata));
    }

    @RequiresPermissions({"basedata/montdata:taskstadata:edit"})
    @Log(
            title = "任务状态数据",
            businessType = BizType.UPDATE
    )
    @PostMapping({"/edit"})
    public AjaxResult edit(@RequestBody BasedataMontTaskStaData basedataMontTaskstadata) {
        return this.toAjax(this.basedataMontTaskStaDataService.updateBasedataMontTaskStaData(basedataMontTaskstadata));
    }

    @RequiresPermissions({"basedata/montdata:taskstadata:remove"})
    @Log(
            title = "任务状态数据",
            businessType = BizType.DELETE
    )
    @PostMapping({"/remove/{taskstadata_ids}"})
    public AjaxResult remove(@PathVariable("taskstadata_ids") Long[] taskStaDataIds) {
        return this.toAjax(this.basedataMontTaskStaDataService.deleteBasedataMontTaskStaDataByTaskStaDataIds(taskStaDataIds));
    }
}
