package com.ruoyi.web.work.api;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.web.work.api.config.BaseController;
import com.ruoyi.web.work.domain.FollowRecord;
import com.ruoyi.web.work.domain.dto.FollowRecordDto;
import com.ruoyi.web.work.domain.vo.FollowRecordVoList;
import com.ruoyi.web.work.service.IFollowRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 回访模板管理
 *
 * @author lsw
 * @date 2024-07-11
 */
@RestController
@RequestMapping("/app/follow")
public class Api_FollowController extends BaseController {

    @Autowired
    private IFollowRecordService followRecordService;

    @GetMapping("/list")
    public TableDataInfo list(FollowRecord followRecord) {
        followRecord.setPatientId(getUser().getPatientId());
        startPage();
        List<FollowRecordVoList> list = followRecordService.selectAppList(followRecord);
        return getDataTable(list);
    }

    @PostMapping("/push")
    public AjaxResult push(@Validated @RequestBody FollowRecordDto dto) {
        return followRecordService.push(dto);
    }

    @PostMapping("/read/{id}")
    public AjaxResult read(@PathVariable("id") Long id) {
        return followRecordService.read(id);
    }

    @GetMapping(value = "/detail/{id}")
    public AjaxResult detail(@PathVariable("id") Long id) {
        return followRecordService.detail(id);
    }
}
