package com.sckw.payment.model;

import com.sckw.core.model.constant.Global;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;


/**
 * @author xucaiqin
 * @date 2023-09-06 18:58:51
 */
@Schema(description = "跳转URL配置类")
@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "msg")
@RefreshScope
public class JumpUrlConfig {
    /**
     * 销售收款对账
     */
    @Schema(description = "URL映射配置")
    private Map<String, JumpUrl> url = new HashMap<>();

    public Map<String, String> getMapUrl(String key) {
        JumpUrl jumpUrl = url.get(key);
        if (Objects.nonNull(jumpUrl)) {
            return new HashMap<>(Global.NUMERICAL_SIXTEEN) {{
                put("pc", jumpUrl.getPc());
                put("app", jumpUrl.getApp());
            }};
        }
        return new HashMap<>(Global.NUMERICAL_SIXTEEN);
    }


}