| | |
| | | package com.yeshi.fanli.service.impl.config;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | |
| | | import com.yeshi.fanli.dao.mybatis.ConfigMapper;
|
| | | import com.yeshi.fanli.entity.common.Config;
|
| | | import com.yeshi.fanli.entity.config.AppHomeFloatImg;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | import com.yeshi.fanli.entity.xcx.XCXSettingConfig;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
| | |
|
| | | @Resource
|
| | | private ConfigMapper configMapper;
|
| | | |
| | |
|
| | | @Cacheable(value = "config")
|
| | | public List<Config> getAllList() {
|
| | |
| | | @Transactional
|
| | | public void update(List<Config> list) {
|
| | | for (Config config : list) {
|
| | | if (config.getValue() == null) {
|
| | | config.setValue("");
|
| | | }
|
| | | config.setCreatetime(new Date().getTime() + "");
|
| | | configMapper.updateByPrimaryKeySelective(config);
|
| | | }
|
| | |
| | |
|
| | | @CacheEvict(value = "config", allEntries = true)
|
| | | public void update(Config config) {
|
| | | if (config.getValue() == null)
|
| | | config.setValue("");
|
| | | |
| | | config.setCreatetime(new Date().getTime() + "");
|
| | | configMapper.updateByPrimaryKeySelective(config);
|
| | | }
|
| | |
| | | if (version == null)
|
| | | return false;
|
| | |
|
| | | String value = get("xcx_setting");
|
| | | String value = get(ConfigKeyEnum.xcxSetting.getKey());
|
| | | if (StringUtil.isNullOrEmpty(value))
|
| | | return false;
|
| | | JSONArray array = JSONArray.fromObject(value);
|
| | |
| | |
|
| | | @Override
|
| | | public XCXSettingConfig getXCXInfoByGhId(String ghId) {
|
| | | String value = get("xcx_setting");
|
| | | String value = get(ConfigKeyEnum.xcxSetting.getKey());
|
| | | JSONArray array = JSONArray.fromObject(value);
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | XCXSettingConfig config = new Gson().fromJson(array.optJSONObject(i).toString(), XCXSettingConfig.class);
|
| | |
| | |
|
| | | @Override
|
| | | public String getH5Host() {
|
| | | String value = get("h5_url");
|
| | | String value = get(ConfigKeyEnum.h5Url.getKey());
|
| | | String[] sts = value.split(",");
|
| | | value = sts[(int) (sts.length * Math.random())];
|
| | | return value.trim();
|
| | |
| | | @Cacheable(value = "config", key = "'iosOnLining'+#version")
|
| | | @Override
|
| | | public boolean iosOnLining(int version) {
|
| | | String value = get("ios_onling_version");
|
| | | String value = get(ConfigKeyEnum.iosOnlingVersion.getKey());
|
| | | if (StringUtil.isNullOrEmpty(value))
|
| | | return false;
|
| | | return version >= Integer.parseInt(value);
|
| | |
| | | @Cacheable(value = "config", key = "'isConvertTaoBaoLinkInServer'")
|
| | | @Override
|
| | | public boolean isConvertTaoBaoLinkInServer() {
|
| | | String value = get("convert_taobao_link_in_server");
|
| | | String value = get(ConfigKeyEnum.convertTaoBaoLinkInServer.getKey());
|
| | | if (StringUtil.isNullOrEmpty(value))
|
| | | return false;
|
| | | if ("1".equalsIgnoreCase(value.trim()))
|
| | |
| | | @Cacheable(value = "config", key = "'getAppHomeFloatImg'")
|
| | | @Override
|
| | | public AppHomeFloatImg getAppHomeFloatImg() {
|
| | | String value = get("app_float_img");
|
| | | String value = get(ConfigKeyEnum.appFloatImg.getKey());
|
| | | if (!StringUtil.isNullOrEmpty(value)) {
|
| | | Gson gson = new Gson();
|
| | | AppHomeFloatImg appHomeFloatImg = gson.fromJson(value, AppHomeFloatImg.class);
|
| | |
| | | @Cacheable(value = "config", key = "'getHomeWEEXUrl'")
|
| | | @Override
|
| | | public String getHomeWEEXUrl() {
|
| | | String value = get("home_weex_url");
|
| | | String value = get(ConfigKeyEnum.homeWeexUrl.getKey());
|
| | | return value;
|
| | | }
|
| | |
|
| | |
| | |
|
| | | @Override
|
| | | public ProxyIP getTaoBaoProxyIP() {
|
| | | String value = get("taobao_proxy_ip");
|
| | | String value = get(ConfigKeyEnum.taobaoProxyIP.getKey());
|
| | | try {
|
| | | String[] sts = value.split(":");
|
| | | return new ProxyIP(sts[0], Integer.parseInt(sts[1]));
|
| | |
| | |
|
| | | @Override
|
| | | public String getAppHomeFloatNotifyImg() {
|
| | |
|
| | | return get("home_float_notify_img");
|
| | | return get(ConfigKeyEnum.homeFloatNotifyImg.getKey());
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | @Cacheable(value = "config", key = "'getSearchDiscoveryKeys'")
|
| | | @Override
|
| | | public String getSearchDiscoveryKeys() {
|
| | | List<Config> list = configMapper.listByKey("search_discovery_keys", null, null);
|
| | | List<Config> list = configMapper.listByKey(ConfigKeyEnum.searchDiscoveryKeys.getKey(), null, null);
|
| | | if (list == null || list.size() == 0)
|
| | | return null;
|
| | |
|
| | |
| | | String hotWords = DaTaoKeApiUtil.getHotWords();
|
| | | if (StringUtil.isNullOrEmpty(hotWords))
|
| | | return;
|
| | |
|
| | | config.setValue(hotWords);
|
| | | JSONArray array = JSONArray.fromObject(hotWords);
|
| | | String reg = "^([\u4E00-\uFA29]|[\uE7C7-\uE7F3]|[a-zA-Z0-9_-]){1,20}$";
|
| | | List<String> list = new ArrayList<>();
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | String key = array.optString(i);
|
| | | if (key.matches(reg)) {
|
| | | list.add(key);
|
| | | }
|
| | | }
|
| | | config.setValue(new Gson().toJson(list));
|
| | | config.setCreatetime(currentTime + "");
|
| | | configMapper.updateByPrimaryKeySelective(config);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public Config getConfigBykeyNoCache(String key) {
|
| | | List<Config> list = configMapper.listByKey(key, null, null);
|
| | | if (list.size() == 0) {
|
| | | return null;
|
| | | }
|
| | | return list.get(0);
|
| | | }
|
| | | }
|