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
86b7db2f
Commit
86b7db2f
authored
Jan 06, 2017
by
lee_mingzhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
app login method add channelId param
parent
4bd06ce3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
2 deletions
+80
-2
AppController.java
...antgroup/xyqb/controller/external/user/AppController.java
+2
-1
application.properties
src/main/resources/config/dev/application.properties
+1
-1
TestUserLogin.java
src/test/java/user/TestUserLogin.java
+77
-0
No files found.
src/main/java/cn/quantgroup/xyqb/controller/external/user/AppController.java
View file @
86b7db2f
...
...
@@ -75,6 +75,7 @@ public class AppController implements IBaseController {
public
JsonResult
login
(
String
phoneNo
,
@RequestParam
(
required
=
false
,
defaultValue
=
"0"
)
Long
registerFrom
,
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Long
channelId
,
String
idNo
,
String
name
,
String
key
,
HttpServletRequest
request
)
{
if
(!
ValidationUtil
.
validatePhoneNo
(
phoneNo
))
{
...
...
@@ -95,7 +96,7 @@ public class AppController implements IBaseController {
return
JsonResult
.
buildErrorStateResult
(
"无效的商户"
,
null
);
}
SessionStruct
sessionStruct
=
sessionService
.
createSessionAndPersist
(
user
,
session
->
{
session
.
setAttribute
(
"channelId"
,
"1"
);
session
.
setAttribute
(
"channelId"
,
String
.
valueOf
(
channelId
)
);
session
.
setAttribute
(
"createdFrom"
,
String
.
valueOf
(
registerFrom
));
},
merchant
);
...
...
src/main/resources/config/dev/application.properties
View file @
86b7db2f
server.port
=
9001
server.port
=
8080
security.sessions
=
if_required
...
...
src/test/java/user/TestUserLogin.java
0 → 100644
View file @
86b7db2f
package
user
;
import
cn.quantgroup.xyqb.Bootstrap
;
import
cn.quantgroup.xyqb.controller.internal.user.UserController
;
import
cn.quantgroup.xyqb.model.AuthBean
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.test.HttpClient
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.NameValuePair
;
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.message.BasicNameValuePair
;
import
org.apache.http.util.EntityUtils
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.mock.web.MockHttpServletRequest
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
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.
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
Bootstrap
.
class
)
@WebAppConfiguration
public
class
TestUserLogin
{
private
MockHttpServletRequest
request
;
@Autowired
private
UserController
userController
;
@Test
public
void
testUserLogin
(){
//访问xyqb-user拿到登录token
/*Long channelId = 1L;
String appChannel = "3";
Long createFrom = 152L;
//String userId = "8c02a7b8-815f-4ba0-b39c-a9e6e52904de";
//测试userId为空的情况
String userId = "";
request.addHeader("authorization", "Basic ");
JsonResult jsonResult = userController.login(channelId, appChannel, createFrom, userId, request);
AuthBean authBean = (AuthBean) jsonResult.getData();
String token = authBean.getToken();
System.out.println("user token:" + token);
//用获取到的token请求xyqb的receive_token
CloseableHttpClient httpClient = HttpClient.httpClient();
HttpPost post = new HttpPost("http://localhost:9004/ex/login/receive_token");
List<NameValuePair> pairList = new ArrayList<>();
pairList.add(new BasicNameValuePair("token", token));
HttpEntity entity = null;
try {
entity = new UrlEncodedFormEntity(pairList, "UTF-8");
}catch (Exception e){
e.printStackTrace();
}
post.setEntity(entity);
String result = "";
try {
CloseableHttpResponse response = httpClient.execute(post);
result = EntityUtils.toString(response.getEntity());
} catch (IOException e) {
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