b7b44628 by joe

增加分享次数

1 parent 3d76e1df
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);
}
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;
}
}
......@@ -16,6 +16,11 @@ public interface ScoreLogInfoService {
Map<String,Object> getMyRanking(String openid);
long countToDay(String openid);
long shareToday(String openid);
long countSum(String openid);
long saveShare(String openid);
}
......
......@@ -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;
......@@ -25,6 +28,9 @@ public class ScoreLogInfoServiceImpl implements ScoreLogInfoService {
@Autowired
private ConfigInfoMapper configInfoMapper;
@Autowired
private ShareLogMapper shareLogMapper;
@Override
public String save(ScoreLogInfo scoreLogInfo) {
......@@ -78,11 +84,29 @@ public class ScoreLogInfoServiceImpl implements ScoreLogInfoService {
String endDate = format + " 23:59:59";
return this.scoreLogInfoMapper.countByDay(openid,startDate,endDate);
}
@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;
}
}
......
<?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