package com.persagy.dmp.file.config;

import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.Map;

@Data
@Configuration
@ConfigurationProperties(prefix = "persagy.hdfs.file")
public class HdfsFileConfiguration {

    private static Map<String,String> accounts;

    /***
     * Description: 根据账号id获取密码
     * @param accountId : 账号id
     * @return : java.lang.String
     * @author : lijie
     * @date :2021/9/7 22:43
     * Update By lijie 2021/9/7 22:43
     */
    public static String getSecretById(String accountId){
        if (MapUtil.isEmpty(accounts)){
            return StrUtil.EMPTY;
        }
        return accounts.getOrDefault(accountId, StrUtil.EMPTY);
    }
    /***
     * Description: 根据账号id获取密码
     * @param accountId : 账号id
     * @return : java.lang.String
     * @author : lijie
     * @date :2021/9/7 22:43
     * Update By lijie 2021/9/7 22:43
     */
    public static Boolean checkAccountExists(String accountId){
        if (MapUtil.isEmpty(accounts)){
            return false;
        }
        return accounts.containsKey(accountId);
    }


}
