package com.agri.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.agri.common.annotation.Log;
import com.agri.common.core.controller.BaseController;
import com.agri.common.core.domain.AjaxResult;
import com.agri.common.enums.BusinessType;
import com.agri.system.domain.SysRequireList;
import com.agri.system.service.ISysRequireListService;
import com.agri.common.utils.poi.ExcelUtil;
import com.agri.common.core.page.TableDataInfo;

/**
 * 需求清单Controller
 * 
 * @author lld
 * @date 2026-01-11
 */
@RestController
@RequestMapping("/system/require")
public class SysRequireListController extends BaseController
{
    @Autowired
    private ISysRequireListService sysRequireListService;

    /**
     * 查询需求清单列表
     */
    @PreAuthorize("@ss.hasPermi('system:require:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysRequireList sysRequireList)
    {
        startPage();
        List<SysRequireList> list = sysRequireListService.selectSysRequireListList(sysRequireList);
        return getDataTable(list);
    }

    /**
     * 导出需求清单列表
     */
    @PreAuthorize("@ss.hasPermi('system:require:export')")
    @Log(title = "需求清单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysRequireList sysRequireList)
    {
        List<SysRequireList> list = sysRequireListService.selectSysRequireListList(sysRequireList);
        ExcelUtil<SysRequireList> util = new ExcelUtil<SysRequireList>(SysRequireList.class);
        util.exportExcel(response, list, "需求清单数据");
    }

    /**
     * 获取需求清单详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:require:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysRequireListService.selectSysRequireListById(id));
    }

    /**
     * 新增需求清单
     */
    @PreAuthorize("@ss.hasPermi('system:require:add')")
    @Log(title = "需求清单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysRequireList sysRequireList)
    {
        return toAjax(sysRequireListService.insertSysRequireList(sysRequireList));
    }

    /**
     * 修改需求清单
     */
    @PreAuthorize("@ss.hasPermi('system:require:edit')")
    @Log(title = "需求清单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysRequireList sysRequireList)
    {
        return toAjax(sysRequireListService.updateSysRequireList(sysRequireList));
    }

    /**
     * 删除需求清单
     */
    @PreAuthorize("@ss.hasPermi('system:require:remove')")
    @Log(title = "需求清单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysRequireListService.deleteSysRequireListByIds(ids));
    }
}
