package com.uavps.web.controller.system;

import com.uavps.common.annotation.Log;
import com.uavps.common.core.controller.BaseController;
import com.uavps.common.core.domain.AjaxResult;
import com.uavps.common.core.page.TableDataInfo;
import com.uavps.common.enums.BusinessType;
import com.uavps.common.utils.poi.ExcelUtil;
import com.uavps.system.domain.UavpsAlgorithmParameter;
import com.uavps.system.service.IUavpsAlgorithmParameterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * 算法参数信息Controller
 *
 * @author ruoyi
 * @date 2025-03-27
 */
@RestController
@RequestMapping("/uavps/parameter")
public class UavpsAlgorithmParameterController extends BaseController {
    @Autowired
    private IUavpsAlgorithmParameterService uavpsAlgorithmParameterService;

    /**
     * 查询算法参数信息列表
     */
    @PreAuthorize("@ss.hasPermi('uavps:parameter:list')")
    @GetMapping("/list")
    public TableDataInfo list(UavpsAlgorithmParameter uavpsAlgorithmParameter) {
        startPage();
        List<UavpsAlgorithmParameter> list = uavpsAlgorithmParameterService.selectUavpsAlgorithmParameterList(uavpsAlgorithmParameter);
        return getDataTable(list);
    }

    /**
     * 导出算法参数信息列表
     */
    @PreAuthorize("@ss.hasPermi('uavps:parameter:export')")
    @Log(title = "算法参数信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UavpsAlgorithmParameter uavpsAlgorithmParameter) {
        List<UavpsAlgorithmParameter> list = uavpsAlgorithmParameterService.selectUavpsAlgorithmParameterList(uavpsAlgorithmParameter);
        ExcelUtil<UavpsAlgorithmParameter> util = new ExcelUtil<UavpsAlgorithmParameter>(UavpsAlgorithmParameter.class);
        util.exportExcel(response, list, "算法参数信息数据");
    }

    /**
     * 获取算法参数信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('uavps:parameter:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(uavpsAlgorithmParameterService.selectUavpsAlgorithmParameterById(id));
    }

    /**
     * 新增算法参数信息
     */
    @PreAuthorize("@ss.hasPermi('uavps:parameter:add')")
    @Log(title = "算法参数信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UavpsAlgorithmParameter uavpsAlgorithmParameter) {
        return toAjax(uavpsAlgorithmParameterService.insertUavpsAlgorithmParameter(uavpsAlgorithmParameter));
    }

    /**
     * 修改算法参数信息
     */
    @PreAuthorize("@ss.hasPermi('uavps:parameter:edit')")
    @Log(title = "算法参数信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UavpsAlgorithmParameter uavpsAlgorithmParameter) {
        return toAjax(uavpsAlgorithmParameterService.updateUavpsAlgorithmParameter(uavpsAlgorithmParameter));
    }

    /**
     * 删除算法参数信息
     */
    @PreAuthorize("@ss.hasPermi('uavps:parameter:remove')")
    @Log(title = "算法参数信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(uavpsAlgorithmParameterService.deleteUavpsAlgorithmParameterByIds(ids));
    }
}
