package com.srs.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;

import com.srs.system.domain.SysSuggestion;
import com.srs.system.service.ISysSuggestionService;
import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.utils.poi.ExcelUtil;
import com.srs.common.enums.BusinessType;
import com.srs.common.annotation.Log;
import com.srs.common.core.page.TableDataInfo;

/**
 * 优化建议Controller
 *
 * @author srs
 * @date 2025-04-29
 */
@RestController
@RequestMapping("/system/suggestion")
@Api(value = "优化建议管理", tags = "优化建议管理")
public class SysSuggestionController extends BaseController {
    @Autowired
    private ISysSuggestionService sysSuggestionService;

    /**
     * 查询优化建议列表
     */
@PreAuthorize("@ss.hasPermi('system:suggestion:list')")
@GetMapping("/list")
@ApiOperation("查询优化建议列表")
    public TableDataInfo list(SysSuggestion sysSuggestion)
    {
        startPage();
        List<SysSuggestion> list = sysSuggestionService.selectSysSuggestionList(sysSuggestion);
        return getDataTable(list);
    }

    /**
     * 导出优化建议列表
     */
    @PreAuthorize("@ss.hasPermi('system:suggestion:export')")
    @Log(title = "优化建议", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出优化建议列表")
    public void export(HttpServletResponse response, SysSuggestion sysSuggestion)
    {
        List<SysSuggestion> list = sysSuggestionService.selectSysSuggestionList(sysSuggestion);
        ExcelUtil<SysSuggestion> util = new ExcelUtil<SysSuggestion>(SysSuggestion.class);
        util.exportExcel(response, list, "优化建议数据");
    }

    /**
     * 获取优化建议详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:suggestion:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取优化建议详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysSuggestionService.selectSysSuggestionById(id));
    }

    /**
     * 新增优化建议
     */
    @PreAuthorize("@ss.hasPermi('system:suggestion:add')")
    @Log(title = "优化建议", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增优化建议")
    public AjaxResult add(@RequestBody SysSuggestion sysSuggestion)
    {
        return toAjax(sysSuggestionService.insertSysSuggestion(sysSuggestion));
    }

    /**
     * 修改优化建议
     */
    @PreAuthorize("@ss.hasPermi('system:suggestion:edit')")
    @Log(title = "优化建议", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改优化建议")
    public AjaxResult edit(@RequestBody SysSuggestion sysSuggestion)
    {
        return toAjax(sysSuggestionService.updateSysSuggestion(sysSuggestion));
    }

    /**
     * 删除优化建议
     */
    @PreAuthorize("@ss.hasPermi('system:suggestion:remove')")
    @Log(title = "优化建议", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("删除优化建议")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysSuggestionService.deleteSysSuggestionByIds(ids));
    }
}
