package com.ruoyi.project.plant.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.plant.domain.TTargetyardstick;
import com.ruoyi.project.plant.service.ITTargetyardstickService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 目标完成判定标准Controller
 *
 * @author ruoyi
 * @date 2021-08-16
 */
@RestController
@RequestMapping("/plant/targetyardstick")
public class TTargetyardstickController extends BaseController
{
    @Autowired
    private ITTargetyardstickService tTargetyardstickService;

    /**
     * 查询目标完成判定标准列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TTargetyardstick tTargetyardstick)
    {
        startPage();
        List<TTargetyardstick> list = tTargetyardstickService.selectTTargetyardstickList(tTargetyardstick);
        return getDataTable(list);
    }

    /**
     * 导出目标完成判定标准列表
     */
    @PreAuthorize("@ss.hasPermi('plant:targetyardstick:export')")
    @Log(title = "目标完成判定标准", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TTargetyardstick tTargetyardstick)
    {
        List<TTargetyardstick> list = tTargetyardstickService.selectTTargetyardstickList(tTargetyardstick);
        ExcelUtil<TTargetyardstick> util = new ExcelUtil<TTargetyardstick>(TTargetyardstick.class);
        return util.exportExcel(list, "targetyardstick");
    }

    /**
     * 获取目标完成判定标准详细信息
     */
    @PreAuthorize("@ss.hasPermi('plant:targetyardstick:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tTargetyardstickService.selectTTargetyardstickById(id));
    }

    /**
     * 新增目标完成判定标准
     */
    @PreAuthorize("@ss.hasPermi('plant:targetyardstick:add')")
    @Log(title = "目标完成判定标准", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TTargetyardstick tTargetyardstick)
    {
        return toAjax(tTargetyardstickService.insertTTargetyardstick(tTargetyardstick));
    }

    /**
     * 修改目标完成判定标准
     */
    @PreAuthorize("@ss.hasPermi('plant:targetyardstick:edit')")
    @Log(title = "目标完成判定标准", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TTargetyardstick tTargetyardstick)
    {
        return toAjax(tTargetyardstickService.updateTTargetyardstick(tTargetyardstick));
    }

    /**
     * 删除目标完成判定标准
     */
    @PreAuthorize("@ss.hasPermi('plant:targetyardstick:remove')")
    @Log(title = "目标完成判定标准", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tTargetyardstickService.deleteTTargetyardstickByIds(ids));
    }
}
