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.SetupTensionStraightener;
import com.fizz.business.service.ISetupTensionStraightenerService;

/**
 * 矫直机张力Controller（无权限控制）
 * 
 * 三主键：steelGrade + thick + yieldStren
 */
@RestController
@RequestMapping("/business/tension/straightener")
@Anonymous
public class SetupTensionStraightenerController extends BaseController
{
    @Autowired
    private ISetupTensionStraightenerService service;

    @GetMapping("/list")
    public TableDataInfo list(SetupTensionStraightener query)
    {
        startPage();
        List<SetupTensionStraightener> 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 SetupTensionStraightener entity)
    {
        return toAjax(service.insert(entity));
    }

    @Log(title = "矫直机张力", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SetupTensionStraightener 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));
    }
}

