apolo

parent f332a947
......@@ -223,12 +223,16 @@
<artifactId>poi</artifactId>
<version>3.10-FINAL</version>
</dependency>
<dependency>
<groupId>cn.quantgroup</groupId>
<artifactId>quantgroup-config-sdk</artifactId>
<version>1.0.3-SNAPSHOT</version>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-client</artifactId>
<version>0.9.2</version>
</dependency>
<!--<dependency>-->
<!--<groupId>cn.quantgroup</groupId>-->
<!--<artifactId>quantgroup-config-sdk</artifactId>-->
<!--<version>1.0.3-SNAPSHOT</version>-->
<!--</dependency>-->
<!-- motan -->
<dependency>
......@@ -299,8 +303,11 @@
<artifactId>spring-security-web</artifactId>
<version>3.2.7.RELEASE</version>
</dependency>
<dependency>
<groupId>cn.quantgroup</groupId>
<artifactId>quantgroup-sms-sdk</artifactId>
<version>3.0</version>
</dependency>
</dependencies>
<build>
......@@ -325,13 +332,13 @@
<properties>
<profiles.activation>product</profiles.activation>
</properties>
<dependencies>
<dependency>
<groupId>cn.quantgroup</groupId>
<artifactId>quantgroup-sms-sdk</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
<!--<dependencies>-->
<!--<dependency>-->
<!--<groupId>cn.quantgroup</groupId>-->
<!--<artifactId>quantgroup-sms-sdk</artifactId>-->
<!--<version>3.0</version>-->
<!--</dependency>-->
<!--</dependencies>-->
<build>
<resources>
<resource>
......@@ -347,13 +354,13 @@
<properties>
<profiles.activation>dev</profiles.activation>
</properties>
<dependencies>
<dependency>
<groupId>cn.quantgroup</groupId>
<artifactId>quantgroup-sms-sdk</artifactId>
<version>2.0.0.3-SNAPSHOT</version>
</dependency>
</dependencies>
<!--<dependencies>-->
<!--<dependency>-->
<!--<groupId>cn.quantgroup</groupId>-->
<!--<artifactId>quantgroup-sms-sdk</artifactId>-->
<!--<version>3.0</version>-->
<!--</dependency>-->
<!--</dependencies>-->
<build>
<resources>
<resource>
......@@ -369,13 +376,13 @@
<properties>
<profiles.activation>test</profiles.activation>
</properties>
<dependencies>
<dependency>
<groupId>cn.quantgroup</groupId>
<artifactId>quantgroup-sms-sdk</artifactId>
<version>2.0.0.3-SNAPSHOT</version>
</dependency>
</dependencies>
<!--<dependencies>-->
<!--<dependency>-->
<!--<groupId>cn.quantgroup</groupId>-->
<!--<artifactId>quantgroup-sms-sdk</artifactId>-->
<!--<version>3.0</version>-->
<!--</dependency>-->
<!--</dependencies>-->
<build>
<resources>
<resource>
......
package cn.quantgroup.xyqb;
import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
import com.weibo.api.motan.common.MotanConstants;
import com.weibo.api.motan.util.MotanSwitcherUtil;
import lombok.extern.slf4j.Slf4j;
......@@ -15,28 +16,29 @@ import org.springframework.context.annotation.PropertySource;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.scheduling.annotation.EnableAsync;
@ComponentScan(basePackages = {"cn.quantgroup.xyqb", "cn.quantgroup.cloudconfig"})
@ComponentScan(basePackages = {"cn.quantgroup.sms", "cn.quantgroup.xyqb"})
@EnableAutoConfiguration
@SpringBootApplication
@PropertySource(value = {"classpath:application.properties", "classpath:xyqb.properties"}, ignoreResourceNotFound = true)
@EnableCaching
@PropertySource(value = {"classpath:application.properties", "classpath:xyqb.properties"}, ignoreResourceNotFound = true)
@Configuration
@EnableAspectJAutoProxy
@EnableAsync
@EnableApolloConfig({"application", "tech.msg.sdk", "cash.common"})
@Slf4j
public class Bootstrap {
public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(Bootstrap.class);
springApplication.addListeners(new ApplicationListener<ContextRefreshedEvent>() {
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
MotanSwitcherUtil.setSwitcherValue(MotanConstants.REGISTRY_HEARTBEAT_SWITCHER, true);
log.info("注册zookeeper成功");
}
});
springApplication.setRegisterShutdownHook(true);
springApplication.run(args);
log.info("server start...");
}
public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(Bootstrap.class);
springApplication.addListeners(new ApplicationListener<ContextRefreshedEvent>() {
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
MotanSwitcherUtil.setSwitcherValue(MotanConstants.REGISTRY_HEARTBEAT_SWITCHER, true);
log.info("注册zookeeper成功");
}
});
springApplication.setRegisterShutdownHook(true);
springApplication.run(args);
log.info("server start...");
}
}
......@@ -4,7 +4,6 @@ package cn.quantgroup.xyqb.config.data;
* Created by Miraculous on 2016/11/16.
*/
import cn.quantgroup.cloudconfig.SafeValue;
import cn.quantgroup.xyqb.util.ApplicationContextHolder;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
......@@ -33,13 +32,13 @@ import java.util.Properties;
@EnableTransactionManagement
public class JpaConfig {
@SafeValue("xyqb.data.mysql.jdbc-url")
@Value("${xyqb.data.mysql.jdbc-url}")
private String xyqbJdbcUrl;
@SafeValue("xyqb.data.mysql.password")
@Value("${xyqb.data.mysql.password}")
private String password;
@SafeValue("xyqb.data.mysql.user")
@Value("${xyqb.data.mysql.user}")
private String user;
@Value("${xyqb.data.mysql.max-pool-size}")
......
......@@ -3,7 +3,6 @@ package cn.quantgroup.xyqb.service.sms.impl;
import cn.quantgroup.sms.MsgParams;
import cn.quantgroup.sms.SmsSender;
import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.model.sms.SmsResult;
import cn.quantgroup.xyqb.service.sms.ISmsService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
......@@ -23,107 +22,103 @@ import java.util.Collections;
@Service
public class SmsServiceImpl implements ISmsService {
private static final Logger LOGGER = LoggerFactory.getLogger(SmsServiceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(SmsServiceImpl.class);
private static final int SMS_VERIFICATION_MAXLEN = 4;
private static final String SMS_VERIFY_PREFIX = "sms:verify:";
private static final SmsSender smsSender = new SmsSender();
@Value("${sms.is.debug}")
private boolean isDebug;
@Autowired
@Qualifier("stringRedisTemplate")
private RedisTemplate<String, String> stringRedisTemplate;
private static final int SMS_VERIFICATION_MAXLEN = 4;
private static final String SMS_VERIFY_PREFIX = "sms:verify:";
private static final SmsSender smsSender = new SmsSender();
@Value("${sms.is.debug}")
private Boolean isDebug;
@Autowired
@Qualifier("stringRedisTemplate")
private RedisTemplate<String, String> stringRedisTemplate;
@Override
public SmsSender getSmsSender() {
if (null == smsSender) {
return smsSender;
@Override
public SmsSender getSmsSender() {
return smsSender;
}
return this.smsSender;
}
@Override
public void sendAfterRegister(String phoneNo) {
try {
MsgParams msgParams = new MsgParams(Collections.singletonList(2), phoneNo, "1", "24", Collections.emptyList());
smsSender.sendMsg(msgParams);
//smsSender.sendAndForget(new SendAndForgetMsg(Collections.emptyList(), "24", "1", phoneNo));
LOGGER.info("注册完成,发送短信, phoneNo:{}", phoneNo);
} catch (Exception e) {
e.printStackTrace();
@Override
public void sendAfterRegister(String phoneNo) {
try {
MsgParams msgParams = new MsgParams(Collections.singletonList(2), phoneNo, "1", "24", Collections.emptyList());
smsSender.sendMsg(msgParams);
//smsSender.sendAndForget(new SendAndForgetMsg(Collections.emptyList(), "24", "1", phoneNo));
LOGGER.info("注册完成,发送短信, phoneNo:{}", phoneNo);
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public void sendAfterRegister(String phoneNo, String contentId) {
try {
if(StringUtils.isBlank(contentId)){
contentId = "24";
}
MsgParams msgParams = new MsgParams(Collections.singletonList(2), phoneNo, "1", contentId, Collections.emptyList());
smsSender.sendMsg(msgParams);
LOGGER.info("注册完成,发送短信, phoneNo:{}", phoneNo);
} catch (Exception e) {
e.printStackTrace();
@Override
public void sendAfterRegister(String phoneNo, String contentId) {
try {
if (StringUtils.isBlank(contentId)) {
contentId = "24";
}
MsgParams msgParams = new MsgParams(Collections.singletonList(2), phoneNo, "1", contentId, Collections.emptyList());
smsSender.sendMsg(msgParams);
LOGGER.info("注册完成,发送短信, phoneNo:{}", phoneNo);
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* 检查验证码是否正确
*
* @param phoneNo
* @param smsVerificationCode
* @return
*/
@Override
public boolean validRegisterOrResetPasswdVerificationCode(String phoneNo, String smsVerificationCode) {
//if (StringUtils.isEmpty(smsVerificationCode) || smsVerificationCode.length() != SMS_VERIFICATION_MAXLEN) {
// return false;
//}
String key = Constants.REDIS_PREFIX_VERIFICATION_CODE + phoneNo;
String randomCode = stringRedisTemplate.opsForValue().get(key);
if (StringUtils.isEmpty(randomCode)) {
return false;
/**
* 检查验证码是否正确
*
* @param phoneNo
* @param smsVerificationCode
* @return
*/
@Override
public boolean validRegisterOrResetPasswdVerificationCode(String phoneNo, String smsVerificationCode) {
//if (StringUtils.isEmpty(smsVerificationCode) || smsVerificationCode.length() != SMS_VERIFICATION_MAXLEN) {
// return false;
//}
String key = Constants.REDIS_PREFIX_VERIFICATION_CODE + phoneNo;
String randomCode = stringRedisTemplate.opsForValue().get(key);
if (StringUtils.isEmpty(randomCode)) {
return false;
}
String[] arr = randomCode.split(":");
String unqiueId = arr[0];
String code = arr[1];
return confirmSms(smsVerificationCode, unqiueId, code);
}
String[] arr = randomCode.split(":");
String unqiueId = arr[0];
String code = arr[1];
return confirmSms(smsVerificationCode, unqiueId, code);
}
@Override
public boolean validateFastLoginVerificationCode(String phoneNo, String verificationCode) {
String key = Constants.REDIS_PREFIX_VERIFICATION_CODE + phoneNo;
String randomCode = stringRedisTemplate.opsForValue().get(key);
if (StringUtils.isBlank(randomCode)) {
return false;
@Override
public boolean validateFastLoginVerificationCode(String phoneNo, String verificationCode) {
String key = Constants.REDIS_PREFIX_VERIFICATION_CODE + phoneNo;
String randomCode = stringRedisTemplate.opsForValue().get(key);
if (StringUtils.isBlank(randomCode)) {
return false;
}
String[] arr = randomCode.split(":");
if (arr.length != 2) {
return false;
}
String uniqueId = arr[0];
String code = arr[1];
return confirmSms(verificationCode, uniqueId, code);
}
String[] arr = randomCode.split(":");
if (arr.length != 2) {
return false;
}
String uniqueId = arr[0];
String code = arr[1];
return confirmSms(verificationCode, uniqueId, code);
}
private boolean confirmSms(String smsVerificationCode, String unqiueId, String code) {
try {
MsgParams message = new MsgParams(Collections.singletonList(2), unqiueId);
//MsgParams messageVoice = new MsgParams(Collections.singletonList(4), unqiueId);
getSmsSender().confirmMsg(message);
//getSmsSender().confirmMsg(messageVoice);
//smsSender.confirmSmsResult("1", unqiueId);
LOGGER.info("confirmMsg send success, uniqueId={}", unqiueId);
} catch (Exception e) {
LOGGER.info("短信验证向短信中心确认失效");
}
if (StringUtils.equals(code, smsVerificationCode)) {
return true;
private boolean confirmSms(String smsVerificationCode, String unqiueId, String code) {
try {
MsgParams message = new MsgParams(Collections.singletonList(2), unqiueId);
//MsgParams messageVoice = new MsgParams(Collections.singletonList(4), unqiueId);
getSmsSender().confirmMsg(message);
//getSmsSender().confirmMsg(messageVoice);
//smsSender.confirmSmsResult("1", unqiueId);
LOGGER.info("confirmMsg send success, uniqueId={}", unqiueId);
} catch (Exception e) {
LOGGER.info("短信验证向短信中心确认失效");
}
if (StringUtils.equals(code, smsVerificationCode)) {
return true;
}
return false;
}
return false;
}
}
package cn.quantgroup.xyqb.service.wechat.impl;
import cn.quantgroup.cloudconfig.SafeValue;
import cn.quantgroup.xyqb.entity.WechatUserInfo;
import cn.quantgroup.xyqb.model.webchat.AccessTokenResponse;
import cn.quantgroup.xyqb.repository.IWeChatUserRepository;
......@@ -10,6 +9,7 @@ import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -28,9 +28,9 @@ public class WechatServiceImpl implements IWechatService {
@Autowired
@Qualifier("stringRedisTemplate")
private RedisTemplate<String, String> redisTemplate;
@SafeValue("wechat.appid")
@Value("${wechat.appid}")
private String appId;
@SafeValue("wechat.secret")
@Value("${wechat.secret}")
private String secret;
@Autowired
private IWeChatUserRepository weChatUserRepository;
......
app.id=xyqb-user2
namespace=application
\ No newline at end of file
server.port=8082
security.sessions=if_required
spring.aop.proxy-target-class=true
config.accessable=false
configserver.disable=1
configserver.system=xyqb-user
#xyqb.data.mysql.jdbc-url=jdbc:mysql://192.168.4.22:3306/xyqb_user?useUnicode=true&characterEncoding=UTF8
xyqb.data.mysql.jdbc-url=jdbc:mysql://192.168.4.153:3306/xyqb_user?useUnicode=true&characterEncoding=UTF8
xyqb.data.mysql.password=qatest
xyqb.data.mysql.user=qa
xyqb.data.mysql.max-pool-size=20
# CORS
xyqb.filter.allowedOrigin=*
xyqb.filter.allowedHeaders=Origin, No-Cache, x-auth-token, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type,Authorization
xyqb.data.redis.defaultExpiration=3600
# redis
xyqb.redis.master.host=192.168.4.153
xyqb.redis.master.port=6379
xyqb.redis.master.name=
xyqb.redis.sentinel1.host=
xyqb.redis.sentinel1.port=0
xyqb.redis.sentinel2.host=
xyqb.redis.sentinel2.port=0
xyqb.redis.sentinel3.host=
xyqb.redis.sentinel3.port=0
# 短信平台配置
sms.is.debug=1
# LKB client
lkb.client.url=http://192.168.4.193:8082/LKBClient/openapi
lkb.client.user.register.app=/new/register/registerApp.json
lkb.client.user.update=/new/register/updateUser.json
lkb.client.user.push=/user/push.json
# LKB import
lkb.import.url=http://spider.quantgroup.cn
# LKB
lkb.url=http://192.168.192.251:8081/LKB
# xyqb
xyqb.url=http://192.168.192.163:8999
xyqb.api.url=http://192.168.192.163:9004
# 图形验证码
# 是否启用超级验证码 "__SUPERQG__", 用于测试环境自动化测试, 线上环境可忽略此参数
xyqb.auth.captcha.super.enable=1
#首参数校验
xyqb.fplock.limit.byhour=3
xyqb.fplock.limit.byday=5
#sdk
model.quantgroup.url=http://model.quantgroup.cn
xyqb.auth.url=http://192.168.192.206:9001
usersys.url=http://localhost:9001
xyqb-user.ui=http://192.168.100.36:7043
xyqb-user.ui-s=https://192.168.100.36:7043
wechat.appid=wxcdf6077af8127559
wechat.secret=16eaec16084d0d9c52d4114f359cc72c
#motan protocol
protocol.name=motan
protocol.contentLength=1048576
protocol.isDefault=true
#motan registry center
registry.protocol=zookeeper
registry.address=192.168.4.22:2181
motan.port=8086
motan.user.group=userGroup
motan.user.module=user-motan-rpc
motan.application=xyqbUserMotan
#xyqb-user-域名
xyqb.user.domain=passport.xyqb.com
xyqb.user.query.url=http://192.168.11.40:8081
xyqb.domain = http://192.168.4.153:7003
xyqb.paycenter.url=http://192.168.4.26:7006
xyqb.paycenter.id=3
#内部运营系统
xyqb.yunying.url=http://192.168.4.26:7047
#马甲包
loanvest.rabbitmq.connection.virtual-host=/loan_order
#loanvest.rabbitmq.stateMsgQueue=loan_vest_msg_queue
loanvest.rabbitmq.queue=loan_user_queue
loanvest.rabbitmq.exchange=loan_vest_exchange
loanvest.rabbitmq.connection.host=192.168.4.46
loanvest.rabbitmq.connection.port=5672
loanvest.rabbitmq.connection.user=qa
loanvest.rabbitmq.connection.password=qatest
#用户注册广播
register.rabbitmq.connection.virtual-host=/user_register
register.rabbitmq.queue=user_register_queue
register.rabbitmq.exchange=user_register_exchange
register.rabbitmq.connection.host=192.168.4.153
register.rabbitmq.connection.port=5672
register.rabbitmq.connection.user=qa
register.rabbitmq.connection.password=qatest
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment