package com.easyproject.web.controller.operate;

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

import com.easyproject.service.domain.operate.OperateHotQuestions;
import com.easyproject.system.service.operate.IOperateHotQuestionsService;
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/hotQuestions")
public class OperateHotQuestionsController extends BaseController
{
    @Autowired
    private IOperateHotQuestionsService operateHotQuestionsService;

    /**
     * 查询热门问题列表
     */
    @PreAuthorize("@ss.hasPermi('system:hotQuestions:list')")
    @GetMapping("/list")
    public TableDataInfo list(OperateHotQuestions operateHotQuestions)
    {
        startPage();
        List<OperateHotQuestions> list = operateHotQuestionsService.selectOperateHotQuestionsList(operateHotQuestions);
        return getDataTable(list);
    }

    /**
     * 获取热门问题详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:hotQuestions:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(operateHotQuestionsService.selectOperateHotQuestionsById(id));
    }

    /**
     * 新增热门问题
     */
    @PreAuthorize("@ss.hasPermi('system:hotQuestions:add')")
    @Log(title = "热门问题", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OperateHotQuestions operateHotQuestions)
    {
        return toAjax(operateHotQuestionsService.insertOperateHotQuestions(operateHotQuestions));
    }

    /**
     * 修改热门问题
     */
    @PreAuthorize("@ss.hasPermi('system:hotQuestions:edit')")
    @Log(title = "热门问题", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OperateHotQuestions operateHotQuestions)
    {
        return toAjax(operateHotQuestionsService.updateOperateHotQuestions(operateHotQuestions));
    }

    /**
     * 删除热门问题
     */
    @PreAuthorize("@ss.hasPermi('system:hotQuestions:remove')")
    @Log(title = "热门问题", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(operateHotQuestionsService.deleteOperateHotQuestionsByIds(ids));
    }
}
