package com.cf.imes.framework.ip.core.property;

import com.cf.imes.framework.common.util.encrypt.AesUtils;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;


/**
 * ip查询服务配置
 * @author Gqr
 * @since 2024/10/30 9:59
 */
@ConfigurationProperties(prefix = "chenfeng.ipquery")
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class IPQueryProperties {

    @Value("${chenfeng.encrypt.publicKey:}")
    private String publicKey;

    /**
     * 开关
     */
    private boolean enable;

    /**
     * 接口地址
     */
    private String apiUrl;

    /**
     * 接口认证编码
     */
    private String appCode;

    public boolean isEnable() {
        return enable;
    }

    public void setEnable(boolean enable) {
        this.enable = enable;
    }

    public String getAppCode() {
        return appCode;
    }

    public IPQueryProperties setAppCode(String appCode) {
        this.appCode = AesUtils.decrypt(appCode, publicKey);
        return this;
    }

    public String getApiUrl() {
        return apiUrl;
    }

    public void setApiUrl(String apiUrl) {
        this.apiUrl = apiUrl;
    }
}
