package com.inspect.metadata.montdata.controller;

import com.inspect.metadata.montdata.domain.BasedataMontTaskResult;
import com.inspect.metadata.montdata.service.IBasedataMontTaskResultService;
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({"/taskresult"})
public class BasedataMontTaskResultController extends BaseController {
    @Resource
    private IBasedataMontTaskResultService basedataMontTaskResultService;

    @RequiresPermissions({"basedata/montdata:taskresult:list"})
    @GetMapping({"/list"})
    public TableDataInfo list(BasedataMontTaskResult basedataMontTaskresult) {
        this.startPage();
        List<BasedataMontTaskResult> list = this.basedataMontTaskResultService.selectBasedataMontTaskResultList(basedataMontTaskresult);
        return this.getDataTable(list);
    }

    @RequiresPermissions({"basedata/montdata:taskresult:export"})
    @Log(
            title = "巡视结果",
            businessType = BizType.EXPORT
    )
    @PostMapping({"/export"})
    public void export(HttpServletResponse response, BasedataMontTaskResult basedataMontTaskresult) {
        List<BasedataMontTaskResult> list = this.basedataMontTaskResultService.selectBasedataMontTaskResultList(basedataMontTaskresult);
        ExcelUtil<BasedataMontTaskResult> util = new ExcelUtil<>(BasedataMontTaskResult.class);
        util.exportExcel(response, list, "巡视结果数据");
    }

    @RequiresPermissions({"basedata/montdata:taskresult:query"})
    @GetMapping({"/{taskresult_id}"})
    public AjaxResult getInfo(@PathVariable("taskresult_id") Long taskResultId) {
        return AjaxResult.success(this.basedataMontTaskResultService.selectBasedataMontTaskResultByTaskResultId(taskResultId));
    }

    @RequiresPermissions({"basedata/montdata:taskresult:add"})
    @Log(
            title = "巡视结果",
            businessType = BizType.INSERT
    )
    @PostMapping
    public AjaxResult add(@RequestBody BasedataMontTaskResult basedataMontTaskresult) {
        return this.toAjax(this.basedataMontTaskResultService.insertBasedataMontTaskResult(basedataMontTaskresult));
    }

    @RequiresPermissions({"basedata/montdata:taskresult:edit"})
    @Log(
            title = "巡视结果",
            businessType = BizType.UPDATE
    )
    @PostMapping({"/edit"})
    public AjaxResult edit(@RequestBody BasedataMontTaskResult basedataMontTaskresult) {
        return this.toAjax(this.basedataMontTaskResultService.updateBasedataMontTaskResult(basedataMontTaskresult));
    }

    @RequiresPermissions({"basedata/montdata:taskresult:remove"})
    @Log(
            title = "巡视结果",
            businessType = BizType.DELETE
    )
    @PostMapping({"/remove/{taskresult_ids}"})
    public AjaxResult remove(@PathVariable("taskresult_ids") Long[] taskResultIds) {
        return this.toAjax(this.basedataMontTaskResultService.deleteBasedataMontTaskResultByTaskResultIds(taskResultIds));
    }
}
