package com.fizz.business.controller;

import java.util.List;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.fizz.business.domain.SetupTensionAllLine;
import com.fizz.business.service.ISetupTensionAllLineService;

/**
 * 全线张力Controller（无权限控制）
 * 
 * 三主键：steelGrade + thick + yieldStren
 */
@RestController
@RequestMapping("/business/tension/all-line")
@Anonymous
public class SetupTensionAllLineController extends BaseController
{
    @Autowired
    private ISetupTensionAllLineService service;

    /**
     * 查询全线张力列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SetupTensionAllLine query)
    {
        startPage();
        List<SetupTensionAllLine> list = service.selectList(query);
        return getDataTable(list);
    }

    /**
     * 获取全线张力详细信息（按三主键）
     */
    @GetMapping
    public AjaxResult getInfo(@RequestParam("steelGrade") String steelGrade,
                              @RequestParam("thick") Float thick,
                              @RequestParam("yieldStren") Float yieldStren)
    {
        return success(service.selectByKey(steelGrade, thick, yieldStren));
    }

    /**
     * 新增全线张力
     */
    @Log(title = "全线张力", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SetupTensionAllLine entity)
    {
        return toAjax(service.insert(entity));
    }

    /**
     * 修改全线张力（按三主键定位）
     */
    @Log(title = "全线张力", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SetupTensionAllLine entity)
    {
        return toAjax(service.updateByKey(entity));
    }

    /**
     * 删除全线张力（按三主键）
     */
    @Log(title = "全线张力", businessType = BusinessType.DELETE)
    @DeleteMapping
    public AjaxResult remove(@RequestParam("steelGrade") String steelGrade,
                             @RequestParam("thick") Float thick,
                             @RequestParam("yieldStren") Float yieldStren)
    {
        return toAjax(service.deleteByKey(steelGrade, thick, yieldStren));
    }
}
