Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
DuibaTestToolV2.1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
赵然
DuibaTestToolV2.1
Commits
1fc1d58e
Commit
1fc1d58e
authored
Nov 04, 2019
by
赵然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zr
parent
cdbd7608
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
172 additions
and
11 deletions
+172
-11
VisitorCounter.java
src/main/com/atguigu/springmvc/common/VisitorCounter.java
+41
-0
AccountModule.java
src/main/com/atguigu/springmvc/handlers/AccountModule.java
+5
-5
CoderModule.java
src/main/com/atguigu/springmvc/handlers/CoderModule.java
+7
-1
CollectModule.java
src/main/com/atguigu/springmvc/handlers/CollectModule.java
+65
-0
CreatUrlModule.java
src/main/com/atguigu/springmvc/handlers/CreatUrlModule.java
+6
-1
HbaseModule.java
src/main/com/atguigu/springmvc/handlers/HbaseModule.java
+6
-1
NewSignModule.java
src/main/com/atguigu/springmvc/handlers/NewSignModule.java
+7
-3
SignModule.java
src/main/com/atguigu/springmvc/handlers/SignModule.java
+5
-0
UserModule.java
src/main/com/atguigu/springmvc/handlers/UserModule.java
+10
-0
ViewService.java
src/main/com/atguigu/springmvc/service/ViewService.java
+20
-0
No files found.
src/main/com/atguigu/springmvc/common/VisitorCounter.java
0 → 100644
View file @
1fc1d58e
package
main
.
com
.
atguigu
.
springmvc
.
common
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.util.Properties
;
public
class
VisitorCounter
{
//使用Properties
private
static
Properties
p
=
new
Properties
();
public
static
void
writeCount
(
String
path
,
String
count
){
p
.
setProperty
(
"count"
,
count
);
try
{
p
.
store
(
new
FileOutputStream
(
path
),
""
);
//写入文件
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
public
static
String
readCount
(
String
path
)
{
String
count
=
"1"
;
File
f
=
new
File
(
path
);
if
(!
f
.
exists
())
{
writeCount
(
path
,
"1"
);
}
try
{
p
.
load
(
new
FileInputStream
(
path
));
count
=
p
.
getProperty
(
"count"
);
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
count
;
}
}
src/main/com/atguigu/springmvc/handlers/AccountModule.java
View file @
1fc1d58e
...
...
@@ -2,10 +2,7 @@ package main.com.atguigu.springmvc.handlers;
import
io.restassured.response.Response
;
import
main.com.atguigu.springmvc.common.MatcherString
;
import
main.com.atguigu.springmvc.service.AccountService
;
import
main.com.atguigu.springmvc.service.Authorization
;
import
main.com.atguigu.springmvc.service.NewActivityService
;
import
main.com.atguigu.springmvc.service.SqlService
;
import
main.com.atguigu.springmvc.service.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -28,6 +25,9 @@ public class AccountModule {
Authorization
authorization
;
@Autowired
SqlService
sqlService
;
@Autowired
ViewService
viewService
;
final
Base64
.
Decoder
decoder
=
Base64
.
getDecoder
();
...
...
@@ -38,7 +38,7 @@ public class AccountModule {
@RequestMapping
(
value
=
"/setAccount"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Map
setAccount
(
HttpServletRequest
request
)
throws
Exception
{
System
.
out
.
println
(
"日志:
访问统计"
);
viewService
.
count
(
);
String
partnerId
=
request
.
getParameter
(
"userId"
);
String
accountType
=
request
.
getParameter
(
"accountType"
);
...
...
src/main/com/atguigu/springmvc/handlers/CoderModule.java
View file @
1fc1d58e
package
main
.
com
.
atguigu
.
springmvc
.
handlers
;
import
main.com.atguigu.springmvc.common.MatcherString
;
import
main.com.atguigu.springmvc.service.ViewService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
...
...
@@ -13,7 +15,8 @@ import java.util.Base64;
//@RequestMapping("/Sign")
@Controller
public
class
CoderModule
{
@Autowired
ViewService
viewService
;
final
Base64
.
Decoder
decoder
=
Base64
.
getDecoder
();
final
Base64
.
Encoder
encoder
=
Base64
.
getEncoder
();
/**
...
...
@@ -22,6 +25,8 @@ public class CoderModule {
*/
@RequestMapping
(
value
=
"/Base64Coder"
,
method
=
RequestMethod
.
POST
)
public
ModelAndView
Base64Coder
(
HttpServletRequest
request
)
throws
Exception
{
viewService
.
count
();
String
original
=
request
.
getParameter
(
"original"
);
String
action
=
request
.
getParameter
(
"coder"
);
String
login
=
request
.
getParameter
(
"login"
);
...
...
@@ -66,6 +71,7 @@ public class CoderModule {
*/
@RequestMapping
(
value
=
"/URLCoder"
,
method
=
RequestMethod
.
POST
)
public
ModelAndView
URLCoder
(
HttpServletRequest
request
)
throws
Exception
{
viewService
.
count
();
String
original
=
request
.
getParameter
(
"original"
);
String
action
=
request
.
getParameter
(
"coder"
);
System
.
out
.
println
(
"初始文本为:"
+
original
);
...
...
src/main/com/atguigu/springmvc/handlers/CollectModule.java
View file @
1fc1d58e
...
...
@@ -327,4 +327,69 @@ public class CollectModule {
return
map
;
}
/**
* 功能:星宿台设置卡片数量操作
* @return
*/
@RequestMapping
(
value
=
"/setQuantity"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Map
setQuantity
(
HttpServletRequest
request
)
throws
Exception
{
java
.
net
.
URLDecoder
urlDecoder
=
new
java
.
net
.
URLDecoder
();
String
userId
=
urlDecoder
.
decode
(
request
.
getParameter
(
"userId"
),
"utf-8"
);
String
projectId
=
request
.
getParameter
(
"projectId"
);
String
spId
=
request
.
getParameter
(
"spId"
);
String
quantity
=
request
.
getParameter
(
"quantity"
);
System
.
out
.
println
(
"用户id:"
+
userId
);
System
.
out
.
println
(
"项目id:"
+
projectId
);
System
.
out
.
println
(
"道具id:"
+
spId
);
//userid转consumerid
Map
<
String
,
String
>
login_map
=
authorization
.
dafuwengLogin
(
Integer
.
parseInt
(
userId
));
System
.
out
.
println
(
"用户login_map为:"
+
login_map
.
toString
());
String
consumer_base64
=
String
.
valueOf
(
login_map
.
get
(
"_ac"
));
System
.
out
.
println
(
"用户consumer_base64为:"
+
consumer_base64
);
String
decodedText
=
new
String
(
decoder
.
decode
(
consumer_base64
));
System
.
out
.
println
(
"助力者consumer_base64转码后为:"
+
decodedText
);
String
consumerId
=
MatcherString
.
getString
(
decodedText
,
"cid\":(.*?)}"
,
1
);
System
.
out
.
println
(
"用户consumer_id为:"
+
consumerId
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
String
sql
=
"SELECT * FROM projectx.tb_user_sp where user_id = '"
+
consumerId
+
"' and project_id = '"
+
projectId
+
"' and sp_id = '"
+
spId
+
"' "
;
Response
response
=
sqlService
.
findSimpleResult
(
sql
);
System
.
out
.
println
(
"查询结果为:"
+
response
.
asString
());
if
(
response
.
asString
().
equals
(
"{}"
))
{
try
{
String
sqlAdd
=
"INSERT INTO projectx.tb_user_sp (project_id, user_id, sp_id, quantity, gmt_create, gmt_modified) values ('"
+
projectId
+
"', '"
+
consumerId
+
"', '"
+
spId
+
"', "
+
quantity
+
", '2019-09-25 15:58:11', '2019-09-27 14:23:57')"
;
System
.
out
.
println
(
"sql为:"
+
sqlAdd
);
sqlService
.
update
(
sqlAdd
);
System
.
out
.
println
(
"如果道具原本为空,重置成功!"
);
map
.
put
(
"success"
,
"true"
);
map
.
put
(
"message"
,
"道具数设置成功,用户"
+
userId
+
"的"
+
spId
+
"数量为:"
+
quantity
);
}
catch
(
Exception
e
)
{
map
.
put
(
"success"
,
"false"
);
map
.
put
(
"message"
,
"道具数设置失败!"
);
}
}
else
{
try
{
sqlService
.
update
(
"update projectx.tb_user_sp set quantity = '"
+
quantity
+
"' where user_id = '"
+
consumerId
+
"' and project_id = '"
+
projectId
+
"' and sp_id = '"
+
spId
+
"'"
);
System
.
out
.
println
(
"如果道具原本有值,重置成功!"
);
map
.
put
(
"success"
,
"true"
);
map
.
put
(
"message"
,
"道具数设置成功,用户"
+
userId
+
"的"
+
spId
+
"数量为:"
+
quantity
);
}
catch
(
Exception
e
)
{
map
.
put
(
"success"
,
"false"
);
map
.
put
(
"message"
,
"道具数设置失败!"
);
}
}
return
map
;
}
}
src/main/com/atguigu/springmvc/handlers/CreatUrlModule.java
View file @
1fc1d58e
package
main
.
com
.
atguigu
.
springmvc
.
handlers
;
import
cn.com.duiba.credits.sdk.CreditTool
;
import
main.com.atguigu.springmvc.service.ViewService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
...
...
@@ -16,7 +18,8 @@ import java.util.Map;
@Controller
public
class
CreatUrlModule
{
@Autowired
ViewService
viewService
;
private
static
String
httpArea
;
/**
* 功能:生成免登链接操作
...
...
@@ -25,6 +28,8 @@ public class CreatUrlModule {
@RequestMapping
(
value
=
"/urlLink"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Map
urlLink
(
HttpServletRequest
request
)
throws
Exception
{
viewService
.
count
();
String
evn
=
request
.
getParameter
(
"evn"
);
String
appkey
=
request
.
getParameter
(
"appkey"
);
...
...
src/main/com/atguigu/springmvc/handlers/HbaseModule.java
View file @
1fc1d58e
...
...
@@ -2,6 +2,8 @@ package main.com.atguigu.springmvc.handlers;
import
io.restassured.response.Response
;
import
main.com.atguigu.springmvc.common.HbaseService
;
import
main.com.atguigu.springmvc.service.ViewService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
...
...
@@ -14,7 +16,8 @@ import java.util.Map;
@Controller
public
class
HbaseModule
{
@Autowired
ViewService
viewService
;
/**
* 功能:Hbase查改操作
* @return
...
...
@@ -22,6 +25,8 @@ public class HbaseModule {
@RequestMapping
(
value
=
"/doHbase"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Map
urlLink
(
HttpServletRequest
request
)
throws
Exception
{
viewService
.
count
();
String
select
=
request
.
getParameter
(
"select"
);
String
reverse
=
request
.
getParameter
(
"reverse"
);
String
hashkey
=
request
.
getParameter
(
"hashkey"
);
...
...
src/main/com/atguigu/springmvc/handlers/NewSignModule.java
View file @
1fc1d58e
...
...
@@ -8,6 +8,7 @@ import main.com.atguigu.springmvc.common.MysqlUtils;
import
main.com.atguigu.springmvc.service.Authorization
;
import
main.com.atguigu.springmvc.service.NewActivityService
;
import
main.com.atguigu.springmvc.service.SqlService
;
import
main.com.atguigu.springmvc.service.ViewService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -27,6 +28,8 @@ public class NewSignModule {
Authorization
authorization
;
@Autowired
SqlService
sqlService
;
@Autowired
ViewService
viewService
;
final
Base64
.
Decoder
decoder
=
Base64
.
getDecoder
();
...
...
@@ -37,7 +40,7 @@ public class NewSignModule {
@RequestMapping
(
value
=
"/clearAll"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Map
clearAll
(
HttpServletRequest
request
)
throws
Exception
{
viewService
.
count
();
//String userId = request.getParameter("userId");
java
.
net
.
URLDecoder
urlDecoder
=
new
java
.
net
.
URLDecoder
();
String
userId
=
urlDecoder
.
decode
(
request
.
getParameter
(
"userId"
),
"utf-8"
);
...
...
@@ -96,7 +99,7 @@ public class NewSignModule {
@RequestMapping
(
value
=
"/clearToday"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Map
clearToday
(
HttpServletRequest
request
)
throws
Exception
{
viewService
.
count
();
//String userId = request.getParameter("userId");
java
.
net
.
URLDecoder
urlDecoder
=
new
java
.
net
.
URLDecoder
();
String
userId
=
urlDecoder
.
decode
(
request
.
getParameter
(
"userId"
),
"utf-8"
);
...
...
@@ -154,7 +157,7 @@ public class NewSignModule {
@RequestMapping
(
value
=
"/getSignInfo"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Map
getSignInfo
(
HttpServletRequest
request
)
throws
Exception
{
viewService
.
count
();
//String userId = request.getParameter("userId");
java
.
net
.
URLDecoder
urlDecoder
=
new
java
.
net
.
URLDecoder
();
String
userId
=
urlDecoder
.
decode
(
request
.
getParameter
(
"userId"
),
"utf-8"
);
...
...
@@ -223,6 +226,7 @@ public class NewSignModule {
@RequestMapping
(
value
=
"/doSign"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Map
doSign
(
HttpServletRequest
request
)
throws
Exception
{
viewService
.
count
();
java
.
net
.
URLDecoder
urlDecoder
=
new
java
.
net
.
URLDecoder
();
String
userId
=
urlDecoder
.
decode
(
request
.
getParameter
(
"userId"
),
"utf-8"
);
...
...
src/main/com/atguigu/springmvc/handlers/SignModule.java
View file @
1fc1d58e
...
...
@@ -2,6 +2,7 @@ package main.com.atguigu.springmvc.handlers;
import
main.com.atguigu.springmvc.common.MysqlUtils
;
import
main.com.atguigu.springmvc.service.SqlService
;
import
main.com.atguigu.springmvc.service.ViewService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -20,6 +21,8 @@ public class SignModule {
@Autowired
SqlService
sqlService
;
@Autowired
ViewService
viewService
;
private
MysqlUtils
jdbc
;
private
static
final
String
SUCCESS
=
"success"
;
...
...
@@ -31,6 +34,8 @@ public class SignModule {
*/
@RequestMapping
(
value
=
"/ClearSignData"
,
method
=
RequestMethod
.
POST
)
public
ModelAndView
ClearSignData
(
HttpServletRequest
request
)
throws
Exception
{
viewService
.
count
();
String
consumer_id
=
request
.
getParameter
(
"consumer_id"
);
String
source_relation_id
=
request
.
getParameter
(
"source_relation_id"
);
...
...
src/main/com/atguigu/springmvc/handlers/UserModule.java
View file @
1fc1d58e
...
...
@@ -10,6 +10,7 @@ import main.com.atguigu.springmvc.entities.UserDO;
import
main.com.atguigu.springmvc.service.Authorization
;
import
main.com.atguigu.springmvc.service.NewActivityService
;
import
main.com.atguigu.springmvc.service.SqlService
;
import
main.com.atguigu.springmvc.service.ViewService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -32,6 +33,8 @@ public class UserModule {
Authorization
authorization
;
@Autowired
SqlService
sqlService
;
@Autowired
ViewService
viewService
;
private
MysqlUtils
jdbc
;
private
static
Map
<
String
,
String
>
appMap
=
new
ConcurrentHashMap
<>();
...
...
@@ -44,6 +47,9 @@ public class UserModule {
@RequestMapping
(
value
=
"/searchInfo"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Map
searchInfo
(
HttpServletRequest
request
)
throws
Exception
{
viewService
.
count
();
String
partnerId
=
request
.
getParameter
(
"userId"
);
System
.
out
.
println
(
"用户partnerId为:"
+
partnerId
);
...
...
@@ -79,6 +85,8 @@ public class UserModule {
@RequestMapping
(
value
=
"/searchInfo2"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Map
searchInfo2
(
HttpServletRequest
request
)
throws
Exception
{
viewService
.
count
();
String
consumerId
=
request
.
getParameter
(
"consumerId"
);
System
.
out
.
println
(
"用户consumerId为:"
+
consumerId
);
...
...
@@ -114,6 +122,8 @@ public class UserModule {
@ResponseBody
public
Object
user
()
throws
Exception
{
viewService
.
count
();
Response
response
=
sqlService
.
findModeResult
(
"select * from dafuweng.user "
);
//System.out.println("值为:" + response.print());
...
...
src/main/com/atguigu/springmvc/service/ViewService.java
0 → 100644
View file @
1fc1d58e
package
main
.
com
.
atguigu
.
springmvc
.
service
;
import
org.springframework.stereotype.Service
;
import
main.com.atguigu.springmvc.common.VisitorCounter
;
@Service
public
class
ViewService
{
public
void
count
()
{
//訪問量
String
count
=
VisitorCounter
.
readCount
(
"D:/visitCount.txt"
);
int
count1
=
Integer
.
parseInt
(
count
);
count1
=
count1
+
1
;
count
=
String
.
valueOf
(
count1
).
toString
();
VisitorCounter
.
writeCount
(
"D:/visitCount.txt"
,
count
);
}
}
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