package com.brframework.webapppatch.service.impl;

import com.alibaba.fastjson.JSON;
import com.brframework.commonwebbase.service.DictionaryService;
import com.brframework.webapppatch.domain.AppPatchConfig;
import com.brframework.webapppatch.service.PatchConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author xu
 * @date 2019/11/14 17:17
 */
@Service
public class PatchConfigServiceImpl implements PatchConfigService {

    @Autowired
    DictionaryService dictionaryService;

    public static final String KEY_APP_PATCH_CONFIG = "KEY_APP_PATCH_CONFIG";

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

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

}
