1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.tanpu.community.service;
import com.tanpu.common.util.JsonUtil;
import com.tanpu.community.api.beans.qo.ThemeAnalysDO;
import com.tanpu.community.api.beans.qo.TopicRankQo;
import com.tanpu.community.api.enums.RankLogTypeEnum;
import com.tanpu.community.dao.entity.community.RankLogEntity;
import com.tanpu.community.dao.mapper.community.RankLogMapper;
import com.tanpu.community.util.BizUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
@Service
public class RankLogService {
@Resource
private RankLogMapper rankLogMapper;
private Integer pageSize = 50;
//话题排序日志
public void logTopicRank(List<TopicRankQo> rankList, LocalDateTime logTime, Long cost) {
if (CollectionUtils.isEmpty(rankList)) {
return;
}
//分页插入
for (int i = 0; i * pageSize < rankList.size(); i++) {
int pageStart = i * pageSize;
List<TopicRankQo> sublist = BizUtils.subList(rankList, pageStart, pageSize);
RankLogEntity entity = RankLogEntity.builder().rankTime(logTime)
.type(RankLogTypeEnum.TOPIC.getCode())
.totalCount(rankList.size())
.rankCost(cost)
.content(JsonUtil.toJson(sublist))
.pageNumber(i + 1)
.pageSize(sublist.size())
.build();
rankLogMapper.insert(entity);
}
}
//主题排序日志
public void logThemeRank(List<ThemeAnalysDO> themeList, LocalDateTime logTime, Long cost) {
if (CollectionUtils.isEmpty(themeList)) {
return;
}
//分页插入
for (int i = 0; i * pageSize < themeList.size(); i++) {
int pageStart = i * pageSize;
List<ThemeAnalysDO> sublist = BizUtils.subList(themeList, pageStart, pageSize);
RankLogEntity entity = RankLogEntity.builder().rankTime(logTime)
.type(RankLogTypeEnum.THEME.getCode())
.totalCount(themeList.size())
.rankCost(cost)
.content(JsonUtil.toJson(sublist))
.pageNumber(i + 1)
.pageSize(sublist.size())
.build();
rankLogMapper.insert(entity);
}
}
}