package com.brframework.commonapppush.service.impl;

import com.alibaba.fastjson.JSON;
import com.brframework.commonapppush.domain.UPushConfig;
import com.brframework.commonapppush.service.UPushConfigService;
import com.brframework.commonwebbase.service.DictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 友盟推送配置
 * @author xu
 * @date 2019/11/18 19:40
 */
@Service
public class UPushConfigServiceImpl implements UPushConfigService {
    @Autowired
    DictionaryService dictionaryService;

    public static final String KEY_UPUSH_CONFIG = "KEY_UPUSH_CONFIG";

    @Override
    public UPushConfig get() {
        String json = dictionaryService.get(KEY_UPUSH_CONFIG);
        return JSON.parseObject(json, UPushConfig.class);
    }

    @Override
    public void set(UPushConfig config) {
        dictionaryService.set(KEY_UPUSH_CONFIG, JSON.toJSONString(config));
    }

}
