package com.ruoyi.project.sems.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.sems.domain.TMeasureStress;
import com.ruoyi.project.sems.service.ITMeasureStressService;
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 ssy
 * @date 2025-03-19
 */
@RestController
@RequestMapping("/sems/stress")
public class TMeasureStressController extends BaseController
{
    @Autowired
    private ITMeasureStressService tMeasureStressService;

    /**
     * 查询材料应力列表
     */
    @PreAuthorize("@ss.hasPermi('sems:stress:list')")
    @GetMapping("/list")
    public TableDataInfo list(TMeasureStress tMeasureStress)
    {
        startPage();
        List<TMeasureStress> list = tMeasureStressService.selectTMeasureStressList(tMeasureStress);
        return getDataTable(list);
    }

    /**
     * 导出材料应力列表
     */
    @PreAuthorize("@ss.hasPermi('sems:stress:export')")
    @Log(title = "材料应力", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TMeasureStress tMeasureStress)
    {
        List<TMeasureStress> list = tMeasureStressService.selectTMeasureStressList(tMeasureStress);
        ExcelUtil<TMeasureStress> util = new ExcelUtil<TMeasureStress>(TMeasureStress.class);
        return util.exportExcel(list, "stress");
    }

    /**
     * 获取材料应力详细信息
     */
    @PreAuthorize("@ss.hasPermi('sems:stress:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tMeasureStressService.selectTMeasureStressById(id));
    }

    /**
     * 新增材料应力
     */
    @PreAuthorize("@ss.hasPermi('sems:stress:add')")
    @Log(title = "材料应力", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TMeasureStress tMeasureStress)
    {
        return toAjax(tMeasureStressService.insertTMeasureStress(tMeasureStress));
    }

    /**
     * 修改材料应力
     */
    @PreAuthorize("@ss.hasPermi('sems:stress:edit')")
    @Log(title = "材料应力", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TMeasureStress tMeasureStress)
    {
        return toAjax(tMeasureStressService.updateTMeasureStress(tMeasureStress));
    }

    /**
     * 删除材料应力
     */
    @PreAuthorize("@ss.hasPermi('sems:stress:remove')")
    @Log(title = "材料应力", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tMeasureStressService.deleteTMeasureStressByIds(ids));
    }
}
