package com.ruoyi.project.plant.controller;

import java.util.List;

import com.ruoyi.project.plant.domain.*;
import com.ruoyi.project.plant.service.*;
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.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/targetaction")
public class TTargetactionController extends BaseController
{
    @Autowired
    private ITTargetactionService tTargetactionService;

    /**
     * 查询目标回顾行动项列表
     */
    @PreAuthorize("@ss.hasPermi('plant:targetaction:query')")
    @GetMapping("/list")
    public TableDataInfo list(TTargetaction tTargetaction)
    {
        startPage();
        List<TTargetaction> list = tTargetactionService.selectTTargetactionList(tTargetaction);
        return getDataTable(list);
    }

    /**
     * 导出目标回顾行动项列表
     */
    @PreAuthorize("@ss.hasPermi('plant:targetaction:export')")
    @Log(title = "目标回顾行动项", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TTargetaction tTargetaction)
    {
        List<TTargetaction> list = tTargetactionService.selectTTargetactionList(tTargetaction);
        ExcelUtil<TTargetaction> util = new ExcelUtil<TTargetaction>(TTargetaction.class);
        return util.exportExcel(list, "targetaction");
    }

    /**
     * 获取目标回顾行动项详细信息
     */
    @PreAuthorize("@ss.hasPermi('plant:targetaction:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tTargetactionService.selectTTargetactionById(id));
    }

    /**
     * 新增目标回顾行动项
     */
    @PreAuthorize("@ss.hasPermi('plant:targetaction:add')")
    @Log(title = "目标回顾行动项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TTargetaction tTargetaction)
    {
        return toAjax(tTargetactionService.insertTTargetaction(tTargetaction));
    }

    /**
     * 修改目标回顾行动项
     */
    @PreAuthorize("@ss.hasPermi('plant:targetaction:edit')")
    @Log(title = "目标回顾行动项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TTargetaction tTargetaction)
    {
        return toAjax(tTargetactionService.updateTTargetaction(tTargetaction));
    }

    /**
     * 删除目标回顾行动项
     */
    @PreAuthorize("@ss.hasPermi('plant:targetaction:remove')")
    @Log(title = "目标回顾行动项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tTargetactionService.deleteTTargetactionByIds(ids));
    }
}
