| | |
| | | package com.yeshi.fanli.service.impl.config;
|
| | |
|
| | | import java.io.Serializable;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | |
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.entity.ProxyIP;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dao.config.ConfigDao;
|
| | | 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.xcx.XCXSettingConfig;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | |
| | | public class ConfigServiceImpl implements ConfigService {
|
| | |
|
| | | @Resource
|
| | | private ConfigDao configDao;
|
| | | private ConfigMapper configMapper;
|
| | |
|
| | | @Cacheable(value = "config")
|
| | | public List<Config> getAllList() {
|
| | | return configDao.list("from Config");
|
| | | return configMapper.listAll();
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Config> listObjects(String key, int page) {
|
| | | int start = (page - 1) * Constant.PAGE_SIZE;
|
| | | return configMapper.listSearchByName(key, start, Constant.PAGE_SIZE);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int getCount(String key) {
|
| | | return (int) configMapper.countSearchByName(key);
|
| | | }
|
| | |
|
| | | @CacheEvict(value = "config", allEntries = true)
|
| | |
| | | public void update(List<Config> list) {
|
| | | for (Config config : list) {
|
| | | config.setCreatetime(new Date().getTime() + "");
|
| | | configDao.update(config);
|
| | | configMapper.updateByPrimaryKeySelective(config);
|
| | | }
|
| | | }
|
| | |
|
| | | @CacheEvict(value = "config", allEntries = true)
|
| | | public void update(Config config) {
|
| | | config.setCreatetime(new Date().getTime() + "");
|
| | | configDao.update(config);
|
| | | configMapper.updateByPrimaryKeySelective(config);
|
| | | }
|
| | |
|
| | | @Cacheable(value = "config", key = "#p0+'Str'")
|
| | | public String get(String key) {
|
| | | List<Config> list = configDao.list("from Config c where c.key=? ", new Serializable[] { key });
|
| | | List<Config> list = configMapper.listByKey(key);
|
| | | if (list.size() == 0) {
|
| | | return null;
|
| | | }
|
| | |
| | |
|
| | | @Cacheable(value = "config", key = "#p0")
|
| | | public Config getConfig(String key) {
|
| | | List<Config> list = configDao.list("from Config c where c.key=? ", new Serializable[] { key });
|
| | | List<Config> list = configMapper.listByKey(key);
|
| | | if (list.size() == 0) {
|
| | | return null;
|
| | | }
|
| | |
| | | @Override
|
| | | public String getH5Host() {
|
| | | String value = get("h5_url");
|
| | | String[] sts = value.split(",");
|
| | | value = sts[(int) (sts.length * Math.random())];
|
| | | return value.trim();
|
| | | }
|
| | |
|
| | |
| | | return value;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Config getConfig(long id) {
|
| | | return configMapper.selectByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public ProxyIP getTaoBaoProxyIP() {
|
| | | String value = get("taobao_proxy_ip");
|
| | | try {
|
| | | String[] sts = value.split(":");
|
| | | return new ProxyIP(sts[0], Integer.parseInt(sts[1]));
|
| | | } catch (Exception e) {
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String getAppHomeFloatNotifyImg() {
|
| | |
|
| | | return get("home_float_notify_img");
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void save(Config config) {
|
| | | List<Config> list = configMapper.listByKey(config.getKey());
|
| | | if (list == null || list.size() == 0) {
|
| | | configMapper.insertSelective(config);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|