# -*- coding: utf-8 -*-

from kodo.basemodels import PlatformMixin
from utils.redis.connect import r
from utils.redis.rkeys import APP_SETTINGS_INFO


def set_app_settings_info(appset):
    """ 设置 APP 设置信息 """
    r.setjson(APP_SETTINGS_INFO % (appset.platform, appset.channel, appset.version), appset.data)


def del_app_settings_info(appset):
    """ 删除 APP 设置信息 """
    r.delete(APP_SETTINGS_INFO % (appset.platform, appset.channel, appset.version))


def get_app_settings_info(platform, channel, version):
    """ 获取 APP 设置信息 """
    platform = platform if isinstance(platform, int) else PlatformMixin.Platforms[platform]
    return r.getjson(APP_SETTINGS_INFO % (platform, channel, version))
