🔥 删除微信相关文件

This commit is contained in:
ronger 2020-06-08 14:11:20 +08:00
parent a8198bcb90
commit 3d06abaaca
6 changed files with 126 additions and 107 deletions

View File

@ -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 <a href="https://github.com/007gzs">007</a>
*/
@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;
}
}

View File

@ -9,6 +9,7 @@ import com.rymcu.vertical.core.service.redis.RedisService;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import redis.clients.jedis.Jedis; import redis.clients.jedis.Jedis;
@ -27,6 +28,7 @@ import java.util.*;
* 16/10/30 下午5:28 * 16/10/30 下午5:28
*/ */
@Component("redisService") @Component("redisService")
@EnableConfigurationProperties({RedisProperties.class})
public class RedisServiceImpl implements RedisService { public class RedisServiceImpl implements RedisService {
private static final Logger logger = LoggerFactory.getLogger(RedisServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(RedisServiceImpl.class);

View File

@ -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<WxUser> {
}

View File

@ -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> {
WxUser saveUser(WxMpUser wxMpUser, String appId);
}

View File

@ -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<WxUser> 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<WxUser> 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;
}
}

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.rymcu.vertical.mapper.WxUserMapper">
<resultMap id="BaseResultMap" type="com.rymcu.vertical.entity.WxUser">
<id column="id" property="idWxUser"></id>
<result column="nickname" property="nickname"></result>
<result column="nickname" property="unionId"></result>
<result column="nickname" property="appId"></result>
<result column="nickname" property="openId"></result>
<result column="nickname" property="sex"></result>
<result column="nickname" property="sexDesc"></result>
<result column="nickname" property="headImgUrl"></result>
<result column="nickname" property="country"></result>
<result column="nickname" property="province"></result>
<result column="nickname" property="city"></result>
<result column="nickname" property="actToken"></result>
<result column="nickname" property="subscribe"></result>
<result column="nickname" property="subscribeTime"></result>
<result column="nickname" property="language"></result>
</resultMap>
</mapper>