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.callnumber.CallNumbers;
import com.joju.datamanager.service.CallNumbersService;
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-27 19:00
 **/

@RestController
@RequestMapping("/callNumbers")
public class LineUpToCallNumbersController {

    @Autowired
    CallNumbersService callNumbersService;


    @GetMapping("/getCallNumberByIdentity")
    @EleganceLog(description = "排队叫号获取线上数据")
    public Result getCallNumberByIdentity(String identity) {

        List<CallNumbers> callNumbersList = callNumbersService.getCallNumberByIdentity(identity);
        if (!CollUtil.isEmpty(callNumbersList)) {
            return ResultUtil.successData(callNumbersList);
        }
        return ResultUtil.failureMsg("获取失败");
    }

    @GetMapping("/getCallNumber")
    @EleganceLog(description = "排队叫号获取本地测试数据")
    public Result getCallNumber(String identity) {
        List<CallNumbers> list = callNumbersService.list(new QueryWrapper<CallNumbers>().eq("Card_no", identity).ne("adiagnostic_status", "已就诊"));
        if (!CollUtil.isEmpty(list)) {
            return ResultUtil.successData(list);
        }
        return ResultUtil.failureMsg("获取失败");
    }

}
