From 02b81b52fbba024632f354d93f48586043a818ed Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 19 一月 2019 09:52:58 +0800
Subject: [PATCH] 测试
---
fanli/src/main/java/com/yeshi/fanli/service/impl/config/ConfigServiceImpl.java | 57 +++++++++++++++++++++++++++++++++++----------------------
1 files changed, 35 insertions(+), 22 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/config/ConfigServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/config/ConfigServiceImpl.java
index 47776f8..b706acd 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/config/ConfigServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/config/ConfigServiceImpl.java
@@ -12,6 +12,7 @@
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;
@@ -35,42 +36,41 @@
@Override
public List<Config> listObjects(String key, int page) {
- int start = (page-1) * Constant.PAGE_SIZE;
- StringBuffer hqlBuf=new StringBuffer("from Config pr where 1=1 ");
-
- if(key !=null && !"".equals(key.trim())){
+ int start = (page - 1) * Constant.PAGE_SIZE;
+ StringBuffer hqlBuf = new StringBuffer("from Config pr where 1=1 ");
+
+ if (key != null && !"".equals(key.trim())) {
hqlBuf.append(" and (pr.name like ? )");
}
-
+
hqlBuf.append(" order by pr.id desc ");
String hql = hqlBuf.toString();
- if(hql.contains("pr.name")){
- return configDao.list(hqlBuf.toString(), start, Constant.PAGE_SIZE, new Serializable[]{"%"+key+"%"});
+ if (hql.contains("pr.name")) {
+ return configDao.list(hqlBuf.toString(), start, Constant.PAGE_SIZE, new Serializable[] { "%" + key + "%" });
} else {
- return configDao.list(hqlBuf.toString(), start, Constant.PAGE_SIZE, new Serializable[]{});
+ return configDao.list(hqlBuf.toString(), start, Constant.PAGE_SIZE, new Serializable[] {});
}
-
+
}
-
+
@Override
public int getCount(String key, int page) {
-
- StringBuffer hqlBuf=new StringBuffer("select count(*) from Config pr where 1=1 ");
-
- if(key !=null && !"".equals(key.trim())){
+
+ StringBuffer hqlBuf = new StringBuffer("select count(*) from Config pr where 1=1 ");
+
+ if (key != null && !"".equals(key.trim())) {
hqlBuf.append(" and (pr.name like ? )");
}
-
+
String hql = hqlBuf.toString();
-
- if(hql.contains("pr.name")){
- return (int) configDao.getCount(hqlBuf.toString(),new Serializable[]{"%"+key+"%"});
+
+ if (hql.contains("pr.name")) {
+ return (int) configDao.getCount(hqlBuf.toString(), new Serializable[] { "%" + key + "%" });
} else {
- return (int) configDao.getCount(hqlBuf.toString(), new Serializable[]{});
+ return (int) configDao.getCount(hqlBuf.toString(), new Serializable[] {});
}
}
-
@CacheEvict(value = "config", allEntries = true)
@Transactional
public void update(List<Config> list) {
@@ -142,6 +142,8 @@
@Override
public String getH5Host() {
String value = get("h5_url");
+ String[] sts = value.split(",");
+ value = sts[(int) (sts.length * Math.random())];
return value.trim();
}
@@ -186,10 +188,21 @@
String value = get("home_weex_url");
return value;
}
-
+
@Override
public Config getConfig(long id) {
return configDao.find(Config.class, 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;
+ }
+
}
--
Gitblit v1.8.0