package com.xinelu.mobile.controller.homepage;

import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.core.page.TableDataInfo;
import com.xinelu.manage.domain.signpatientmanageroutenode.SignPatientManageRouteNode;
import com.xinelu.manage.dto.patientquestionsubmitresult.PatientQuestionSubmitResultDTO;
import com.xinelu.mobile.service.homepage.HomePageService;
import com.xinelu.mobile.vo.homepage.HealthLog;
import com.xinelu.mobile.vo.myfollowup.MyFollowUpVO;
import org.springframework.web.bind.annotation.*;

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

/**
 * 小程序首页Controller
 *
 * @author zh
 * @date 2024-04-18
 */
@RestController
@RequestMapping("/postDischarge/homePage")
public class HomePageController extends BaseController {

    @Resource
    private HomePageService homePageService;

    /**
     * 我的随访列表
     */
    @GetMapping("/myFollowUp")
    public TableDataInfo myFollowUp(MyFollowUpVO myFollowUp) {
        return homePageService.myFollowUp(myFollowUp);
    }

    /**
     * 获取话术信息详细信息(随访)
     */
    @GetMapping("/selectScriptInfo")
    public AjaxResult selectScriptInfo(Long patientTaskExecuteRecordId) {
        return AjaxResult.success(homePageService.selectScriptInfo(patientTaskExecuteRecordId));
    }

    /**
     * 问卷信息（随访）
     */
    @GetMapping("/selectQuestion")
    public AjaxResult selectQuestion(Long templateId) {
        return homePageService.selectQuestion(templateId);
    }

    /**
     * 问卷记录信息（消息记录、我的随访）
     */
    @GetMapping("/selectQuestionSubmit")
    public AjaxResult selectQuestionSubmit(Long patientQuestionSubmitResultId, Long patientTaskExecuteRecordId) {
        if (Objects.isNull(patientQuestionSubmitResultId) && Objects.isNull(patientTaskExecuteRecordId)) {
            return AjaxResult.error("请选择记录信息！");
        }
        return homePageService.selectQuestionSubmit(patientQuestionSubmitResultId, patientTaskExecuteRecordId);
    }

    /**
     * 问卷提交（消息记录）
     */
    @PostMapping("/updateTaskExecuteRecord")
    public AjaxResult updatePatientTaskExecuteRecord(@RequestBody PatientQuestionSubmitResultDTO dto) {
        return homePageService.updatePatientTaskExecuteRecord(dto);
    }

    /**
     * 健康日志
     */
    @GetMapping("/selectTaskExecuteRecord")
    public TableDataInfo selectPatientTaskExecuteRecord(Long residentId) {
        startPage();
        List<HealthLog> list = homePageService.selectPatientTaskExecuteRecord(residentId);
        return getDataTable(list);
    }

    /**
     * 满意度问卷
     */
    @GetMapping("/satisfactionQuestionnaire")
    private TableDataInfo satisfactionQuestionnaire(Long residentId) {
        return homePageService.satisfactionQuestionnaire(residentId);
    }

    /**
     * 消息通知列表（消息记录）
     */
    @GetMapping("/messageNotification")
    public AjaxResult selectSignPatientManageRouteNode(Long residentId) {
        return homePageService.selectSignPatientManageRouteNode(residentId);
    }

    /**
     * 消息推送内容（消息记录）
     */
    @GetMapping("/selectMessageContent")
    public AjaxResult selectMessageContent(Long manageRouteNodeId) {
        return homePageService.selectMessageContent(manageRouteNodeId);
    }

    /**
     * 修改消息状态（消息记录）
     */
    @PostMapping("/updateMessageStatus")
    public AjaxResult updateMessageStatus(@RequestBody SignPatientManageRouteNode signPatientManageRouteNode) {
        return homePageService.updateMessageStatus(signPatientManageRouteNode);
    }

    /**
     * 任务完成情况
     */
    @GetMapping("/nodeExecuteStatus")
    public AjaxResult nodeExecuteStatus(Long manageRouteNodeId) {
        return homePageService.nodeExecuteStatus(manageRouteNodeId);
    }

    /**
     * 保存宣教文章查看时间
     */
    @PostMapping("/viewPropaganda")
    public AjaxResult viewPropaganda(Long manageRouteNodeId) {
        return homePageService.viewPropaganda(manageRouteNodeId);
    }
}