package com.easyproject.web.controller.operate;

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

import com.easyproject.service.domain.operate.OperateCommonQuestions;
import com.easyproject.system.service.operate.IOperateCommonQuestionsService;
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.easyproject.common.annotation.Log;
import com.easyproject.common.core.controller.BaseController;
import com.easyproject.common.core.domain.AjaxResult;
import com.easyproject.common.enums.BusinessType;
import com.easyproject.common.core.page.TableDataInfo;

/**
 * 常见问题Controller
 * 
 * @author easyproject
 * @date 2025-03-19
 */
@RestController
@RequestMapping("/system/questions")
public class OperateCommonQuestionsController extends BaseController
{
    @Autowired
    private IOperateCommonQuestionsService operateCommonQuestionsService;

    /**
     * 查询常见问题列表
     */
    @PreAuthorize("@ss.hasPermi('system:questions:list')")
    @GetMapping("/list")
    public TableDataInfo list(OperateCommonQuestions operateCommonQuestions)
    {
        startPage();
        List<OperateCommonQuestions> list = operateCommonQuestionsService.selectOperateCommonQuestionsList(operateCommonQuestions);
        return getDataTable(list);
    }

    /**
     * 获取常见问题详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:questions:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(operateCommonQuestionsService.selectOperateCommonQuestionsById(id));
    }

    /**
     * 新增常见问题
     */
    @PreAuthorize("@ss.hasPermi('system:questions:add')")
    @Log(title = "常见问题", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OperateCommonQuestions operateCommonQuestions)
    {
        return toAjax(operateCommonQuestionsService.insertOperateCommonQuestions(operateCommonQuestions));
    }

    /**
     * 修改常见问题
     */
    @PreAuthorize("@ss.hasPermi('system:questions:edit')")
    @Log(title = "常见问题", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OperateCommonQuestions operateCommonQuestions)
    {
        return toAjax(operateCommonQuestionsService.updateOperateCommonQuestions(operateCommonQuestions));
    }

    /**
     * 删除常见问题
     */
    @PreAuthorize("@ss.hasPermi('system:questions:remove')")
    @Log(title = "常见问题", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(operateCommonQuestionsService.deleteOperateCommonQuestionsByIds(ids));
    }
}
