package com.boman.web.core.controller;

import com.alibaba.fastjson.JSONObject;
import com.boman.domain.dto.AjaxResult;
import com.boman.web.core.service.vaccineInfo.IVaccineInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author shiqian
 * @date 2021年11月18日 15:39
 **/
@RequestMapping("/akm")
@RestController
public class AnkangMaController {

    @Resource
    private IVaccineInfoService vaccineInfoService;

    /**
     * 功能描述: 安康码根据身份证号码查询信息
     *
     * @param idCard idCard
     * @return com.boman.domain.dto.AjaxResult
     */
    @GetMapping("/info/{idCard}")
    public AjaxResult getByIdCard(@PathVariable("idCard") String idCard) {
        if (StringUtils.isBlank(idCard) || "null".equals(idCard)) {
            return AjaxResult.error("身份证不能为空");
        }

        final JSONObject info = vaccineInfoService.getByIdCard(idCard);
        if (info == null) {
            return AjaxResult.error("档案库中无此人，身份证：" + idCard);
        }

        return AjaxResult.success("成功", info);
    }


}
