package com.ruoyi.project.ehs.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.ehs.domain.TMatterFeature;
import com.ruoyi.project.ehs.service.ITMatterFeatureService;
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-09-22
 */
@RestController
@RequestMapping("/ehs/feature")
public class TMatterFeatureController extends BaseController
{
    @Autowired
    private ITMatterFeatureService tMatterFeatureService;

    /**
     * 查询危害物质关联危险类型列表
     */
    @PreAuthorize("@ss.hasPermi('ehs:feature:list')")
    @GetMapping("/list")
    public TableDataInfo list(TMatterFeature tMatterFeature)
    {
        startPage();
        List<TMatterFeature> list = tMatterFeatureService.selectTMatterFeatureList(tMatterFeature);
        return getDataTable(list);
    }

    /**
     * 导出危害物质关联危险类型列表
     */
    @PreAuthorize("@ss.hasPermi('ehs:feature:export')")
    @Log(title = "危害物质关联危险类型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TMatterFeature tMatterFeature)
    {
        List<TMatterFeature> list = tMatterFeatureService.selectTMatterFeatureList(tMatterFeature);
        ExcelUtil<TMatterFeature> util = new ExcelUtil<TMatterFeature>(TMatterFeature.class);
        return util.exportExcel(list, "feature");
    }

    /**
     * 获取危害物质关联危险类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('ehs:feature:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tMatterFeatureService.selectTMatterFeatureById(id));
    }

    /**
     * 新增危害物质关联危险类型
     */
    @PreAuthorize("@ss.hasPermi('ehs:feature:add')")
    @Log(title = "危害物质关联危险类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TMatterFeature tMatterFeature)
    {
        return toAjax(tMatterFeatureService.insertTMatterFeature(tMatterFeature));
    }

    /**
     * 修改危害物质关联危险类型
     */
    @PreAuthorize("@ss.hasPermi('ehs:feature:edit')")
    @Log(title = "危害物质关联危险类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TMatterFeature tMatterFeature)
    {
        return toAjax(tMatterFeatureService.updateTMatterFeature(tMatterFeature));
    }

    /**
     * 删除危害物质关联危险类型
     */
    @PreAuthorize("@ss.hasPermi('ehs:feature:remove')")
    @Log(title = "危害物质关联危险类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tMatterFeatureService.deleteTMatterFeatureByIds(ids));
    }
}
