com.spring.boxes.option.config.Configure Maven / Gradle / Ivy
The newest version!
package com.spring.boxes.option.config;
import java.util.List;
import com.spring.boxes.dollar.support.widget.RichText;
import org.springframework.data.redis.core.StringRedisTemplate;
import com.google.common.collect.Lists;
import com.spring.boxes.dollar.JSONUtils;
import com.spring.boxes.dollar.StringUtils;
import com.spring.boxes.dollar.support.AppVersion;
import com.spring.boxes.dollar.support.Utility;
import com.spring.boxes.dollar.term.ItemView;
// 应用全局配置文件(配置中心)
public class Configure {
public static final String _K = "_k";
private final StringRedisTemplate stringRedisTemplate;
public Configure(StringRedisTemplate stringRedisTemplate) {
this.stringRedisTemplate = stringRedisTemplate;
}
public static Configure newInstance(StringRedisTemplate stringRedisTemplate) {
return new Configure(stringRedisTemplate);
}
// 获取通用配置Key
public String getKey(long appId, String key) {
return String.format("%s:%s:%s", _K, appId, key);
}
// 获取应用更新版本: _k:10000:appVersion:ios
public AppVersion getAppVersion(long appId, String appType) {
String key = String.format("appVersion:%s", Utility.toLowerCase(appType));
String value = stringRedisTemplate.opsForValue().get(getKey(appId, key));
return StringUtils.isNotBlank(value) ? JSONUtils.fromJSON(value, AppVersion.class) : null;
}
// 圈子分类集合
public List getSquareTypeList(long appId) {
String key = "squareClassList";
String value = stringRedisTemplate.opsForValue().get(getKey(appId, key));
return StringUtils.isNotBlank(value) ? JSONUtils.fromJSON(value, List.class, ItemView.class) : Lists.newArrayList();
}
// 隐私策略
public RichText getPrivacyPolicy(long appId) {
String key = "privacyPolicy";
String value = stringRedisTemplate.opsForValue().get(getKey(appId, key));
return StringUtils.isNotBlank(value) ? JSONUtils.fromJSON(value, RichText.class) : null;
}
// 用户协议
public RichText getUserAgreement(long appId) {
String key = "userAgreement";
String value = stringRedisTemplate.opsForValue().get(getKey(appId, key));
return StringUtils.isNotBlank(value) ? JSONUtils.fromJSON(value, RichText.class) : null;
}
// 获取资源位
public List getGriddleList(long appId, String page){
String key = String.format("griddleList:%s", Utility.toLowerCase(page));
String value = stringRedisTemplate.opsForValue().get(getKey(appId, key));
return StringUtils.isNotBlank(value) ? JSONUtils.fromJSON(value, List.class, ItemView.class) : Lists.newArrayList();
}
// 获取资源位
public List getBannerList(long appId, String page){
String key = String.format("bannerList:%s", Utility.toLowerCase(page));
String value = stringRedisTemplate.opsForValue().get(getKey(appId, key));
return StringUtils.isNotBlank(value) ? JSONUtils.fromJSON(value, List.class, ItemView.class) : Lists.newArrayList();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy