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
6a8587e7
authored
2017-12-03 16:37:25 +0800
by
joe
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
增加统计方法
1 parent
b7b44628
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
58 additions
and
26 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/mapper/ShareLogMapper.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 @
6a8587e
...
...
@@ -18,9 +18,12 @@ import org.springframework.web.bind.annotation.RestController;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLDecoder
;
import
java.net.URLEncoder
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -46,34 +49,37 @@ public class ScoreLogInfoController {
@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
secret
)
throws
ParseException
,
UnsupportedEncodingException
{
MessageEntity
.
Builder
builder
=
new
MessageEntity
.
Builder
(
request
);
boolean
flag
=
false
;
String
code
=
"9000"
;
String
openid
=
scoreLogInfo
.
getOpenid
();
if
(
StringUtils
.
isNotBlank
(
jsondata
))
{
jsondata
=
URLDecoder
.
decode
(
jsondata
);
ObjectMapper
objectMapper
=
new
ObjectMapper
();
Map
map
=
null
;
try
{
map
=
objectMapper
.
readValue
(
jsondata
,
Map
.
class
);
}
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)){
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"
))
{
flag
=
true
;
// String openid = scoreLogInfo.getOpenid();
Date
lastDay
=
sdf
.
parse
(
"2017-12-14 23:59:59"
);
if
(
lastDay
.
after
(
new
Date
()))
{
if
(
StringUtils
.
isNotBlank
(
jsondata
))
{
jsondata
=
URLDecoder
.
decode
(
jsondata
,
"utf-8"
);
ObjectMapper
objectMapper
=
new
ObjectMapper
();
Map
map
=
null
;
try
{
map
=
objectMapper
.
readValue
(
jsondata
,
Map
.
class
);
}
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)){
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"
))
{
flag
=
true
;
}
// }
// }
}
// }
// }
}
return
builder
.
success
(
flag
).
code
(
code
).
create
();
}
...
...
@@ -117,6 +123,14 @@ public class ScoreLogInfoController {
long
l
=
this
.
scoreLogInfoService
.
saveShare
(
openid
);
return
builder
.
success
(
true
).
code
(
"2000"
).
content
(
l
).
create
();
}
@RequestMapping
(
"/saveStat"
)
public
MessageEntity
saveStat
(
HttpServletRequest
request
,
@RequestParam
String
openid
)
{
MessageEntity
.
Builder
builder
=
new
MessageEntity
.
Builder
(
request
);
long
l
=
this
.
scoreLogInfoService
.
saveStat
(
openid
);
return
builder
.
success
(
true
).
code
(
"2000"
).
content
(
l
).
create
();
}
// public static void main(String[] args) {
// String
...
...
kmr_dp_HDP/src/main/java/com/example/controller/WxController.java
View file @
6a8587e
...
...
@@ -69,7 +69,7 @@ public class WxController {
try
{
readValue
=
mapper
.
readValue
(
responseEntity
,
Map
.
class
);
if
(
null
!=
readValue
.
get
(
"errcode"
))
{
return
null
;
return
builder
.
success
(
false
).
code
(
"999"
).
content
(
readValue
).
create
()
;
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();;
...
...
kmr_dp_HDP/src/main/java/com/example/mapper/ShareLogMapper.java
View file @
6a8587e
...
...
@@ -14,4 +14,6 @@ public interface ShareLogMapper {
long
countByDay
(
@Param
(
"openid"
)
String
openid
,
@Param
(
"startDate"
)
String
startDate
,
@Param
(
"endDate"
)
String
endDate
);
boolean
saveStat
(
@Param
(
"openid"
)
String
openid
);
}
...
...
kmr_dp_HDP/src/main/java/com/example/service/ScoreLogInfoService.java
View file @
6a8587e
...
...
@@ -23,4 +23,6 @@ public interface ScoreLogInfoService {
long
saveShare
(
String
openid
);
long
saveStat
(
String
openid
);
}
...
...
kmr_dp_HDP/src/main/java/com/example/service/ScoreLogInfoServiceImpl.java
View file @
6a8587e
...
...
@@ -109,4 +109,11 @@ public class ScoreLogInfoServiceImpl implements ScoreLogInfoService {
}
@Override
public
long
saveStat
(
String
openid
)
{
shareLogMapper
.
saveStat
(
openid
);
return
0
;
}
}
...
...
kmr_dp_HDP/src/main/resources/mappers/ShareLogMapper.xml
View file @
6a8587e
...
...
@@ -9,7 +9,7 @@
)
values(
#{openid},
#{share
_t
ime}
#{share
T
ime}
);
</insert>
...
...
@@ -21,6 +21,13 @@
and openid= #{openid};
</select>
<insert
id=
"saveStat"
>
insert into `t_kmr_stat_log`(
`openid`
) values (
#{openid}
)
</insert>
</mapper>
\ No newline at end of file
...
...
Please
register
or
sign in
to post a comment