package com.example.his.api;

import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.http.HtmlUtil;
import com.example.his.api.db.dao.CheckupResultDao;
import com.example.his.api.exception.HisException;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.iai.v20200303.IaiClient;
import com.tencentcloudapi.iai.v20200303.models.GetPersonBaseInfoRequest;
import com.tencentcloudapi.iai.v20200303.models.GetPersonBaseInfoResponse;
import lombok.SneakyThrows;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.core.RedisOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.SessionCallback;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class HisApiApplicationTests {

    @Value("${tencent.cloud.secretId}")
    private String secretId;

    @Value("${tencent.cloud.secretKey}")
    private String secretKey;

    @Value("${tencent.cloud.face.groupId}")
    private String groupId;

    @Value("${tencent.cloud.face.region}")
    private String region;

    @Test
    void test() {
        boolean result;

        Credential cred = new Credential(secretId, secretKey);
        IaiClient client = new IaiClient(cred, region);
        GetPersonBaseInfoRequest getPersonBaseInfoRequest = new GetPersonBaseInfoRequest();
        getPersonBaseInfoRequest.setPersonId("123456");
        GetPersonBaseInfoResponse getPersonBaseInfoResponse = null;
        try {
            getPersonBaseInfoResponse = client.GetPersonBaseInfo(getPersonBaseInfoRequest);
        } catch (TencentCloudSDKException e) {
            if (!e.getErrorCode().equals("InvalidParameterValue.PersonIdNotExist")) {
                throw new HisException("查询人员库失败");
            }
        }

        String personName = getPersonBaseInfoResponse.getPersonName();
    }
}
