package com.xinelu.manage.controller.patientquestionoptionresult;

import com.xinelu.common.annotation.Log;
import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.core.page.TableDataInfo;
import com.xinelu.common.enums.BusinessType;
import com.xinelu.common.utils.poi.ExcelUtil;
import com.xinelu.manage.domain.patientquestionoptionresult.PatientQuestionOptionResult;
import com.xinelu.manage.service.patientquestionoptionresult.IPatientQuestionOptionResultService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

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

/**
 * 患者问卷题目选项提交结果信息Controller
 *
 * @author xinelu
 * @date 2024-03-28
 */
@RestController
@RequestMapping("/system/patientQuestionOptionResult")
public class PatientQuestionOptionResultController extends BaseController {
    @Resource
    private IPatientQuestionOptionResultService patientQuestionOptionResultService;

    /**
     * 查询患者问卷题目选项提交结果信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:patientQuestionOptionResult:list')")
    @GetMapping("/list")
    public TableDataInfo list(PatientQuestionOptionResult patientQuestionOptionResult) {
        startPage();
        List<PatientQuestionOptionResult> list = patientQuestionOptionResultService.selectPatientQuestionOptionResultList(patientQuestionOptionResult);
        return getDataTable(list);
    }

    /**
     * 导出患者问卷题目选项提交结果信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:patientQuestionOptionResult:export')")
    @Log(title = "患者问卷题目选项提交结果信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PatientQuestionOptionResult patientQuestionOptionResult) {
        List<PatientQuestionOptionResult> list = patientQuestionOptionResultService.selectPatientQuestionOptionResultList(patientQuestionOptionResult);
        ExcelUtil<PatientQuestionOptionResult> util = new ExcelUtil<>(PatientQuestionOptionResult.class);
        util.exportExcel(response, list, "患者问卷题目选项提交结果信息数据");
    }

    /**
     * 获取患者问卷题目选项提交结果信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:patientQuestionOptionResult:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(patientQuestionOptionResultService.selectPatientQuestionOptionResultById(id));
    }

    /**
     * 新增患者问卷题目选项提交结果信息
     */
    @PreAuthorize("@ss.hasPermi('system:patientQuestionOptionResult:add')")
    @Log(title = "患者问卷题目选项提交结果信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PatientQuestionOptionResult patientQuestionOptionResult) {
        return toAjax(patientQuestionOptionResultService.insertPatientQuestionOptionResult(patientQuestionOptionResult));
    }

    /**
     * 修改患者问卷题目选项提交结果信息
     */
    @PreAuthorize("@ss.hasPermi('system:patientQuestionOptionResult:edit')")
    @Log(title = "患者问卷题目选项提交结果信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PatientQuestionOptionResult patientQuestionOptionResult) {
        return toAjax(patientQuestionOptionResultService.updatePatientQuestionOptionResult(patientQuestionOptionResult));
    }

    /**
     * 删除患者问卷题目选项提交结果信息
     */
    @PreAuthorize("@ss.hasPermi('system:patientQuestionOptionResult:remove')")
    @Log(title = "患者问卷题目选项提交结果信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(patientQuestionOptionResultService.deletePatientQuestionOptionResultByIds(ids));
    }
}
