package com.ruoyi.web.controller.dz;

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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.back.domain.BCustomerQuestionError;
import com.ruoyi.back.service.IBCustomerQuestionErrorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 题目纠错Controller
 *
 * @author ruoyi
 * @date 2025-11-22
 */
@RestController
@RequestMapping("/dz/bCustomerQuestionError")
public class BCustomerQuestionErrorController extends BaseController
{
    @Autowired
    private IBCustomerQuestionErrorService bCustomerQuestionErrorService;

    /**
     * 查询题目纠错列表
     */
    @PreAuthorize("@ss.hasPermi('dz:bCustomerQuestionError:list')")
    @GetMapping("/list")
    public TableDataInfo list(BCustomerQuestionError bCustomerQuestionError)
    {
        startPage();
        List<BCustomerQuestionError> list = bCustomerQuestionErrorService.selectBCustomerQuestionErrorList(bCustomerQuestionError);
        return getDataTable(list);
    }

    /**
     * 导出题目纠错列表
     */
    @PreAuthorize("@ss.hasPermi('dz:bCustomerQuestionError:export')")
    @Log(title = "题目纠错", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BCustomerQuestionError bCustomerQuestionError)
    {
        List<BCustomerQuestionError> list = bCustomerQuestionErrorService.selectBCustomerQuestionErrorList(bCustomerQuestionError);
        ExcelUtil<BCustomerQuestionError> util = new ExcelUtil<BCustomerQuestionError>(BCustomerQuestionError.class);
        util.exportExcel(response, list, "题目纠错数据");
    }

    /**
     * 获取题目纠错详细信息
     */
    @PreAuthorize("@ss.hasPermi('dz:bCustomerQuestionError:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bCustomerQuestionErrorService.selectBCustomerQuestionErrorById(id));
    }

    /**
     * 新增题目纠错
     */
    @PreAuthorize("@ss.hasPermi('dz:bCustomerQuestionError:add')")
    @Log(title = "题目纠错", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BCustomerQuestionError bCustomerQuestionError)
    {
        return toAjax(bCustomerQuestionErrorService.insertBCustomerQuestionError(bCustomerQuestionError));
    }

    /**
     * 修改题目纠错
     */
    @PreAuthorize("@ss.hasPermi('dz:bCustomerQuestionError:edit')")
    @Log(title = "题目纠错", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BCustomerQuestionError bCustomerQuestionError)
    {
        return toAjax(bCustomerQuestionErrorService.updateBCustomerQuestionError(bCustomerQuestionError));
    }

    /**
     * 删除题目纠错
     */
    @PreAuthorize("@ss.hasPermi('dz:bCustomerQuestionError:remove')")
    @Log(title = "题目纠错", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bCustomerQuestionErrorService.deleteBCustomerQuestionErrorByIds(ids));
    }

    /**
     * 确认解决
     */
    @PreAuthorize("@ss.hasPermi('dz:bCustomerQuestionError:edit')")
    @Log(title = "题目纠错", businessType = BusinessType.UPDATE)
    @PostMapping("/verifyProcess/{id}")
    public AjaxResult verifyProcess(@PathVariable("id") Long id)
    {
        BCustomerQuestionError bCustomerQuestionError = new BCustomerQuestionError();
        bCustomerQuestionError.setId(id);
        bCustomerQuestionError.setStatus(1);
        return toAjax(bCustomerQuestionErrorService.updateBCustomerQuestionError(bCustomerQuestionError));
    }
}
