package com.xzzn.web.controller.ems;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.xzzn.ems.domain.EmsStrategyTemp;
import com.xzzn.ems.domain.EmsStrategyTimeConfig;
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.xzzn.common.annotation.Log;
import com.xzzn.common.core.controller.BaseController;
import com.xzzn.common.core.domain.AjaxResult;
import com.xzzn.common.enums.BusinessType;
import com.xzzn.ems.domain.EmsStrategyCurve;
import com.xzzn.ems.service.IEmsStrategyCurveService;
import com.xzzn.common.utils.poi.ExcelUtil;

/**
 * 策曲线Controller
 *
 * @author xzzn
 * @date 2025-07-11
 */
@RestController
@RequestMapping("/strategy/curve")
public class EmsStrategyCurveController extends BaseController
{
    @Autowired
    private IEmsStrategyCurveService emsStrategyCurveService;

    /**
     * 查询策曲线列表
     */
    @PreAuthorize("@ss.hasPermi('system:curve:list')")
    @GetMapping("/list")
    public AjaxResult list(EmsStrategyCurve emsStrategyCurve)
    {
        return success(emsStrategyCurveService.selectEmsStrategyCurveList(emsStrategyCurve));
    }

    /**
     * 导出策曲线列表
     */
    @PreAuthorize("@ss.hasPermi('system:curve:export')")
    @Log(title = "策曲线", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmsStrategyCurve emsStrategyCurve)
    {
        List<EmsStrategyCurve> list = emsStrategyCurveService.selectEmsStrategyCurveList(emsStrategyCurve);
        ExcelUtil<EmsStrategyCurve> util = new ExcelUtil<EmsStrategyCurve>(EmsStrategyCurve.class);
        util.exportExcel(response, list, "策曲线数据");
    }

    /**
     * 获取策曲线详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:curve:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(emsStrategyCurveService.selectEmsStrategyCurveById(id));
    }

    /**
     * 新增策曲线
     */
    @PreAuthorize("@ss.hasPermi('system:curve:add')")
    @Log(title = "策曲线", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmsStrategyCurve emsStrategyCurve)
    {
        return toAjax(emsStrategyCurveService.insertEmsStrategyCurve(emsStrategyCurve));
    }

    /**
     * 修改策曲线
     */
    @PreAuthorize("@ss.hasPermi('system:curve:edit')")
    @Log(title = "策曲线", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmsStrategyCurve emsStrategyCurve)
    {
        return toAjax(emsStrategyCurveService.updateEmsStrategyCurve(emsStrategyCurve));
    }

    /**
     * 删除策曲线
     */
    @PreAuthorize("@ss.hasPermi('system:curve:remove')")
    @Log(title = "策曲线", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(emsStrategyCurveService.deleteEmsStrategyCurveByIds(ids));
    }

    /**
     * 获取策略曲线图数据
     */
    @GetMapping("/curveList")
    public AjaxResult getCurveList(EmsStrategyTemp tempConfig)
    {
        return success(emsStrategyCurveService.getStrategyCurveList(tempConfig));
    }
}
