diff --git a/src/main/java/com/rymcu/vertical/config/RedisProperties.java b/src/main/java/com/rymcu/vertical/config/RedisProperties.java new file mode 100644 index 0000000..02ae5d2 --- /dev/null +++ b/src/main/java/com/rymcu/vertical/config/RedisProperties.java @@ -0,0 +1,124 @@ +package com.rymcu.vertical.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import redis.clients.jedis.JedisPoolConfig; +import redis.clients.jedis.Protocol; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLParameters; +import javax.net.ssl.SSLSocketFactory; + +/** + * @author 007 + */ +@ConfigurationProperties(prefix = "spring.redis") +public class RedisProperties extends JedisPoolConfig { + private String host = Protocol.DEFAULT_HOST; + private int port = Protocol.DEFAULT_PORT; + private String password; + private int database = 1; + private int connectionTimeout = Protocol.DEFAULT_TIMEOUT; + private int soTimeout = Protocol.DEFAULT_TIMEOUT; + private String clientName; + private boolean ssl; + private SSLSocketFactory sslSocketFactory; + private SSLParameters sslParameters; + private HostnameVerifier hostnameVerifier; + + public boolean isSsl() { + return ssl; + } + + public void setSsl(boolean ssl) { + this.ssl = ssl; + } + + public SSLSocketFactory getSslSocketFactory() { + return sslSocketFactory; + } + + public void setSslSocketFactory(SSLSocketFactory sslSocketFactory) { + this.sslSocketFactory = sslSocketFactory; + } + + public SSLParameters getSslParameters() { + return sslParameters; + } + + public void setSslParameters(SSLParameters sslParameters) { + this.sslParameters = sslParameters; + } + + public HostnameVerifier getHostnameVerifier() { + return hostnameVerifier; + } + + public void setHostnameVerifier(HostnameVerifier hostnameVerifier) { + this.hostnameVerifier = hostnameVerifier; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + if (host == null || "".equals(host)) { + host = Protocol.DEFAULT_HOST; + } + this.host = host; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + if ("".equals(password)) { + password = null; + } + this.password = password; + } + + public int getDatabase() { + return database; + } + + public void setDatabase(int database) { + this.database = database; + } + + public String getClientName() { + return clientName; + } + + public void setClientName(String clientName) { + if ("".equals(clientName)) { + clientName = null; + } + this.clientName = clientName; + } + + public int getConnectionTimeout() { + return connectionTimeout; + } + + public void setConnectionTimeout(int connectionTimeout) { + this.connectionTimeout = connectionTimeout; + } + + public int getSoTimeout() { + return soTimeout; + } + + public void setSoTimeout(int soTimeout) { + this.soTimeout = soTimeout; + } +} diff --git a/src/main/java/com/rymcu/vertical/core/service/redis/impl/RedisServiceImpl.java b/src/main/java/com/rymcu/vertical/core/service/redis/impl/RedisServiceImpl.java index 90ef3af..85dc35a 100644 --- a/src/main/java/com/rymcu/vertical/core/service/redis/impl/RedisServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/core/service/redis/impl/RedisServiceImpl.java @@ -9,6 +9,7 @@ import com.rymcu.vertical.core.service.redis.RedisService; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import redis.clients.jedis.Jedis; @@ -27,6 +28,7 @@ import java.util.*; * 16/10/30 下午5:28 */ @Component("redisService") +@EnableConfigurationProperties({RedisProperties.class}) public class RedisServiceImpl implements RedisService { private static final Logger logger = LoggerFactory.getLogger(RedisServiceImpl.class); diff --git a/src/main/java/com/rymcu/vertical/mapper/WxUserMapper.java b/src/main/java/com/rymcu/vertical/mapper/WxUserMapper.java deleted file mode 100644 index 9e941d3..0000000 --- a/src/main/java/com/rymcu/vertical/mapper/WxUserMapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.rymcu.vertical.mapper; - -import com.rymcu.vertical.core.mapper.Mapper; -import com.rymcu.vertical.entity.WxUser; - -/** - * @author ronger - */ -public interface WxUserMapper extends Mapper { -} diff --git a/src/main/java/com/rymcu/vertical/service/WxUserService.java b/src/main/java/com/rymcu/vertical/service/WxUserService.java deleted file mode 100644 index 59e8527..0000000 --- a/src/main/java/com/rymcu/vertical/service/WxUserService.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.rymcu.vertical.service; - -import com.rymcu.vertical.core.service.Service; -import com.rymcu.vertical.entity.WxUser; -import me.chanjar.weixin.mp.bean.result.WxMpUser; - -/** - * @author ronger - */ -public interface WxUserService extends Service { - - WxUser saveUser(WxMpUser wxMpUser, String appId); - -} diff --git a/src/main/java/com/rymcu/vertical/service/impl/WxUserServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/WxUserServiceImpl.java deleted file mode 100644 index 3309f0d..0000000 --- a/src/main/java/com/rymcu/vertical/service/impl/WxUserServiceImpl.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.rymcu.vertical.service.impl; - -import com.rymcu.vertical.core.service.AbstractService; -import com.rymcu.vertical.entity.WxUser; -import com.rymcu.vertical.mapper.WxUserMapper; -import com.rymcu.vertical.service.WxUserService; -import me.chanjar.weixin.mp.bean.result.WxMpUser; -import org.apache.commons.lang.StringUtils; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.List; - -/** - * @author ronger - */ -@Service -public class WxUserServiceImpl extends AbstractService implements WxUserService { - - @Resource - private WxUserMapper wxUserMapper; - - @Override - public WxUser saveUser(WxMpUser wxMpUser, String appId) { - WxUser searchWxUser = new WxUser(); - if (StringUtils.isBlank(wxMpUser.getUnionId())) { - searchWxUser.setUnionId(wxMpUser.getUnionId()); - } else { - searchWxUser.setAppId(appId); - searchWxUser.setOpenId(searchWxUser.getOpenId()); - } - List wxUsers = wxUserMapper.select(searchWxUser); - WxUser wxUser; - if (wxUsers.isEmpty()) { - wxUser = new WxUser(); - wxUser.setAppId(appId); - wxUser = copyWxUser(wxMpUser,wxUser); - wxUserMapper.insertSelective(wxUser); - } else { - wxUser = wxUsers.get(0); - wxUser = copyWxUser(wxMpUser,wxUser); - wxUserMapper.updateByPrimaryKeySelective(wxUser); - } - return wxUser; - } - - private WxUser copyWxUser(WxMpUser wxMpUser, WxUser wxUser) { - wxUser.setNickname(wxMpUser.getNickname()); - wxUser.setHeadImgUrl(wxMpUser.getHeadImgUrl()); - wxUser.setCountry(wxMpUser.getCountry()); - wxUser.setProvince(wxMpUser.getProvince()); - wxUser.setCity(wxMpUser.getCity()); - wxUser.setSex(wxMpUser.getSex()); - wxUser.setSubscribe(wxMpUser.getSubscribe()); - wxUser.setSubscribeTime(wxMpUser.getSubscribeTime()); - wxUser.setUnionId(wxMpUser.getUnionId()); - wxUser.setOpenId(wxMpUser.getOpenId()); - wxUser.setLanguage(wxMpUser.getLanguage()); - wxUser.setSexDesc(wxMpUser.getSexDesc()); - return wxUser; - } -} diff --git a/src/main/java/mapper/WxUserMapper.xml b/src/main/java/mapper/WxUserMapper.xml deleted file mode 100644 index 228a592..0000000 --- a/src/main/java/mapper/WxUserMapper.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file