From effd6fa88dcce01551a78aa1d3256e6db0e40fc7 Mon Sep 17 00:00:00 2001 From: ronger Date: Tue, 7 Apr 2020 13:02:33 +0800 Subject: [PATCH 1/2] Add License --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e68c0cd --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 RYMCU + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 3d06abaacaba187bab25e252efcf0845419016b3 Mon Sep 17 00:00:00 2001 From: ronger Date: Mon, 8 Jun 2020 14:11:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?:fire:=20=E5=88=A0=E9=99=A4=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E7=9B=B8=E5=85=B3=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vertical/config/RedisProperties.java | 124 ++++++++++++++++++ .../service/redis/impl/RedisServiceImpl.java | 2 + .../rymcu/vertical/mapper/WxUserMapper.java | 10 -- .../rymcu/vertical/service/WxUserService.java | 14 -- .../service/impl/WxUserServiceImpl.java | 62 --------- src/main/java/mapper/WxUserMapper.xml | 21 --- 6 files changed, 126 insertions(+), 107 deletions(-) create mode 100644 src/main/java/com/rymcu/vertical/config/RedisProperties.java delete mode 100644 src/main/java/com/rymcu/vertical/mapper/WxUserMapper.java delete mode 100644 src/main/java/com/rymcu/vertical/service/WxUserService.java delete mode 100644 src/main/java/com/rymcu/vertical/service/impl/WxUserServiceImpl.java delete mode 100644 src/main/java/mapper/WxUserMapper.xml 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