Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Administrator
/
kmr-h5-java
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
c0a51c54
authored
2017-12-02 10:56:38 +0800
by
ja
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
压测写法
1 parent
ecb31759
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
8 deletions
kmr_dp_HDP/src/main/java/com/example/controller/ScoreLogInfoController.java
kmr_dp_HDP/src/main/java/com/example/controller/WxController.java
kmr_dp_HDP/src/main/java/com/example/utils/thread/TestThread.java
kmr_dp_HDP/src/main/java/com/example/controller/ScoreLogInfoController.java
View file @
c0a51c5
...
...
@@ -4,8 +4,10 @@ import com.example.mapper.ConfigInfoMapper;
import
com.example.models.ConfigInfo
;
import
com.example.models.ScoreLogInfo
;
import
com.example.service.ScoreLogInfoService
;
import
com.example.service.http.HttpPostService
;
import
com.example.support.model.MessageEntity
;
import
com.example.utils.md5.MD5Utils
;
import
com.example.utils.thread.TestThread
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -38,6 +40,10 @@ public class ScoreLogInfoController {
@Autowired
private
ConfigInfoMapper
configInfoMapper
;
@Autowired
HttpPostService
httpPostService
;
@RequestMapping
(
"/save"
)
public
MessageEntity
save
(
HttpServletRequest
request
,
@ModelAttribute
ScoreLogInfo
scoreLogInfo
,
String
access_token
,
String
state
,
String
timestamp
,
String
rands
,
String
jsondata
,
String
checksum
,
String
secret
)
{
...
...
@@ -101,20 +107,50 @@ public class ScoreLogInfoController {
// public static void main(String[] args) {
// String access_token="4_ei8KYHlVKGE8zLguYGl7iHLEBf28u4nAzxocOMXGvzKoPxpU3Dxr_kq8cQlfDD34qFiJWgQpYxj3k3gobg0hyA";
// String openid="
oUmdXt90H2A784gfU7ChtsBsxU48
";
// String openid="
111
";
// String state="xxxx";
// String timestamp="1511923072";
// String rands="KeXxdzc7gQxkw6sE";
// String jsondata="%7B%22gtmc_code%22%3A404%7D";
// jsondata = URLDecoder.decode(jsondata);
// String jsondata=URLEncoder.encode("{\"gtmc_code\":404,\"gtmc_uid\":\"gtmc_uid\",\"gtmc_department\":\"gtmc_department\",\"gtmc_name\":\"gtmc_name\"}");
// System.out.println(jsondata);
// String checksum="5d179dbfdb49cafd3f27100df12d3b99";
// String secret="digi-campaign-2015";
// System.out.println(URLEncoder.encode("{\"gtmc_code\":404,\"gtmc_uid\":\"gtmc_uid\",\"gtmc_department\":\"gtmc_department\",\"gtmc_name\":\"gtmc_name\"}"));
// String checksum1 = MD5Utils.hash(access_token +openid +state +timestamp +rands +jsondata +secret);
// System.out.println(checksum);
// System.out.println(checksum1);
// }
@RequestMapping
(
"/test"
)
public
MessageEntity
test
(
HttpServletRequest
request
,
@RequestParam
String
open
)
{
MessageEntity
.
Builder
builder
=
new
MessageEntity
.
Builder
(
request
);
for
(
int
i
=
0
;
i
<
20
;
i
++){
String
openid
=
open
+
i
;
String
access_token
=
"4_ei8KYHlVKGE8zLguYGl7iHLEBf28u4nAzxocOMXGvzKoPxpU3Dxr_kq8cQlfDD34qFiJWgQpYxj3k3gobg0hyA"
;
String
state
=
"xxxx"
;
String
timestamp
=
"1511923072"
;
String
rands
=
"KeXxdzc7gQxkw6sE"
;
String
jsondata
=
"{\"gtmc_code\":200,\"gtmc_uid\":\"gtmc_uid\",\"gtmc_department\":\"gtmc_department\",\"gtmc_name\":\"gtmc_name\"}"
;
jsondata
=
URLDecoder
.
decode
(
jsondata
);
String
secret
=
"digi-campaign-2015"
;
String
checksum
=
MD5Utils
.
hash
(
access_token
+
openid
+
state
+
timestamp
+
rands
+
jsondata
+
secret
);
jsondata
=
URLEncoder
.
encode
(
jsondata
);
String
url
=
"http://114.215.122.43:9922/kmr/rank/save"
;
url
=
url
+
"?state="
+
state
;
url
=
url
+
"&access_token="
+
access_token
;
url
=
url
+
"&openid="
+
openid
;
url
=
url
+
"×tamp="
+
timestamp
;
url
=
url
+
"&rands="
+
rands
;
url
=
url
+
"&jsondata="
+
jsondata
;
url
=
url
+
"&secret="
+
secret
;
url
=
url
+
"&checksum="
+
checksum
;
url
=
url
+
"&nickname=xxxx"
;
url
=
url
+
"&avater=xxxx"
;
url
=
url
+
"&score=12"
;
System
.
out
.
println
(
url
);
TestThread
ds1
=
new
TestThread
(
httpPostService
,
url
);
Thread
t1
=
new
Thread
(
ds1
);
t1
.
start
();
}
return
builder
.
success
(
true
).
code
(
"2000"
).
create
();
}
}
\ No newline at end of file
...
...
kmr_dp_HDP/src/main/java/com/example/controller/WxController.java
View file @
c0a51c5
...
...
@@ -53,12 +53,12 @@ public class WxController {
@RequestMapping
(
"/getUser"
)
public
MessageEntity
oauth
(
HttpServletRequest
request
,
@RequestParam
String
access
T
oken
,
String
openid
)
{
public
MessageEntity
oauth
(
HttpServletRequest
request
,
@RequestParam
String
access
_t
oken
,
String
openid
)
{
MessageEntity
.
Builder
builder
=
new
MessageEntity
.
Builder
(
request
);
ClientConfigService
configService
=
new
ClientConfigServiceImpl
();
RestClient
restClient
=
new
RestClient
(
configService
.
getClientConfig
());
Resource
resource
=
restClient
.
resource
(
"https://api.weixin.qq.com/sns/userinfo"
);
resource
.
queryParam
(
"access_token"
,
access
T
oken
);
resource
.
queryParam
(
"access_token"
,
access
_t
oken
);
resource
.
queryParam
(
"openid"
,
openid
);
resource
.
queryParam
(
"lang"
,
"zh_CN"
);
ClientResponse
response
=
resource
.
get
();
...
...
kmr_dp_HDP/src/main/java/com/example/utils/thread/TestThread.java
0 → 100644
View file @
c0a51c5
package
com
.
example
.
utils
.
thread
;
import
com.example.service.http.HttpPostService
;
import
java.io.IOException
;
import
java.util.Map
;
/**
* Created by JA on 17/12/2.
*/
public
class
TestThread
implements
Runnable
{
HttpPostService
httpPostService
;
String
url
=
null
;
public
TestThread
(
HttpPostService
h
,
String
url
){
this
.
httpPostService
=
h
;
this
.
url
=
url
;
}
@Override
public
void
run
()
{
for
(
int
i
=
0
;
i
<
30
;
i
++){
try
{
Map
<
String
,
Object
>
map
=
this
.
httpPostService
.
httpPost
(
url
,
null
);
System
.
out
.
println
(
map
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
Please
register
or
sign in
to post a comment