package com.xinelu.manage.controller.patientquestionsubjectresult;


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.patientquestionsubjectresult.PatientQuestionSubjectResult;
import com.xinelu.manage.service.patientquestionsubjectresult.IPatientQuestionSubjectResultService;
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/patientQuestionSubjectResult")
public class PatientQuestionSubjectResultController extends BaseController {
    @Resource
    private IPatientQuestionSubjectResultService patientQuestionSubjectResultService;

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

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

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

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

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

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