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
de23e93d
Commit
de23e93d
authored
Dec 20, 2017
by
Java—红包—徐 然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
parent
5a5ab2e2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
23 deletions
+40
-23
pom.xml
pom.xml
+8
-10
Bootstrap.java
src/main/java/cn/quantgroup/xyqb/Bootstrap.java
+2
-3
TestUserLogin.java
src/test/java/user/TestUserLogin.java
+30
-10
No files found.
pom.xml
View file @
de23e93d
...
@@ -228,7 +228,7 @@
...
@@ -228,7 +228,7 @@
<dependency>
<dependency>
<groupId>
com.ctrip.framework.apollo
</groupId>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo-client
</artifactId>
<artifactId>
apollo-client
</artifactId>
<version>
0.
10.0
</version>
<version>
0.
9.2
</version>
</dependency>
</dependency>
<!--<dependency>-->
<!--<dependency>-->
<!--<groupId>cn.quantgroup</groupId>-->
<!--<groupId>cn.quantgroup</groupId>-->
...
@@ -337,13 +337,6 @@
...
@@ -337,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>
3.0
</version>
</dependency>
</dependencies>
<build>
<build>
<resources>
<resources>
<resource>
<resource>
...
@@ -359,8 +352,6 @@
...
@@ -359,8 +352,6 @@
<properties>
<properties>
<profiles.activation>
dev
</profiles.activation>
<profiles.activation>
dev
</profiles.activation>
</properties>
</properties>
<dependencies>
</dependencies>
<build>
<build>
<resources>
<resources>
<resource>
<resource>
...
@@ -375,6 +366,13 @@
...
@@ -375,6 +366,13 @@
<id>
test
</id>
<id>
test
</id>
<properties>
<properties>
<profiles.activation>
test
</profiles.activation>
<profiles.activation>
test
</profiles.activation>
<dependencies>
<dependency>
<groupId>
cn.quantgroup
</groupId>
<artifactId>
quantgroup-sms-sdk
</artifactId>
<version>
2.0.0.3-SNAPSHOT
</version>
</dependency>
</dependencies>
</properties>
</properties>
<build>
<build>
<resources>
<resources>
...
...
src/main/java/cn/quantgroup/xyqb/Bootstrap.java
View file @
de23e93d
package
cn
.
quantgroup
.
xyqb
;
package
cn
.
quantgroup
.
xyqb
;
import
com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig
;
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
;
...
@@ -22,7 +21,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
...
@@ -22,7 +21,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
@EnableAutoConfiguration
@EnableAutoConfiguration
@SpringBootApplication
@SpringBootApplication
@EnableCaching
@EnableCaching
//
@EnableApolloConfig({"application", "tech.msg.sdk", "cash.common"})
@EnableApolloConfig
({
"application"
,
"tech.msg.sdk"
,
"cash.common"
})
@PropertySource
(
value
=
{
"classpath:application.properties"
,
"classpath:xyqb.properties"
},
ignoreResourceNotFound
=
true
)
@PropertySource
(
value
=
{
"classpath:application.properties"
,
"classpath:xyqb.properties"
},
ignoreResourceNotFound
=
true
)
@Configuration
@Configuration
@EnableAspectJAutoProxy
@EnableAspectJAutoProxy
...
@@ -32,7 +31,7 @@ public class Bootstrap {
...
@@ -32,7 +31,7 @@ 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
.
addInitializers
(
new
ApolloPropertySourceInitializer
(
"application"
,
"tech.msg.sdk"
,
"cash.common"
));
//
springApplication.addInitializers(new ApolloPropertySourceInitializer("application", "tech.msg.sdk", "cash.common"));
springApplication
.
addListeners
(
new
ApplicationListener
<
ContextRefreshedEvent
>()
{
springApplication
.
addListeners
(
new
ApplicationListener
<
ContextRefreshedEvent
>()
{
@Override
@Override
...
...
src/test/java/user/TestUserLogin.java
View file @
de23e93d
...
@@ -4,13 +4,23 @@ import cn.quantgroup.xyqb.Bootstrap;
...
@@ -4,13 +4,23 @@ 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.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
;
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
;
...
@@ -23,6 +33,11 @@ import org.springframework.mock.web.MockHttpServletRequest;
...
@@ -23,6 +33,11 @@ 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.
*/
*/
...
@@ -31,7 +46,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
...
@@ -31,7 +46,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
@Slf4j
@Slf4j
public
class
TestUserLogin
{
public
class
TestUserLogin
{
private
MockHttpServletRequest
request
;
private
MockHttpServletRequest
request
=
new
MockHttpServletRequest
();
;
@Autowired
@Autowired
private
UserController
userController
;
private
UserController
userController
;
...
@@ -48,33 +63,38 @@ public class TestUserLogin {
...
@@ -48,33 +63,38 @@ public class TestUserLogin {
}
}
@Test
@Test
public
void
testJson
()
{
public
void
testJson
()
{
SpringApplication
springApplication
=
new
SpringApplication
(
Bootstrap
.
class
);
JsonResult
addressByUserId
=
innerController
.
findAddressByUserId
(
22L
);
JsonResult
addressByUserId
=
innerController
.
findAddressByUserId
(
22L
);
// JsonResult userByUserId = innerController.findUserByPhoneNo("17811111122");
// JsonResult userByUserId = innerController.findUserByPhoneNo("17811111122");
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
;
...
@@ -90,7 +110,7 @@ public class TestUserLogin {
...
@@ -90,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
();
}
*/
}
}
}
}
}
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