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
db58f432
authored
2017-12-06 11:31:00 +0800
by
ja
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
添加统计用接口
1 parent
aec184ec
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
0 deletions
kmr_dp_HDP/src/main/java/com/example/controller/StatisticsController.java
kmr_dp_HDP/src/main/java/com/example/mapper/ShareLogMapper.java
kmr_dp_HDP/src/main/resources/mappers/ShareLogMapper.xml
kmr_dp_HDP/src/main/java/com/example/controller/StatisticsController.java
0 → 100644
View file @
db58f43
package
com
.
example
.
controller
;
import
com.example.mapper.ShareLogMapper
;
import
com.example.support.model.MessageEntity
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* Created by JA on 17/7/3.
*/
@RequestMapping
(
"/kmr/statistics"
)
@RestController
public
class
StatisticsController
{
@Autowired
private
ShareLogMapper
shareLogMapper
;
private
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
@RequestMapping
public
MessageEntity
statistics
(
HttpServletRequest
request
,
@RequestParam
(
required
=
false
)
String
time
)
{
MessageEntity
.
Builder
builder
=
new
MessageEntity
.
Builder
(
request
);
if
(
StringUtils
.
isBlank
(
time
)){
Date
date
=
new
Date
();
time
=
this
.
sdf
.
format
(
date
);
}
String
startDate
=
time
+
" 00:00:00"
;
String
endDate
=
time
+
" 23:59:59"
;
int
pv
=
this
.
shareLogMapper
.
findPVByDay
(
startDate
,
endDate
);
int
uv
=
this
.
shareLogMapper
.
findUVByDay
(
startDate
,
endDate
);
int
share
=
this
.
shareLogMapper
.
findShareByDay
(
startDate
,
endDate
);
int
img
=
this
.
shareLogMapper
.
findImgByDay
(
startDate
,
endDate
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"pv"
,
pv
);
map
.
put
(
"uv"
,
uv
);
map
.
put
(
"share"
,
share
);
map
.
put
(
"img"
,
img
);
return
builder
.
success
(
true
).
code
(
"2000"
).
content
(
map
).
create
();
}
}
kmr_dp_HDP/src/main/java/com/example/mapper/ShareLogMapper.java
View file @
db58f43
...
...
@@ -11,6 +11,12 @@ public interface ShareLogMapper {
boolean
create
(
ShareLog
shareLog
);
int
findPVByDay
(
@Param
(
"startDate"
)
String
startDate
,
@Param
(
"endDate"
)
String
endDate
);
int
findUVByDay
(
@Param
(
"startDate"
)
String
startDate
,
@Param
(
"endDate"
)
String
endDate
);
int
findShareByDay
(
@Param
(
"startDate"
)
String
startDate
,
@Param
(
"endDate"
)
String
endDate
);
int
findImgByDay
(
@Param
(
"startDate"
)
String
startDate
,
@Param
(
"endDate"
)
String
endDate
);
long
countByDay
(
@Param
(
"openid"
)
String
openid
,
@Param
(
"startDate"
)
String
startDate
,
@Param
(
"endDate"
)
String
endDate
);
...
...
kmr_dp_HDP/src/main/resources/mappers/ShareLogMapper.xml
View file @
db58f43
...
...
@@ -29,5 +29,25 @@
)
</insert>
<select
id=
"findPVByDay"
resultType=
"int"
>
SELECT count(*) c FROM `t_kmr_stat_log` where `create_at` BETWEEN #{startDate} and #{endDate};
</select>
<select
id=
"findUVByDay"
resultType=
"int"
>
SELECT count(DISTINCT `openid` ) c FROM `t_kmr_stat_log` where `create_at` BETWEEN #{startDate} and #{endDate};
</select>
<select
id=
"findShareByDay"
resultType=
"int"
>
select count(*) c
from `t_kmr_share_log`
where share_time BETWEEN #{startDate} and #{endDate}
</select>
<select
id=
"findImgByDay"
resultType=
"int"
>
SELECT count(*) c FROM `t_kmr_img_info` where `create_at` BETWEEN #{startDate} and #{endDate};
</select>
</mapper>
\ No newline at end of file
...
...
Please
register
or
sign in
to post a comment