RabbitMqCustomConfig.java 2.82 KB
package com.topdraw.config;

import lombok.Data;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.List;
import java.util.Map;

@Data
@Configuration
@ConfigurationProperties(prefix = "service.mq")
public class RabbitMqCustomConfig {

    private List<Map<String, String>> list;

    /**
     * viewRecord
     * @return
     */
    public Map<String, String> getViewRecordInfo() {

        if (CollectionUtils.isNotEmpty(list)) {

            for (Map<String, String> map : list) {
                String type = map.get("source");
                if (type.equalsIgnoreCase("viewRecord")) {
                    return map;
                }
            }

        }

        return null;
    }

    /**
     * ucg_event
     * @return
     */
    public Map<String, String> getUcgEventInfo() {

        if (CollectionUtils.isNotEmpty(list)) {

            for (Map<String, String> map : list) {
                String type = map.get("source");
                if (type.equalsIgnoreCase("event")) {
                    return map;
                }
            }

        }

        return null;
    }

    /**
     * ucg_collection
     * @return
     */
    public Map<String, String> getUcgCollectionInfo() {

        if (CollectionUtils.isNotEmpty(list)) {

            for (Map<String, String> map : list) {
                String type = map.get("source");
                if (type.equalsIgnoreCase("collection")) {
                    return map;
                }
            }

        }

        return null;
    }

    /**
     * uce
     * @return
     */
    public Map<String, String> getUceInfo() {

        if (CollectionUtils.isNotEmpty(list)) {

            for (Map<String, String> map : list) {
                String type = map.get("source");
                if (type.equalsIgnoreCase("uce")) {
                    return map;
                }
            }

        }

        return null;
    }

    /**
     * eventBus
     * @return
     */
    public Map<String, String> getEventBusInfo() {

        if (CollectionUtils.isNotEmpty(list)) {

            for (Map<String, String> map : list) {
                String type = map.get("source");
                if (type.equalsIgnoreCase("eventBus")) {
                    return map;
                }
            }

        }

        return null;
    }

    /**
     * wechat
     * @return
     */
    public Map<String, String> getWechatInfo() {

        if (CollectionUtils.isNotEmpty(list)) {

            for (Map<String, String> map : list) {
                String type = map.get("source");
                if (type.equalsIgnoreCase("wechat")) {
                    return map;
                }
            }

        }

        return null;
    }
}