6a8587e7 by joe

增加统计方法

1 parent b7b44628
......@@ -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,13 +49,15 @@ 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();
// 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);
jsondata = URLDecoder.decode(jsondata,"utf-8");
ObjectMapper objectMapper = new ObjectMapper();
Map map = null;
try {
......@@ -75,6 +80,7 @@ public class ScoreLogInfoController {
// }
// }
}
}
return builder.success(flag).code(code).create();
}
......@@ -118,6 +124,14 @@ public class ScoreLogInfoController {
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
// access_token="4_ei8KYHlVKGE8zLguYGl7iHLEBf28u4nAzxocOMXGvzKoPxpU3Dxr_kq8cQlfDD34qFiJWgQpYxj3k3gobg0hyA";
......
......@@ -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();;
......
......@@ -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);
}
......
......@@ -23,4 +23,6 @@ public interface ScoreLogInfoService {
long saveShare(String openid);
long saveStat(String openid);
}
......
......@@ -109,4 +109,11 @@ public class ScoreLogInfoServiceImpl implements ScoreLogInfoService {
}
@Override
public long saveStat(String openid) {
shareLogMapper.saveStat(openid);
return 0;
}
}
......
......@@ -9,7 +9,7 @@
)
values(
#{openid},
#{share_time}
#{shareTime}
);
</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
......