package com.joju.datamanager.controller;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.joju.datamanager.common.annotation.EleganceLog;
import com.joju.datamanager.common.result.Result;
import com.joju.datamanager.common.result.ResultUtil;
import com.joju.datamanager.model.viewmodel.PatientList;
import com.joju.datamanager.service.PatientListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @description: 历史就诊测试用接口
 * @author: Mr.zs
 * @create: 2024-03-28 17:14
 **/

@RestController
@RequestMapping("/patientList")
public class PatientListController {


    @Autowired
    PatientListService patientListService;


    @GetMapping("/getPatientListByNameAndIdCard")
    @EleganceLog(description = "获取历史就诊记录的本地测试数据")
    public Result getPatientListByNameAndIdCard(String patientName, String idCard) {

        List<PatientList> list = patientListService.list(new QueryWrapper<PatientList>().eq("patient_name", patientName).eq("idcard", idCard).orderBy(true, false, "register_date"));
        if (!CollUtil.isEmpty(list)) {
            return ResultUtil.successData(list);
        }
        return ResultUtil.failureMsg("获取失败");

    }


}
