package com.xinelu.manage.controller.signpatientmanageroute;

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.signpatientmanageroute.SignPatientManageRoute;
import com.xinelu.manage.dto.manualfollowup.ManualFollowUpDTO;
import com.xinelu.manage.dto.patientquestionsubmitresult.PatientQuestionSubmitResultDTO;
import com.xinelu.manage.service.signpatientmanageroute.ISignPatientManageRouteService;
import com.xinelu.manage.vo.manualfollowup.ManualFollowUpVO;
import com.xinelu.manage.vo.signpatientmanageroute.SignPatientManageRouteVO;
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 haown
 * @date 2024-03-18
 */
@RestController
@RequestMapping("/manage/signroute")
public class SignPatientManageRouteController extends BaseController {
    @Resource
    private ISignPatientManageRouteService signPatientManageRouteService;

    /**
     * 查询签约患者管理任务路径列表
     */
    @PreAuthorize("@ss.hasPermi('manage:signroute:list')")
    @GetMapping("/list")
    public TableDataInfo list(SignPatientManageRoute signPatientManageRoute) {
        startPage();
        List<SignPatientManageRoute> list = signPatientManageRouteService.selectSignPatientManageRouteList(signPatientManageRoute);
        return getDataTable(list);
    }

    /**
     * 导出签约患者管理任务路径列表
     */
    @PreAuthorize("@ss.hasPermi('manage:signroute:export')")
    @Log(title = "签约患者管理任务路径", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SignPatientManageRoute signPatientManageRoute) {
        List<SignPatientManageRoute> list = signPatientManageRouteService.selectSignPatientManageRouteList(signPatientManageRoute);
        ExcelUtil<SignPatientManageRoute> util = new ExcelUtil<SignPatientManageRoute>(SignPatientManageRoute.class);
        util.exportExcel(response, list, "签约患者管理任务路径数据");
    }

    /**
     * 获取签约患者管理任务路径详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:signroute:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(signPatientManageRouteService.selectSignPatientManageRouteById(id));
    }

    /**
     * 新增签约患者管理任务路径
     */
    @PreAuthorize("@ss.hasPermi('manage:signroute:add')")
    @Log(title = "签约患者管理任务路径", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody SignPatientManageRouteVO signPatientManageRoute) {
        return signPatientManageRouteService.insertSignPatientManageRoute(signPatientManageRoute);
    }

    /**
     * 修改签约患者管理任务路径
     */
    @PreAuthorize("@ss.hasPermi('manage:signroute:edit')")
    @Log(title = "签约患者管理任务路径", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody SignPatientManageRouteVO signPatientManageRoute) {
        return signPatientManageRouteService.updateSignPatientManageRoute(signPatientManageRoute);
    }

    /**
     * 删除签约患者管理任务路径
     */
    @PreAuthorize("@ss.hasPermi('manage:signroute:remove')")
    @Log(title = "签约患者管理任务路径", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(signPatientManageRouteService.deleteSignPatientManageRouteByIds(ids));
    }

    /**
     * 查询人工随访代办列表
     */
    @GetMapping("/manualFollowUpList")
    public TableDataInfo getManualFollowUpList(ManualFollowUpDTO manualFollowUpDTO) {
        startPage();
        List<ManualFollowUpVO> list = signPatientManageRouteService.selectManualFollowUpList(manualFollowUpDTO);
        return getDataTable(list);
    }

    /**
     * 查询人工随访患者基本信息
     */
    @GetMapping("/selectFollowPatientInfo/{id}")
    public AjaxResult selectFollowPatientInfo(@PathVariable Long id) {
        return signPatientManageRouteService.selectFollowPatientInfo(id);
    }

    /**
     * 人工随访代办处理
     */
    @PostMapping("/addPatientQuestionResult")
    public AjaxResult addPatientQuestionResult(@RequestBody PatientQuestionSubmitResultDTO dto) {
        return signPatientManageRouteService.addPatientQuestionResult(dto);
    }
}
