package com.ruoyi.project.reliability.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.reliability.domain.TDeviceExperience;
import com.ruoyi.project.reliability.service.ITDeviceExperienceService;
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 2022-07-07
 */
@RestController
@RequestMapping("/reliability/experience")
public class TDeviceExperienceController extends BaseController
{
    @Autowired
    private ITDeviceExperienceService tDeviceExperienceService;

    /**
     * 查询装置经验数据库列表
     */
    @PreAuthorize("@ss.hasPermi('reliability:experience:list')")
    @GetMapping("/list")
    public TableDataInfo list(TDeviceExperience tDeviceExperience)
    {
        startPage();
        List<TDeviceExperience> list = tDeviceExperienceService.selectTDeviceExperienceList(tDeviceExperience);
        return getDataTable(list);
    }

    /**
     * 导出装置经验数据库列表
     */
    @PreAuthorize("@ss.hasPermi('reliability:experience:export')")
    @Log(title = "装置经验数据库", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TDeviceExperience tDeviceExperience)
    {
        List<TDeviceExperience> list = tDeviceExperienceService.selectTDeviceExperienceList(tDeviceExperience);
        ExcelUtil<TDeviceExperience> util = new ExcelUtil<TDeviceExperience>(TDeviceExperience.class);
        return util.exportExcel(list, "experience");
    }

    /**
     * 获取装置经验数据库详细信息
     */
    @PreAuthorize("@ss.hasPermi('reliability:experience:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tDeviceExperienceService.selectTDeviceExperienceById(id));
    }

    /**
     * 新增装置经验数据库
     */
    @PreAuthorize("@ss.hasPermi('reliability:experience:add')")
    @Log(title = "装置经验数据库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TDeviceExperience tDeviceExperience)
    {
        return toAjax(tDeviceExperienceService.insertTDeviceExperience(tDeviceExperience));
    }

    /**
     * 修改装置经验数据库
     */
    @PreAuthorize("@ss.hasPermi('reliability:experience:edit')")
    @Log(title = "装置经验数据库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TDeviceExperience tDeviceExperience)
    {
        return toAjax(tDeviceExperienceService.updateTDeviceExperience(tDeviceExperience));
    }

    /**
     * 删除装置经验数据库
     */
    @PreAuthorize("@ss.hasPermi('reliability:experience:remove')")
    @Log(title = "装置经验数据库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tDeviceExperienceService.deleteTDeviceExperienceByIds(ids));
    }
}
