Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
head_group
xyqb-user2
Commits
a86d9332
Commit
a86d9332
authored
Dec 26, 2017
by
Java—红包—徐 然
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/apollo' into feature/junit_test
# Conflicts: # src/main/resources/config/test/logback.xml
parents
304c5135
a9c9363c
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
148 additions
and
299 deletions
+148
-299
pom.xml
pom.xml
+14
-22
Bootstrap.java
src/main/java/cn/quantgroup/xyqb/Bootstrap.java
+22
-15
CaptchaFiniteValidateAdvisor.java
...oup/xyqb/aspect/captcha/CaptchaFiniteValidateAdvisor.java
+1
-1
JpaConfig.java
src/main/java/cn/quantgroup/xyqb/config/data/JpaConfig.java
+3
-4
MotanUserServiceImpl.java
.../xyqb/controller/external/motan/MotanUserServiceImpl.java
+1
-1
AuthInfoController.java
...up/xyqb/controller/internal/login/AuthInfoController.java
+1
-1
UserController.java
...ntgroup/xyqb/controller/internal/user/UserController.java
+4
-5
CrosFilter.java
src/main/java/cn/quantgroup/xyqb/filter/CrosFilter.java
+1
-1
BaseUserRegisterHandler.java
...ervice/register/handler/impl/BaseUserRegisterHandler.java
+3
-2
BtUserRegisterHandler.java
.../service/register/handler/impl/BtUserRegisterHandler.java
+3
-2
SmsServiceImpl.java
...a/cn/quantgroup/xyqb/service/sms/impl/SmsServiceImpl.java
+39
-37
WechatServiceImpl.java
...uantgroup/xyqb/service/wechat/impl/WechatServiceImpl.java
+3
-3
ApplicationContextHolder.java
...ava/cn/quantgroup/xyqb/util/ApplicationContextHolder.java
+1
-0
IPUtil.java
src/main/java/cn/quantgroup/xyqb/util/IPUtil.java
+1
-0
app.properties
src/main/resources/META-INF/app.properties
+2
-0
application.properties
src/main/resources/config/dev/application.properties
+1
-1
xyqb.properties
src/main/resources/config/dev/xyqb.properties
+0
-110
application.properties
src/main/resources/config/release01/application.properties
+1
-2
xyqb.properties
src/main/resources/config/release01/xyqb.properties
+0
-79
application.properties
src/main/resources/config/test/application.properties
+1
-1
logback.xml
src/main/resources/config/test/logback.xml
+4
-3
TestUserLogin.java
src/test/java/user/TestUserLogin.java
+40
-9
app.properties
src/test/resources/META-INF/app.properties
+2
-0
No files found.
pom.xml
View file @
a86d9332
...
@@ -225,12 +225,16 @@
...
@@ -225,12 +225,16 @@
<artifactId>
poi
</artifactId>
<artifactId>
poi
</artifactId>
<version>
3.10-FINAL
</version>
<version>
3.10-FINAL
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
c
n.quantgroup
</groupId>
<groupId>
c
om.ctrip.framework.apollo
</groupId>
<artifactId>
quantgroup-config-sdk
</artifactId>
<artifactId>
apollo-client
</artifactId>
<version>
1.0.3-SNAPSHOT
</version>
<version>
0.10.0
</version>
</dependency>
</dependency>
<!--<dependency>-->
<!--<groupId>cn.quantgroup</groupId>-->
<!--<artifactId>quantgroup-config-sdk</artifactId>-->
<!--<version>1.0.3-SNAPSHOT</version>-->
<!--</dependency>-->
<!-- motan -->
<!-- motan -->
<dependency>
<dependency>
...
@@ -303,8 +307,11 @@
...
@@ -303,8 +307,11 @@
<artifactId>
spring-security-web
</artifactId>
<artifactId>
spring-security-web
</artifactId>
<version>
${org.springframework.security.version}
</version>
<version>
${org.springframework.security.version}
</version>
</dependency>
</dependency>
<!-- 兼容旧 Spring Session 配置-->
<dependency>
<groupId>
cn.quantgroup
</groupId>
<artifactId>
quantgroup-sms-sdk
</artifactId>
<version>
3.0
</version>
</dependency>
</dependencies>
</dependencies>
...
@@ -330,13 +337,6 @@
...
@@ -330,13 +337,6 @@
<properties>
<properties>
<profiles.activation>
product
</profiles.activation>
<profiles.activation>
product
</profiles.activation>
</properties>
</properties>
<dependencies>
<dependency>
<groupId>
cn.quantgroup
</groupId>
<artifactId>
quantgroup-sms-sdk
</artifactId>
<version>
2.0.0
</version>
</dependency>
</dependencies>
<build>
<build>
<resources>
<resources>
<resource>
<resource>
...
@@ -352,14 +352,6 @@
...
@@ -352,14 +352,6 @@
<properties>
<properties>
<profiles.activation>
dev
</profiles.activation>
<profiles.activation>
dev
</profiles.activation>
</properties>
</properties>
<dependencies>
<dependency>
<groupId>
cn.quantgroup
</groupId>
<artifactId>
quantgroup-sms-sdk
</artifactId>
<version>
2.0.0.3-SNAPSHOT
</version>
</dependency>
</dependencies>
<build>
<build>
<resources>
<resources>
<resource>
<resource>
...
@@ -374,9 +366,9 @@
...
@@ -374,9 +366,9 @@
<id>
test
</id>
<id>
test
</id>
<properties>
<properties>
<profiles.activation>
test
</profiles.activation>
<profiles.activation>
test
</profiles.activation>
</properties>
</properties>
<dependencies>
<dependencies>
<dependency>
<dependency>
<groupId>
cn.quantgroup
</groupId>
<groupId>
cn.quantgroup
</groupId>
<artifactId>
quantgroup-sms-sdk
</artifactId>
<artifactId>
quantgroup-sms-sdk
</artifactId>
...
...
src/main/java/cn/quantgroup/xyqb/Bootstrap.java
View file @
a86d9332
package
cn
.
quantgroup
.
xyqb
;
package
cn
.
quantgroup
.
xyqb
;
import
com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig
;
import
com.ctrip.framework.apollo.spring.config.ApolloPropertySourceInitializer
;
import
com.weibo.api.motan.common.MotanConstants
;
import
com.weibo.api.motan.common.MotanConstants
;
import
com.weibo.api.motan.util.MotanSwitcherUtil
;
import
com.weibo.api.motan.util.MotanSwitcherUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -15,28 +17,33 @@ import org.springframework.context.annotation.PropertySource;
...
@@ -15,28 +17,33 @@ import org.springframework.context.annotation.PropertySource;
import
org.springframework.context.event.ContextRefreshedEvent
;
import
org.springframework.context.event.ContextRefreshedEvent
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.annotation.EnableAsync
;
@ComponentScan
(
basePackages
=
{
"cn.quantgroup.xyqb"
,
"cn.quantgroup.cloudconfig"
})
@ComponentScan
(
basePackages
=
{
"cn.quantgroup.sms"
,
"cn.quantgroup.xyqb"
})
@EnableAutoConfiguration
@EnableAutoConfiguration
@SpringBootApplication
@SpringBootApplication
@PropertySource
(
value
=
{
"classpath:application.properties"
,
"classpath:xyqb.properties"
},
ignoreResourceNotFound
=
true
)
@EnableCaching
@EnableCaching
//@EnableApolloConfig({"application", "tech.msg.sdk", "cash.common"})
@EnableApolloConfig
@PropertySource
(
value
=
{
"classpath:application.properties"
,
"classpath:xyqb.properties"
},
ignoreResourceNotFound
=
true
)
@Configuration
@Configuration
@EnableAspectJAutoProxy
@EnableAspectJAutoProxy
@EnableAsync
@EnableAsync
@Slf4j
@Slf4j
public
class
Bootstrap
{
public
class
Bootstrap
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
springApplication
=
new
SpringApplication
(
Bootstrap
.
class
);
SpringApplication
springApplication
=
new
SpringApplication
(
Bootstrap
.
class
);
springApplication
.
addListeners
(
new
ApplicationListener
<
ContextRefreshedEvent
>()
{
springApplication
.
addInitializers
(
new
ApolloPropertySourceInitializer
(
"application"
,
"tech.msg.sdk"
,
"cash.common"
));
@Override
public
void
onApplicationEvent
(
ContextRefreshedEvent
event
)
{
springApplication
.
addListeners
(
new
ApplicationListener
<
ContextRefreshedEvent
>()
{
MotanSwitcherUtil
.
setSwitcherValue
(
MotanConstants
.
REGISTRY_HEARTBEAT_SWITCHER
,
true
);
@Override
log
.
info
(
"注册zookeeper成功"
);
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..."
);
springApplication
.
setRegisterShutdownHook
(
true
);
}
springApplication
.
run
(
args
);
log
.
info
(
"server start..."
);
}
}
}
src/main/java/cn/quantgroup/xyqb/aspect/captcha/CaptchaFiniteValidateAdvisor.java
View file @
a86d9332
...
@@ -84,7 +84,7 @@ public class CaptchaFiniteValidateAdvisor {
...
@@ -84,7 +84,7 @@ public class CaptchaFiniteValidateAdvisor {
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
Map
<
String
,
String
>
phonePasswordMap
=
getHeaderParam
(
request
);
Map
<
String
,
String
>
phonePasswordMap
=
getHeaderParam
(
request
);
if
(
phonePasswordMap
==
null
||
phonePasswordMap
.
isEmpty
()){
if
(
phonePasswordMap
==
null
||
phonePasswordMap
.
isEmpty
()){
return
false
;
return
JsonResult
.
buildErrorStateResult
(
"用户名或密码不正确"
,
null
)
;
}
}
// 当前用户手机号
// 当前用户手机号
String
phoneNo
=
phonePasswordMap
.
get
(
"phoneNo"
);
String
phoneNo
=
phonePasswordMap
.
get
(
"phoneNo"
);
...
...
src/main/java/cn/quantgroup/xyqb/config/data/JpaConfig.java
View file @
a86d9332
...
@@ -4,7 +4,6 @@ package cn.quantgroup.xyqb.config.data;
...
@@ -4,7 +4,6 @@ package cn.quantgroup.xyqb.config.data;
* Created by Miraculous on 2016/11/16.
* Created by Miraculous on 2016/11/16.
*/
*/
import
cn.quantgroup.cloudconfig.SafeValue
;
import
cn.quantgroup.xyqb.util.ApplicationContextHolder
;
import
cn.quantgroup.xyqb.util.ApplicationContextHolder
;
import
com.zaxxer.hikari.HikariConfig
;
import
com.zaxxer.hikari.HikariConfig
;
import
com.zaxxer.hikari.HikariDataSource
;
import
com.zaxxer.hikari.HikariDataSource
;
...
@@ -33,13 +32,13 @@ import java.util.Properties;
...
@@ -33,13 +32,13 @@ import java.util.Properties;
@EnableTransactionManagement
@EnableTransactionManagement
public
class
JpaConfig
{
public
class
JpaConfig
{
@
SafeValue
(
"xyqb.data.mysql.jdbc-url
"
)
@
Value
(
"${xyqb.data.mysql.jdbc-url}
"
)
private
String
xyqbJdbcUrl
;
private
String
xyqbJdbcUrl
;
@
SafeValue
(
"xyqb.data.mysql.password
"
)
@
Value
(
"${xyqb.data.mysql.password}
"
)
private
String
password
;
private
String
password
;
@
SafeValue
(
"xyqb.data.mysql.user
"
)
@
Value
(
"${xyqb.data.mysql.user}
"
)
private
String
user
;
private
String
user
;
@Value
(
"${xyqb.data.mysql.max-pool-size}"
)
@Value
(
"${xyqb.data.mysql.max-pool-size}"
)
...
...
src/main/java/cn/quantgroup/xyqb/controller/external/motan/MotanUserServiceImpl.java
View file @
a86d9332
...
@@ -716,7 +716,7 @@ public class MotanUserServiceImpl implements UserMotanService {
...
@@ -716,7 +716,7 @@ public class MotanUserServiceImpl implements UserMotanService {
context
.
setChannelId
(
null
);
context
.
setChannelId
(
null
);
context
.
setCreatedFrom
(
user
.
getRegisteredFrom
());
context
.
setCreatedFrom
(
user
.
getRegisteredFrom
());
context
.
setAppChannel
(
""
);
context
.
setAppChannel
(
""
);
if
(
user
.
getRegisteredFrom
()
==
222L
)
{
if
(
Objects
.
equals
(
user
.
getRegisteredFrom
(),
222L
)
)
{
UserBtRegister
userBtRegister
=
null
;
UserBtRegister
userBtRegister
=
null
;
try
{
try
{
userBtRegister
=
userBtRegisterService
.
findByUserId
(
user
.
getId
());
userBtRegister
=
userBtRegisterService
.
findByUserId
(
user
.
getId
());
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/login/AuthInfoController.java
View file @
a86d9332
...
@@ -102,7 +102,7 @@ public class AuthInfoController implements IBaseController {
...
@@ -102,7 +102,7 @@ public class AuthInfoController implements IBaseController {
context
.
setChannelId
(
null
);
context
.
setChannelId
(
null
);
context
.
setCreatedFrom
(
user
.
getRegisteredFrom
());
context
.
setCreatedFrom
(
user
.
getRegisteredFrom
());
context
.
setAppChannel
(
""
);
context
.
setAppChannel
(
""
);
if
(
user
.
getRegisteredFrom
()
==
222L
)
{
if
(
Objects
.
equals
(
user
.
getRegisteredFrom
(),
222L
)
)
{
UserBtRegister
userBtRegister
=
null
;
UserBtRegister
userBtRegister
=
null
;
try
{
try
{
userBtRegister
=
userBtRegisterService
.
findByUserId
(
user
.
getId
());
userBtRegister
=
userBtRegisterService
.
findByUserId
(
user
.
getId
());
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/user/UserController.java
View file @
a86d9332
...
@@ -42,6 +42,7 @@ import java.io.UnsupportedEncodingException;
...
@@ -42,6 +42,7 @@ import java.io.UnsupportedEncodingException;
import
java.nio.charset.Charset
;
import
java.nio.charset.Charset
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
/**
/**
* Http服务接口:用户注册、登录、重置密码
* Http服务接口:用户注册、登录、重置密码
...
@@ -465,12 +466,10 @@ public class UserController implements IBaseController {
...
@@ -465,12 +466,10 @@ public class UserController implements IBaseController {
WechatUserInfo
userInfo
=
wechatService
.
findWechatUserInfoFromDb
(
openId
);
WechatUserInfo
userInfo
=
wechatService
.
findWechatUserInfoFromDb
(
openId
);
LOGGER
.
info
(
"微信关联openId,user:[{}],openId:[{}],wechatUserInfo:[{}]"
,
user
,
openId
,
userInfo
);
LOGGER
.
info
(
"微信关联openId,user:[{}],openId:[{}],wechatUserInfo:[{}]"
,
user
,
openId
,
userInfo
);
// 已经绑定过了
if
(
Objects
.
isNull
(
userInfo
)
&&
!
Objects
.
isNull
(
userId
))
{
if
(
userInfo
!=
null
&&
StringUtils
.
isNotEmpty
(
userInfo
.
getPhoneNo
()))
{
userInfo
=
wechatService
.
queryOpenIdByUserId
(
userId
);
return
JsonResult
.
buildSuccessResult
(
null
,
null
);
}
}
// 前置绑定微信出错
if
(
userInfo
==
null
||
StringUtils
.
isNotEmpty
(
userInfo
.
getPhoneNo
()))
{
if
(
userInfo
==
null
)
{
return
JsonResult
.
buildSuccessResult
(
null
,
null
);
return
JsonResult
.
buildSuccessResult
(
null
,
null
);
}
}
// 未绑定信用钱包用户
// 未绑定信用钱包用户
...
...
src/main/java/cn/quantgroup/xyqb/filter/CrosFilter.java
View file @
a86d9332
...
@@ -18,8 +18,8 @@ import java.util.Set;
...
@@ -18,8 +18,8 @@ import java.util.Set;
* 支持跨域
* 支持跨域
*/
*/
@Component
@Component
@Order
(
Ordered
.
HIGHEST_PRECEDENCE
)
@Configuration
@Configuration
@Order
(
Ordered
.
HIGHEST_PRECEDENCE
)
public
class
CrosFilter
implements
Filter
{
public
class
CrosFilter
implements
Filter
{
private
static
final
Set
<
String
>
DISALLOWED_METHOD
=
new
HashSet
<>();
private
static
final
Set
<
String
>
DISALLOWED_METHOD
=
new
HashSet
<>();
...
...
src/main/java/cn/quantgroup/xyqb/service/register/handler/impl/BaseUserRegisterHandler.java
View file @
a86d9332
...
@@ -17,6 +17,7 @@ import org.springframework.context.annotation.Scope;
...
@@ -17,6 +17,7 @@ import org.springframework.context.annotation.Scope;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
import
java.util.Objects
;
import
java.util.UUID
;
import
java.util.UUID
;
/**
/**
...
@@ -60,11 +61,11 @@ public class BaseUserRegisterHandler extends AbstractUserRegisterHandler {
...
@@ -60,11 +61,11 @@ public class BaseUserRegisterHandler extends AbstractUserRegisterHandler {
user
.
setEnable
(
true
);
user
.
setEnable
(
true
);
user
.
setPhoneNo
(
userRegisterParam
.
getPhoneNo
());
user
.
setPhoneNo
(
userRegisterParam
.
getPhoneNo
());
Long
registerFrom
=
userRegisterParam
.
getRegisterFrom
();
Long
registerFrom
=
userRegisterParam
.
getRegisterFrom
();
if
(
null
==
registerFrom
)
{
if
(
Objects
.
isNull
(
registerFrom
)
)
{
registerFrom
=
1L
;
registerFrom
=
1L
;
}
}
Long
channelId
=
userRegisterParam
.
getChannelId
();
Long
channelId
=
userRegisterParam
.
getChannelId
();
if
(
channelId
==
222L
)
{
if
(
Objects
.
equals
(
channelId
,
222L
)
)
{
user
.
setRegisteredFrom
(
channelId
);
user
.
setRegisteredFrom
(
channelId
);
}
else
{
}
else
{
user
.
setRegisteredFrom
(
registerFrom
);
user
.
setRegisteredFrom
(
registerFrom
);
...
...
src/main/java/cn/quantgroup/xyqb/service/register/handler/impl/BtUserRegisterHandler.java
View file @
a86d9332
...
@@ -12,6 +12,7 @@ import org.springframework.context.annotation.Scope;
...
@@ -12,6 +12,7 @@ import org.springframework.context.annotation.Scope;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
import
java.util.Objects
;
/**
/**
* Created by liqing on 2017/12/4 0004.
* Created by liqing on 2017/12/4 0004.
...
@@ -31,7 +32,7 @@ public class BtUserRegisterHandler extends AbstractUserRegisterHandler {
...
@@ -31,7 +32,7 @@ public class BtUserRegisterHandler extends AbstractUserRegisterHandler {
Long
channelId
=
userRegisterParam
.
getChannelId
();
Long
channelId
=
userRegisterParam
.
getChannelId
();
User
user
=
userRegisterParam
.
getUser
();
User
user
=
userRegisterParam
.
getUser
();
Long
btRegisterChannelId
=
userRegisterParam
.
getBtRegisterChannelId
();
Long
btRegisterChannelId
=
userRegisterParam
.
getBtRegisterChannelId
();
if
(
null
!=
user
&&
channelId
==
222L
){
if
(
!
Objects
.
isNull
(
user
)
&&
Objects
.
equals
(
channelId
,
222L
)
){
UserBtRegister
userBtRegister
=
new
UserBtRegister
();
UserBtRegister
userBtRegister
=
new
UserBtRegister
();
userBtRegister
.
setUserId
(
user
.
getId
());
userBtRegister
.
setUserId
(
user
.
getId
());
if
(
null
==
btRegisterChannelId
){
if
(
null
==
btRegisterChannelId
){
...
@@ -45,7 +46,7 @@ public class BtUserRegisterHandler extends AbstractUserRegisterHandler {
...
@@ -45,7 +46,7 @@ public class BtUserRegisterHandler extends AbstractUserRegisterHandler {
userBtRegister
.
setUpdatedAt
(
currentTime
);
userBtRegister
.
setUpdatedAt
(
currentTime
);
userBtRegisterService
.
save
(
userBtRegister
);
userBtRegisterService
.
save
(
userBtRegister
);
}
}
if
(
successor
!=
null
){
if
(
!
Objects
.
isNull
(
successor
)
){
return
successor
.
handleRegister
(
userRegisterParam
);
return
successor
.
handleRegister
(
userRegisterParam
);
}
}
return
userRegisterParam
.
getUser
();
return
userRegisterParam
.
getUser
();
...
...
src/main/java/cn/quantgroup/xyqb/service/sms/impl/SmsServiceImpl.java
View file @
a86d9332
...
@@ -3,8 +3,11 @@ package cn.quantgroup.xyqb.service.sms.impl;
...
@@ -3,8 +3,11 @@ package cn.quantgroup.xyqb.service.sms.impl;
import
cn.quantgroup.sms.MsgParams
;
import
cn.quantgroup.sms.MsgParams
;
import
cn.quantgroup.sms.SmsSender
;
import
cn.quantgroup.sms.SmsSender
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.model.sms.SmsResult
;
import
cn.quantgroup.xyqb.service.sms.ISmsService
;
import
cn.quantgroup.xyqb.service.sms.ISmsService
;
import
lombok.Synchronized
;
import
java.util.Collections
;
import
lombok.extern.slf4j.Slf4j
;
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
;
...
@@ -14,41 +17,47 @@ import org.springframework.beans.factory.annotation.Value;
...
@@ -14,41 +17,47 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java
.util.Collections
;
import
java
x.annotation.PostConstruct
;
/**
/**
* @author mengfan.feng
* @author mengfan.feng
* @time 2015-07-25 18:47
* @time 2015-07-25 18:47
*/
*/
@Service
@Service
@Slf4j
public
class
SmsServiceImpl
implements
ISmsService
{
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
int
SMS_VERIFICATION_MAXLEN
=
4
;
private
static
final
String
SMS_VERIFY_PREFIX
=
"sms:verify:"
;
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
private
static
SmsSender
smsSender
=
null
;
public
SmsSender
getSmsSender
()
{
@Value
(
"${sms.is.debug}"
)
if
(
null
==
smsSender
)
{
private
Boolean
isDebug
;
return
smsSender
;
@Autowired
@Qualifier
(
"stringRedisTemplate"
)
private
RedisTemplate
<
String
,
String
>
stringRedisTemplate
;
@Override
@Synchronized
public
SmsSender
getSmsSender
()
{
if
(
null
==
smsSender
){
smsSender
=
new
SmsSender
();
}
return
smsSender
;
}
}
return
this
.
smsSender
;
}
@Override
@Override
public
void
sendAfterRegister
(
String
phoneNo
)
{
public
void
sendAfterRegister
(
String
phoneNo
)
{
try
{
try
{
MsgParams
msgParams
=
new
MsgParams
(
Collections
.
singletonList
(
2
),
phoneNo
,
"1"
,
"24"
,
Collections
.
emptyList
());
MsgParams
msgParams
=
smsSender
.
sendMsg
(
msgParams
);
new
MsgParams
(
Collections
.
singletonList
(
2
),
phoneNo
,
"1"
,
"24"
,
Collections
.
emptyList
());
getSmsSender
().
sendMsg
(
msgParams
);
//smsSender.sendAndForget(new SendAndForgetMsg(Collections.emptyList(), "24", "1", phoneNo));
//smsSender.sendAndForget(new SendAndForgetMsg(Collections.emptyList(), "24", "1", phoneNo));
LOGGER
.
info
(
"注册完成,发送短信, phoneNo:{}"
,
phoneNo
);
log
.
info
(
"注册完成,发送短信, phoneNo:{}"
,
phoneNo
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
@@ -57,12 +66,13 @@ public class SmsServiceImpl implements ISmsService {
...
@@ -57,12 +66,13 @@ public class SmsServiceImpl implements ISmsService {
@Override
@Override
public
void
sendAfterRegister
(
String
phoneNo
,
String
contentId
)
{
public
void
sendAfterRegister
(
String
phoneNo
,
String
contentId
)
{
try
{
try
{
if
(
StringUtils
.
isBlank
(
contentId
))
{
if
(
StringUtils
.
isBlank
(
contentId
))
{
contentId
=
"24"
;
contentId
=
"24"
;
}
}
MsgParams
msgParams
=
new
MsgParams
(
Collections
.
singletonList
(
2
),
phoneNo
,
"1"
,
contentId
,
Collections
.
emptyList
());
MsgParams
msgParams
=
new
MsgParams
(
Collections
.
singletonList
(
2
),
phoneNo
,
"1"
,
contentId
,
smsSender
.
sendMsg
(
msgParams
);
Collections
.
emptyList
());
LOGGER
.
info
(
"注册完成,发送短信, phoneNo:{}"
,
phoneNo
);
getSmsSender
().
sendMsg
(
msgParams
);
log
.
info
(
"注册完成,发送短信, phoneNo:{}"
,
phoneNo
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
@@ -70,13 +80,10 @@ public class SmsServiceImpl implements ISmsService {
...
@@ -70,13 +80,10 @@ public class SmsServiceImpl implements ISmsService {
/**
/**
* 检查验证码是否正确
* 检查验证码是否正确
*
* @param phoneNo
* @param smsVerificationCode
* @return
*/
*/
@Override
@Override
public
boolean
validRegisterOrResetPasswdVerificationCode
(
String
phoneNo
,
String
smsVerificationCode
)
{
public
boolean
validRegisterOrResetPasswdVerificationCode
(
String
phoneNo
,
String
smsVerificationCode
)
{
//if (StringUtils.isEmpty(smsVerificationCode) || smsVerificationCode.length() != SMS_VERIFICATION_MAXLEN) {
//if (StringUtils.isEmpty(smsVerificationCode) || smsVerificationCode.length() != SMS_VERIFICATION_MAXLEN) {
// return false;
// return false;
//}
//}
...
@@ -86,9 +93,9 @@ public class SmsServiceImpl implements ISmsService {
...
@@ -86,9 +93,9 @@ public class SmsServiceImpl implements ISmsService {
return
false
;
return
false
;
}
}
String
[]
arr
=
randomCode
.
split
(
":"
);
String
[]
arr
=
randomCode
.
split
(
":"
);
String
un
qi
ueId
=
arr
[
0
];
String
un
iq
ueId
=
arr
[
0
];
String
code
=
arr
[
1
];
String
code
=
arr
[
1
];
return
confirmSms
(
smsVerificationCode
,
un
qi
ueId
,
code
);
return
confirmSms
(
smsVerificationCode
,
un
iq
ueId
,
code
);
}
}
@Override
@Override
...
@@ -107,8 +114,6 @@ public class SmsServiceImpl implements ISmsService {
...
@@ -107,8 +114,6 @@ public class SmsServiceImpl implements ISmsService {
return
confirmSms
(
verificationCode
,
uniqueId
,
code
);
return
confirmSms
(
verificationCode
,
uniqueId
,
code
);
}
}
private
boolean
confirmSms
(
String
smsVerificationCode
,
String
unqiueId
,
String
code
)
{
private
boolean
confirmSms
(
String
smsVerificationCode
,
String
unqiueId
,
String
code
)
{
try
{
try
{
MsgParams
message
=
new
MsgParams
(
Collections
.
singletonList
(
2
),
unqiueId
);
MsgParams
message
=
new
MsgParams
(
Collections
.
singletonList
(
2
),
unqiueId
);
...
@@ -116,14 +121,11 @@ public class SmsServiceImpl implements ISmsService {
...
@@ -116,14 +121,11 @@ public class SmsServiceImpl implements ISmsService {
getSmsSender
().
confirmMsg
(
message
);
getSmsSender
().
confirmMsg
(
message
);
//getSmsSender().confirmMsg(messageVoice);
//getSmsSender().confirmMsg(messageVoice);
//smsSender.confirmSmsResult("1", unqiueId);
//smsSender.confirmSmsResult("1", unqiueId);
LOGGER
.
info
(
"confirmMsg send success, uniqueId={}"
,
unqiueId
);
log
.
info
(
"confirmMsg send success, uniqueId={}"
,
unqiueId
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOGGER
.
info
(
"短信验证向短信中心确认失效"
);
log
.
info
(
"短信验证向短信中心确认失效"
);
}
if
(
StringUtils
.
equals
(
code
,
smsVerificationCode
))
{
return
true
;
}
}
return
false
;
return
StringUtils
.
equals
(
code
,
smsVerificationCode
)
;
}
}
}
}
src/main/java/cn/quantgroup/xyqb/service/wechat/impl/WechatServiceImpl.java
View file @
a86d9332
package
cn
.
quantgroup
.
xyqb
.
service
.
wechat
.
impl
;
package
cn
.
quantgroup
.
xyqb
.
service
.
wechat
.
impl
;
import
cn.quantgroup.cloudconfig.SafeValue
;
import
cn.quantgroup.xyqb.entity.WechatUserInfo
;
import
cn.quantgroup.xyqb.entity.WechatUserInfo
;
import
cn.quantgroup.xyqb.model.webchat.AccessTokenResponse
;
import
cn.quantgroup.xyqb.model.webchat.AccessTokenResponse
;
import
cn.quantgroup.xyqb.repository.IWeChatUserRepository
;
import
cn.quantgroup.xyqb.repository.IWeChatUserRepository
;
...
@@ -10,6 +9,7 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -10,6 +9,7 @@ import com.alibaba.fastjson.JSONObject;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -28,9 +28,9 @@ public class WechatServiceImpl implements IWechatService {
...
@@ -28,9 +28,9 @@ public class WechatServiceImpl implements IWechatService {
@Autowired
@Autowired
@Qualifier
(
"stringRedisTemplate"
)
@Qualifier
(
"stringRedisTemplate"
)
private
RedisTemplate
<
String
,
String
>
redisTemplate
;
private
RedisTemplate
<
String
,
String
>
redisTemplate
;
@
SafeValue
(
"wechat.appid
"
)
@
Value
(
"${wechat.appid}
"
)
private
String
appId
;
private
String
appId
;
@
SafeValue
(
"wechat.secret
"
)
@
Value
(
"${wechat.secret}
"
)
private
String
secret
;
private
String
secret
;
@Autowired
@Autowired
private
IWeChatUserRepository
weChatUserRepository
;
private
IWeChatUserRepository
weChatUserRepository
;
...
...
src/main/java/cn/quantgroup/xyqb/util/ApplicationContextHolder.java
View file @
a86d9332
...
@@ -5,6 +5,7 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException;
...
@@ -5,6 +5,7 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
/**
/**
...
...
src/main/java/cn/quantgroup/xyqb/util/IPUtil.java
View file @
a86d9332
...
@@ -32,6 +32,7 @@ public class IPUtil {
...
@@ -32,6 +32,7 @@ public class IPUtil {
String
jvmTest
=
System
.
getProperty
(
"test"
);
String
jvmTest
=
System
.
getProperty
(
"test"
);
if
(
Boolean
.
valueOf
(
jvmTest
)){
if
(
Boolean
.
valueOf
(
jvmTest
)){
WHITE_ADDRESS
.
add
(
"192.168."
);
WHITE_ADDRESS
.
add
(
"192.168."
);
WHITE_ADDRESS
.
add
(
LOCAL_ADDRESS
);
}
}
}
}
...
...
src/main/resources/META-INF/app.properties
0 → 100644
View file @
a86d9332
app.id
=
xyqb-user2
namespace
=
application
\ No newline at end of file
src/main/resources/config/dev/application.properties
View file @
a86d9332
server.port
=
8082
security.sessions
=
if_required
security.sessions
=
if_required
spring.aop.proxy-target-class
=
true
spring.aop.proxy-target-class
=
true
src/main/resources/config/dev/xyqb.properties
deleted
100644 → 0
View file @
304c5135
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
src/main/resources/config/release01/application.properties
View file @
a86d9332
server.port
=
9001
security.sessions
=
if_required
security.sessions
=
if_required
server.session-timeout
=
86400
spring.aop.proxy-target-class
=
true
spring.aop.proxy-target-class
=
true
src/main/resources/config/release01/xyqb.properties
deleted
100644 → 0
View file @
304c5135
configserver.disable
=
0
configserver.system
=
xyqb-user
xyqb.data.mysql.max-pool-size
=
1000
# 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
=
172.16.1.179
xyqb.redis.master.port
=
6373
xyqb.redis.master.name
=
mymaster
xyqb.redis.sentinel1.host
=
172.16.1.179
xyqb.redis.sentinel1.port
=
26373
xyqb.redis.sentinel2.host
=
172.16.1.180
xyqb.redis.sentinel2.port
=
26373
xyqb.redis.sentinel3.host
=
172.16.1.181
xyqb.redis.sentinel3.port
=
26373
# 短信平台配置
sms.is.debug
=
0
# LKB client
lkb.client.url
=
http://openapi.quantgroup.cn/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://58.xyqb.com/LKB
# xyqb
xyqb.url
=
https://m.xyqb.com
xyqb.api.url
=
http://api.xyqb.com
#sdk
model.quantgroup.url
=
http://model.quantgroup.cn
xyqb.auth.url
=
http://auth.xyqb.com
xyqb-user.ui
=
http://passport.xyqb.com
xyqb-user.ui-s
=
https://passport.xyqb.com
#motan protocol
protocol.name
=
motan
protocol.contentLength
=
1048576
protocol.isDefault
=
true
#motan registry center
registry.protocol
=
zookeeper
registry.address
=
172.16.1.63:2181,172.16.1.64:2181,172.16.1.65:2181
motan.port
=
8082
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://userqry.xyqb.com
xyqb.domain
=
http://api.xyqb.com
xyqb.paycenter.url
=
http://payapi.xyqb.com/
xyqb.paycenter.id
=
3
#内部运营系统
xyqb.yunying.url
=
https://opapi.xyqb.com
#马甲包
loanvest.rabbitmq.connection.virtual-host
=
/loan_order
loanvest.rabbitmq.queue
=
loan_user_queue
#loanvest.rabbitmq.stateMsgQueue=loan_vest_msg_queue
loanvest.rabbitmq.exchange
=
loan_vest_exchange
loanvest.rabbitmq.connection.host
=
172.16.1.242
loanvest.rabbitmq.connection.port
=
56720
loanvest.rabbitmq.connection.user
=
rabbit_admin
loanvest.rabbitmq.connection.password
=
abc1234
#用户注册广播
register.rabbitmq.connection.virtual-host
=
/user_register
register.rabbitmq.queue
=
user_register_queue
register.rabbitmq.exchange
=
user_register_exchange
register.rabbitmq.connection.host
=
172.16.1.242
register.rabbitmq.connection.port
=
56720
register.rabbitmq.connection.user
=
rabbit_admin
register.rabbitmq.connection.password
=
abc1234
\ No newline at end of file
src/main/resources/config/test/application.properties
View file @
a86d9332
server.port
=
9001
security.sessions
=
if_required
security.sessions
=
if_required
spring.aop.proxy-target-class
=
true
spring.aop.proxy-target-class
=
true
src/main/resources/config/test/logback.xml
View file @
a86d9332
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<configuration>
<appender
name=
"STDOUT"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<appender
name=
"STDOUT"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<layout
class=
"ch.qos.logback.classic.PatternLayout"
>
<layout
class=
"ch.qos.logback.classic.PatternLayout"
>
<pattern>
%d{ISO8601} [%thread] [%-5level] %logger - %msg%n
</pattern>
<pattern>
%d{ISO8601} [%thread] [%-5level] %logger - %msg%n
</pattern>
</layout>
</layout>
</appender>
</appender>
<appender
name=
"FILE"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<appender
name=
"FILE"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<file>
/home/quant_group/logs/xyqb_user.log
</file>
<file>
/home/quant_group/logs/xyqb_user1.log
</file>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<fileNamePattern>
/home/quant_group/logs/xyqb_user
1
.log.%d{yyyy-MM-dd}
</fileNamePattern>
<fileNamePattern>
/home/quant_group/logs/xyqb_user.log.%d{yyyy-MM-dd}
</fileNamePattern>
<maxHistory>
30
</maxHistory>
<maxHistory>
30
</maxHistory>
</rollingPolicy>
</rollingPolicy>
<layout
class=
"ch.qos.logback.classic.PatternLayout"
>
<layout
class=
"ch.qos.logback.classic.PatternLayout"
>
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
<root
level=
"info"
>
<root
level=
"info"
>
<appender-ref
ref=
"FILE"
/>
<appender-ref
ref=
"FILE"
/>
<!-- <appender-ref ref="STDOUT"/>-->
</root>
</root>
</configuration>
</configuration>
\ No newline at end of file
src/test/java/user/TestUserLogin.java
View file @
a86d9332
...
@@ -4,25 +4,49 @@ import cn.quantgroup.xyqb.Bootstrap;
...
@@ -4,25 +4,49 @@ import cn.quantgroup.xyqb.Bootstrap;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.controller.external.user.InnerController
;
import
cn.quantgroup.xyqb.controller.external.user.InnerController
;
import
cn.quantgroup.xyqb.controller.internal.user.UserController
;
import
cn.quantgroup.xyqb.controller.internal.user.UserController
;
import
cn.quantgroup.xyqb.model.AuthBean
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.model.JsonResult
;
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
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.entity.UrlEncodedFormEntity
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.apache.http.util.EntityUtils
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.event.ContextRefreshedEvent
;
import
org.springframework.mock.web.MockHttpServletRequest
;
import
org.springframework.mock.web.MockHttpServletRequest
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
/**
* Created by 11 on 2017/1/3.
* Created by 11 on 2017/1/3.
*/
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
(
classes
=
Bootstrap
.
class
)
@SpringBootTest
(
classes
=
Bootstrap
.
class
)
@
WebAppConfiguration
@
Slf4j
public
class
TestUserLogin
{
public
class
TestUserLogin
{
private
MockHttpServletRequest
request
;
private
MockHttpServletRequest
request
=
new
MockHttpServletRequest
();
;
@Autowired
@Autowired
private
UserController
userController
;
private
UserController
userController
;
...
@@ -44,26 +68,33 @@ public class TestUserLogin {
...
@@ -44,26 +68,33 @@ public class TestUserLogin {
System
.
out
.
println
(
"-------------result:"
+
addressByUserId
);
System
.
out
.
println
(
"-------------result:"
+
addressByUserId
);
}
}
/**
* 用户密码登陆接口
*/
@Test
@Test
public
void
testUserLogin
()
{
public
void
testUserLogin
()
{
Long
code
=
1L
;
Long
code
=
1L
;
String
format
=
String
.
format
(
Constants
.
ZERO_FILL_TEMPLATE
,
code
);
String
format
=
String
.
format
(
Constants
.
ZERO_FILL_TEMPLATE
,
code
);
System
.
out
.
println
(
"-----------format:"
+
format
);
System
.
out
.
println
(
"-----------format:"
+
format
);
//访问xyqb-user拿到登录token
//访问xyqb-user拿到登录token
/*
Long channelId = 1L;
Long
channelId
=
1L
;
String
appChannel
=
"3"
;
String
appChannel
=
"3"
;
Long
createFrom
=
152L
;
Long
createFrom
=
152L
;
//String userId = "8c02a7b8-815f-4ba0-b39c-a9e6e52904de";
//String userId = "8c02a7b8-815f-4ba0-b39c-a9e6e52904de";
//测试userId为空的情况
//测试userId为空的情况
String
userId
=
""
;
String
userId
=
""
;
request.addHeader("authorization", "Basic ");
request
.
addHeader
(
"x-original-client-ip"
,
"172.16.0.1"
);
JsonResult jsonResult = userController.login(channelId, appChannel, createFrom, userId, request);
request
.
addHeader
(
"authorization"
,
"Basic MTg1MTMzNDE4MDg6MTIzNDU2"
);
JsonResult
jsonResult
=
userController
.
login
(
channelId
,
appChannel
,
createFrom
,
userId
,
"xyqb"
,
request
,
"xyqb"
,
"aaa"
);
AuthBean
authBean
=
(
AuthBean
)
jsonResult
.
getData
();
AuthBean
authBean
=
(
AuthBean
)
jsonResult
.
getData
();
String
token
=
authBean
.
getToken
();
String
token
=
authBean
.
getToken
();
System
.
out
.
println
(
"user token:"
+
token
);
System
.
out
.
println
(
"user token:"
+
token
);
//用获取到的token请求xyqb的receive_token
//用获取到的token请求xyqb的receive_token
CloseableHttpClient httpClient = HttpClient.httpClient();
HttpPost post = new HttpPost("http://localhost:9004/ex/login/receive_token");
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
HttpPost
post
=
new
HttpPost
(
"http://localhost:9004/ex/login/receive_token"
);
List
<
NameValuePair
>
pairList
=
new
ArrayList
<>();
List
<
NameValuePair
>
pairList
=
new
ArrayList
<>();
pairList
.
add
(
new
BasicNameValuePair
(
"token"
,
token
));
pairList
.
add
(
new
BasicNameValuePair
(
"token"
,
token
));
HttpEntity
entity
=
null
;
HttpEntity
entity
=
null
;
...
@@ -79,7 +110,7 @@ public class TestUserLogin {
...
@@ -79,7 +110,7 @@ public class TestUserLogin {
result
=
EntityUtils
.
toString
(
response
.
getEntity
());
result
=
EntityUtils
.
toString
(
response
.
getEntity
());
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
*/
}
}
}
}
}
src/test/resources/META-INF/app.properties
0 → 100644
View file @
a86d9332
app.id
=
xyqb-user2
namespace
=
application
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment