b7b44628 by joe

增加分享次数

1 parent 3d76e1df
1 package com.example.mapper;
2
3 import org.apache.ibatis.annotations.Param;
4
5 import com.example.models.ShareLog;
6
7 /**
8 * Created by JA on 17/7/17.
9 */
10 public interface ShareLogMapper {
11
12 boolean create(ShareLog shareLog);
13
14 long countByDay(@Param("openid") String openid, @Param("startDate") String startDate,
15 @Param("endDate") String endDate);
16
17 }
1 package com.example.models;
2
3 import java.util.Date;
4
5 /**
6 * Created by JA on 17/7/17.
7 */
8 public class ShareLog {
9
10 private Long id;
11 private String openid;
12 Date shareTime;
13
14 public Long getId() {
15 return id;
16 }
17
18 public void setId(Long id) {
19 this.id = id;
20 }
21
22 public String getOpenid() {
23 return openid;
24 }
25
26 public void setOpenid(String openid) {
27 this.openid = openid;
28 }
29
30 public Date getShareTime() {
31 return shareTime;
32 }
33
34 public void setShareTime(Date shareTime) {
35 this.shareTime = shareTime;
36 }
37
38 }
...@@ -16,6 +16,11 @@ public interface ScoreLogInfoService { ...@@ -16,6 +16,11 @@ public interface ScoreLogInfoService {
16 Map<String,Object> getMyRanking(String openid); 16 Map<String,Object> getMyRanking(String openid);
17 17
18 long countToDay(String openid); 18 long countToDay(String openid);
19
20 long shareToday(String openid);
19 21
20 long countSum(String openid); 22 long countSum(String openid);
23
24 long saveShare(String openid);
25
21 } 26 }
......
...@@ -2,8 +2,11 @@ package com.example.service; ...@@ -2,8 +2,11 @@ package com.example.service;
2 2
3 import com.example.mapper.ConfigInfoMapper; 3 import com.example.mapper.ConfigInfoMapper;
4 import com.example.mapper.ScoreLogInfoMapper; 4 import com.example.mapper.ScoreLogInfoMapper;
5 import com.example.mapper.ShareLogMapper;
5 import com.example.models.ConfigInfo; 6 import com.example.models.ConfigInfo;
6 import com.example.models.ScoreLogInfo; 7 import com.example.models.ScoreLogInfo;
8 import com.example.models.ShareLog;
9
7 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
8 import org.springframework.stereotype.Service; 11 import org.springframework.stereotype.Service;
9 12
...@@ -25,6 +28,9 @@ public class ScoreLogInfoServiceImpl implements ScoreLogInfoService { ...@@ -25,6 +28,9 @@ public class ScoreLogInfoServiceImpl implements ScoreLogInfoService {
25 28
26 @Autowired 29 @Autowired
27 private ConfigInfoMapper configInfoMapper; 30 private ConfigInfoMapper configInfoMapper;
31
32 @Autowired
33 private ShareLogMapper shareLogMapper;
28 34
29 @Override 35 @Override
30 public String save(ScoreLogInfo scoreLogInfo) { 36 public String save(ScoreLogInfo scoreLogInfo) {
...@@ -78,11 +84,29 @@ public class ScoreLogInfoServiceImpl implements ScoreLogInfoService { ...@@ -78,11 +84,29 @@ public class ScoreLogInfoServiceImpl implements ScoreLogInfoService {
78 String endDate = format + " 23:59:59"; 84 String endDate = format + " 23:59:59";
79 return this.scoreLogInfoMapper.countByDay(openid,startDate,endDate); 85 return this.scoreLogInfoMapper.countByDay(openid,startDate,endDate);
80 } 86 }
87
88 @Override
89 public long shareToday(String openid) {
90 Date date = new Date();
91 String format = sdf.format(date);
92 String startDate = format + " 00:00:00";
93 String endDate = format + " 23:59:59";
94 return this.shareLogMapper.countByDay(openid,startDate,endDate);
95 }
81 96
82 @Override 97 @Override
83 public long countSum(String openid) { 98 public long countSum(String openid) {
84 return this.scoreLogInfoMapper.countSum(openid); 99 return this.scoreLogInfoMapper.countSum(openid);
85 } 100 }
101
102 @Override
103 public long saveShare(String openid) {
104 ShareLog shareLog = new ShareLog();
105 shareLog.setOpenid(openid);
106 shareLog.setShareTime(new Date());
107 shareLogMapper.create(shareLog);
108 return 0;
109 }
86 110
87 111
88 } 112 }
......
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3 <mapper namespace="com.example.mapper.ShareLogMapper">
4
5 <insert id="create">
6 insert into `t_kmr_share_log` (
7 `openid`,
8 `share_time`
9 )
10 values(
11 #{openid},
12 #{share_time}
13 );
14 </insert>
15
16
17 <select id="countByDay" resultType="long">
18 select count(*) c
19 from `t_kmr_share_log`
20 where share_time BETWEEN #{startDate} and #{endDate}
21 and openid= #{openid};
22 </select>
23
24
25
26 </mapper>
...\ No newline at end of file ...\ No newline at end of file