package com.xinelu.manage.controller.patienttaskexecuterecord;

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.manage.domain.patienttaskexecuterecord.PatientTaskExecuteRecord;
import com.xinelu.manage.service.patienttaskexecuterecord.IPatientTaskExecuteRecordService;
import com.xinelu.manage.vo.patienttaskexecuterecord.PatientTaskExecuteRecordVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * 患者管理任务执行记录Controller
 *
 * @author xinelu
 * @date 2024-03-25
 */
@RestController
@RequestMapping("/system/taskExecuteRecord")
public class PatientTaskExecuteRecordController extends BaseController {
    @Resource
    private IPatientTaskExecuteRecordService patientTaskExecuteRecordService;

    /**
     * 查询患者管理任务执行记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:taskExecuteRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(PatientTaskExecuteRecordVO patientTaskExecuteRecord) {
        startPage();
        List<PatientTaskExecuteRecordVO> list = patientTaskExecuteRecordService.selectPatientTaskExecuteRecordList(patientTaskExecuteRecord);
        return getDataTable(list);
    }

    /**
     * 获取患者管理任务执行记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:taskExecuteRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(patientTaskExecuteRecordService.selectPatientTaskExecuteRecordById(id));
    }

    /**
     * 新增患者管理任务执行记录
     */
    @PreAuthorize("@ss.hasPermi('system:taskExecuteRecord:add')")
    @Log(title = "患者管理任务执行记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PatientTaskExecuteRecord patientTaskExecuteRecord) {
        return toAjax(patientTaskExecuteRecordService.insertPatientTaskExecuteRecord(patientTaskExecuteRecord));
    }

    /**
     * 修改患者管理任务执行记录
     */
    @PreAuthorize("@ss.hasPermi('system:taskExecuteRecord:edit')")
    @Log(title = "患者管理任务执行记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PatientTaskExecuteRecord patientTaskExecuteRecord) {
        return toAjax(patientTaskExecuteRecordService.updatePatientTaskExecuteRecord(patientTaskExecuteRecord));
    }

    /**
     * 删除患者管理任务执行记录
     */
    @PreAuthorize("@ss.hasPermi('system:taskExecuteRecord:remove')")
    @Log(title = "患者管理任务执行记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(patientTaskExecuteRecordService.deletePatientTaskExecuteRecordByIds(ids));
    }

    /**
     * 根据患者信息查询就诊记录
     */
    @GetMapping("/selectVisitRecord")
    public AjaxResult selectVisitRecord(Long patientId) {
        return patientTaskExecuteRecordService.selectVisitRecord(patientId);
    }

    /**
     * 根据任务执行记录查询患者问卷信息
     */
    @GetMapping("/selectPatientQuestionSubmit")
    public AjaxResult selectPatientQuestionSubmit(Long taskExecuteRecordId) {
        return patientTaskExecuteRecordService.selectPatientQuestionSubmit(taskExecuteRecordId);
    }
}
