package com.hr.config;

/**
 * @author yaoy
 * @createTime 2025/10/17 13:51
 **/


import com.hr.repository.service.impl.EsignServiceImpl;
import com.hr.util.ClientHelper;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@ConfigurationProperties("esign.config")
@Data
@Slf4j
public class EsignConfig {
    private Map<String,String> porps;
    @Autowired
    private EsignServiceImpl esignService;

    //应用ID,沙箱环境7开头，正式环境5开头
    private String projectId ;
    //
//    //应用Secret
//    @Value("${esign.secret}")
    private String secret ;
    //
//    //协议类型（可选HTTP或HTTPS)
//    private final HttpType HTTP_TYPE = HttpType.HTTP;
//
//    //e签宝环境地址 模拟环境：http://smlitsm.tsign.cn:8080    正式环境：http://sdkapi.esign.cn
//    @Value("${esign.apiHost}")
    private String apiHost;

    private Boolean istest;

    public Boolean getIstest() {
        return istest;
    }

    @Bean
    public Object initEsign() {
        //开放平台地址
        String API_URL = apiHost + "/tgmonitor/rest/app!getAPIInfo2";
        log.info("{}初始化e签宝配置完成API_HOST:{}", "initEsign",apiHost);
        ClientHelper.initProps(projectId, secret, API_URL);
        esignService.initEsign();
        return new Object();
    }

}