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
b7b44628
authored
2017-12-03 13:42:22 +0800
by
joe
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
增加分享次数
1 parent
3d76e1df
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
170 additions
and
45 deletions
kmr_dp_HDP/src/main/java/com/example/controller/ScoreLogInfoController.java
kmr_dp_HDP/src/main/java/com/example/mapper/ShareLogMapper.java
kmr_dp_HDP/src/main/java/com/example/models/ShareLog.java
kmr_dp_HDP/src/main/java/com/example/service/ScoreLogInfoService.java
kmr_dp_HDP/src/main/java/com/example/service/ScoreLogInfoServiceImpl.java
kmr_dp_HDP/src/main/resources/mappers/ShareLogMapper.xml
kmr_dp_HDP/src/main/java/com/example/controller/ScoreLogInfoController.java
View file @
b7b4462
...
...
@@ -43,15 +43,15 @@ public class ScoreLogInfoController {
@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
)
{
String
access_token
,
String
state
,
String
timestamp
,
String
rands
,
String
jsondata
,
String
checksum
,
String
secret
)
{
MessageEntity
.
Builder
builder
=
new
MessageEntity
.
Builder
(
request
);
boolean
flag
=
false
;
String
code
=
"9000"
;
String
openid
=
scoreLogInfo
.
getOpenid
();
if
(
StringUtils
.
isNotBlank
(
jsondata
))
{
if
(
StringUtils
.
isNotBlank
(
jsondata
))
{
jsondata
=
URLDecoder
.
decode
(
jsondata
);
ObjectMapper
objectMapper
=
new
ObjectMapper
();
Map
map
=
null
;
...
...
@@ -60,30 +60,33 @@ public class ScoreLogInfoController {
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
// if(map != null && map.containsKey("gtmc_code") && map.get("gtmc_code").toString().equals("200")){
// String checksum1 = MD5Utils.hash(access_token +openid +state +timestamp +rands +jsondata +secret);
// if(checksum1.equals(checksum)){
// if(map != null && map.containsKey("gtmc_code") &&
// map.get("gtmc_code").toString().equals("200")){
// String checksum1 = MD5Utils.hash(access_token +openid +state +timestamp
// +rands +jsondata +secret);
// if(checksum1.equals(checksum)){
scoreLogInfo
.
setGtmcUid
(
map
.
get
(
"gtmc_uid"
).
toString
());
scoreLogInfo
.
setGtmcDepartment
(
map
.
get
(
"gtmc_department"
).
toString
());
scoreLogInfo
.
setGtmcName
(
map
.
get
(
"gtmc_name"
).
toString
());
code
=
this
.
scoreLogInfoService
.
save
(
scoreLogInfo
);
if
(
code
.
equals
(
"2000"
))
{
if
(
code
.
equals
(
"2000"
))
{
flag
=
true
;
}
//
}
//
}
//
}
//
}
}
return
builder
.
success
(
flag
).
code
(
code
).
create
();
}
@RequestMapping
(
"/ranking"
)
public
MessageEntity
ranking
(
HttpServletRequest
request
,
@RequestParam
String
openid
,
@RequestParam
(
defaultValue
=
"10"
)
Long
limit
)
{
public
MessageEntity
ranking
(
HttpServletRequest
request
,
@RequestParam
String
openid
,
@RequestParam
(
defaultValue
=
"10"
)
Long
limit
)
{
MessageEntity
.
Builder
builder
=
new
MessageEntity
.
Builder
(
request
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
List
<
Map
<
String
,
Object
>>
rankingList
=
this
.
scoreLogInfoService
.
getRankingList
(
limit
);
Map
<
String
,
Object
>
myRanking
=
this
.
scoreLogInfoService
.
getMyRanking
(
openid
);
map
.
put
(
"rankingList"
,
rankingList
);
map
.
put
(
"myRanking"
,
myRanking
);
map
.
put
(
"rankingList"
,
rankingList
);
map
.
put
(
"myRanking"
,
myRanking
);
return
builder
.
success
(
true
).
code
(
"2000"
).
content
(
map
).
create
();
}
...
...
@@ -91,9 +94,13 @@ public class ScoreLogInfoController {
public
MessageEntity
counttoday
(
HttpServletRequest
request
,
@RequestParam
String
openid
)
{
MessageEntity
.
Builder
builder
=
new
MessageEntity
.
Builder
(
request
);
long
l
=
this
.
scoreLogInfoService
.
countToDay
(
openid
);
long
s
=
this
.
scoreLogInfoService
.
shareToday
(
openid
);
if
(
s
>
5
)
{
s
=
5
;
}
ConfigInfo
configInfo
=
configInfoMapper
.
get
();
Long
maxTime
=
configInfo
.
getMaxTime
();
long
lastTime
=
maxTime
-
l
;
long
lastTime
=
maxTime
-
l
+
s
;
return
builder
.
success
(
true
).
code
(
"2000"
).
content
(
lastTime
).
create
();
}
...
...
@@ -104,53 +111,61 @@ public class ScoreLogInfoController {
return
builder
.
success
(
true
).
code
(
"2000"
).
content
(
l
).
create
();
}
@RequestMapping
(
"/saveShare"
)
public
MessageEntity
saveShare
(
HttpServletRequest
request
,
@RequestParam
String
openid
)
{
MessageEntity
.
Builder
builder
=
new
MessageEntity
.
Builder
(
request
);
long
l
=
this
.
scoreLogInfoService
.
saveShare
(
openid
);
return
builder
.
success
(
true
).
code
(
"2000"
).
content
(
l
).
create
();
}
// public static void main(String[] args) {
// String access_token="4_ei8KYHlVKGE8zLguYGl7iHLEBf28u4nAzxocOMXGvzKoPxpU3Dxr_kq8cQlfDD34qFiJWgQpYxj3k3gobg0hyA";
// String openid="111";
// String state="xxxx";
// String timestamp="1511923072";
// String rands="KeXxdzc7gQxkw6sE";
// String jsondata=URLEncoder.encode("{\"gtmc_code\":404,\"gtmc_uid\":\"gtmc_uid\",\"gtmc_department\":\"gtmc_department\",\"gtmc_name\":\"gtmc_name\"}");
// System.out.println(jsondata);
// String secret="digi-campaign-2015";
// String checksum1 = MD5Utils.hash(access_token +openid +state +timestamp +rands +jsondata +secret);
// System.out.println(checksum1);
// }
// public static void main(String[] args) {
// String
// access_token="4_ei8KYHlVKGE8zLguYGl7iHLEBf28u4nAzxocOMXGvzKoPxpU3Dxr_kq8cQlfDD34qFiJWgQpYxj3k3gobg0hyA";
// String openid="111";
// String state="xxxx";
// String timestamp="1511923072";
// String rands="KeXxdzc7gQxkw6sE";
// String
// jsondata=URLEncoder.encode("{\"gtmc_code\":404,\"gtmc_uid\":\"gtmc_uid\",\"gtmc_department\":\"gtmc_department\",\"gtmc_name\":\"gtmc_name\"}");
// System.out.println(jsondata);
// String secret="digi-campaign-2015";
// String checksum1 = MD5Utils.hash(access_token +openid +state +timestamp
// +rands +jsondata +secret);
// System.out.println(checksum1);
// }
@RequestMapping
(
"/test"
)
public
MessageEntity
test
(
HttpServletRequest
request
,
@RequestParam
String
open
)
{
public
MessageEntity
test
(
HttpServletRequest
request
,
@RequestParam
String
open
)
{
MessageEntity
.
Builder
builder
=
new
MessageEntity
.
Builder
(
request
);
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
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\"}"
;
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
);
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
+
"?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
);
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/mapper/ShareLogMapper.java
0 → 100644
View file @
b7b4462
package
com
.
example
.
mapper
;
import
org.apache.ibatis.annotations.Param
;
import
com.example.models.ShareLog
;
/**
* Created by JA on 17/7/17.
*/
public
interface
ShareLogMapper
{
boolean
create
(
ShareLog
shareLog
);
long
countByDay
(
@Param
(
"openid"
)
String
openid
,
@Param
(
"startDate"
)
String
startDate
,
@Param
(
"endDate"
)
String
endDate
);
}
kmr_dp_HDP/src/main/java/com/example/models/ShareLog.java
0 → 100644
View file @
b7b4462
package
com
.
example
.
models
;
import
java.util.Date
;
/**
* Created by JA on 17/7/17.
*/
public
class
ShareLog
{
private
Long
id
;
private
String
openid
;
Date
shareTime
;
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
String
getOpenid
()
{
return
openid
;
}
public
void
setOpenid
(
String
openid
)
{
this
.
openid
=
openid
;
}
public
Date
getShareTime
()
{
return
shareTime
;
}
public
void
setShareTime
(
Date
shareTime
)
{
this
.
shareTime
=
shareTime
;
}
}
kmr_dp_HDP/src/main/java/com/example/service/ScoreLogInfoService.java
View file @
b7b4462
...
...
@@ -17,5 +17,10 @@ public interface ScoreLogInfoService {
long
countToDay
(
String
openid
);
long
shareToday
(
String
openid
);
long
countSum
(
String
openid
);
long
saveShare
(
String
openid
);
}
...
...
kmr_dp_HDP/src/main/java/com/example/service/ScoreLogInfoServiceImpl.java
View file @
b7b4462
...
...
@@ -2,8 +2,11 @@ package com.example.service;
import
com.example.mapper.ConfigInfoMapper
;
import
com.example.mapper.ScoreLogInfoMapper
;
import
com.example.mapper.ShareLogMapper
;
import
com.example.models.ConfigInfo
;
import
com.example.models.ScoreLogInfo
;
import
com.example.models.ShareLog
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -26,6 +29,9 @@ public class ScoreLogInfoServiceImpl implements ScoreLogInfoService {
@Autowired
private
ConfigInfoMapper
configInfoMapper
;
@Autowired
private
ShareLogMapper
shareLogMapper
;
@Override
public
String
save
(
ScoreLogInfo
scoreLogInfo
)
{
String
code
=
"2000"
;
...
...
@@ -80,9 +86,27 @@ public class ScoreLogInfoServiceImpl implements ScoreLogInfoService {
}
@Override
public
long
shareToday
(
String
openid
)
{
Date
date
=
new
Date
();
String
format
=
sdf
.
format
(
date
);
String
startDate
=
format
+
" 00:00:00"
;
String
endDate
=
format
+
" 23:59:59"
;
return
this
.
shareLogMapper
.
countByDay
(
openid
,
startDate
,
endDate
);
}
@Override
public
long
countSum
(
String
openid
)
{
return
this
.
scoreLogInfoMapper
.
countSum
(
openid
);
}
@Override
public
long
saveShare
(
String
openid
)
{
ShareLog
shareLog
=
new
ShareLog
();
shareLog
.
setOpenid
(
openid
);
shareLog
.
setShareTime
(
new
Date
());
shareLogMapper
.
create
(
shareLog
);
return
0
;
}
}
...
...
kmr_dp_HDP/src/main/resources/mappers/ShareLogMapper.xml
0 → 100644
View file @
b7b4462
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.example.mapper.ShareLogMapper"
>
<insert
id=
"create"
>
insert into `t_kmr_share_log` (
`openid`,
`share_time`
)
values(
#{openid},
#{share_time}
);
</insert>
<select
id=
"countByDay"
resultType=
"long"
>
select count(*) c
from `t_kmr_share_log`
where share_time BETWEEN #{startDate} and #{endDate}
and openid= #{openid};
</select>
</mapper>
\ No newline at end of file
Please
register
or
sign in
to post a comment