package cn.axzo.msg.center.inside.notices.config;

import com.alibaba.fastjson.JSON;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;

/**
 * @author yanglin
 */
@Data
@RefreshScope
@Configuration
@ConfigurationProperties(prefix = "upush.channels")
public class PushProps {

    /**
     * oppo渠道配置
     */
    private ChannelConfig oppoChannelConfig = new ChannelConfig(
            "oppo渠道配置",
            // 管理端
            new ChannelIds("cmp", "67a686e9", "38a2db69"),
            // 工人端
            new ChannelIds("cm", "203be53b", "3163b193"));

    /**
     * 小米渠道配置
     */
    private ChannelConfig xiaomiChannelConfig = new ChannelConfig(
            "小米渠道配置",
            // 管理端
            new ChannelIds("cmp", "122345", "122346"),
            // 工人端
            new ChannelIds("cm", "122431", "122432"));

    /**
     * 不同app的渠道配置
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class ChannelConfig {

        /**
         * 渠道名称
         */
        private String channelName;

        /**
         * 管理端配置
         */
        private ChannelIds managerIds;

        /**
         * 工人端配置
         */
        private ChannelIds workerIds;

        public String toString() {
            return JSON.toJSONString(this);
        }
    }

    /**
     * 不同渠道的channelId配置
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class ChannelIds {

        private String appType;

        /**
         * 个人工作信息渠道
         */
        private String workMessageChannelId;

        /**
         * 推广信息、运营信息渠道
         */
        private String opMessageChannelId;

        @Override
        public String toString() {
            return JSON.toJSONString(this);
        }
    }

}