ThemeService.java 15.6 KB
Newer Older
刘基明's avatar
刘基明 committed
1 2
package com.tanpu.community.service;

刘基明's avatar
刘基明 committed
3
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
刘基明's avatar
刘基明 committed
4
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
5
import com.tanpu.biz.common.enums.RelTypeEnum;
张辰's avatar
张辰 committed
6
import com.tanpu.biz.common.enums.community.ReportStatusEnum;
刘基明's avatar
刘基明 committed
7
import com.tanpu.common.exception.BizException;
张辰's avatar
张辰 committed
8
import com.tanpu.common.redis.RedisHelper;
9
import com.tanpu.common.util.JsonUtil;
刘基明's avatar
刘基明 committed
10
import com.tanpu.common.uuid.UuidGenHelper;
刘基明's avatar
刘基明 committed
11 12
import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.qo.TopicFollowQo;
13 14
import com.tanpu.community.api.beans.req.comment.CreateCommentReq;
import com.tanpu.community.api.beans.req.theme.ThemeContentReq;
刘基明's avatar
刘基明 committed
15
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp;
刘基明's avatar
刘基明 committed
16
import com.tanpu.community.api.enums.DeleteTagEnum;
刘基明's avatar
刘基明 committed
17
import com.tanpu.community.api.enums.ThemeTypeEnum;
刘基明's avatar
刘基明 committed
18
import com.tanpu.community.dao.entity.community.ThemeEntity;
刘基明's avatar
刘基明 committed
19
import com.tanpu.community.dao.entity.community.TimesCountEntity;
刘基明's avatar
刘基明 committed
20
import com.tanpu.community.dao.entity.community.VisitLogEntity;
刘基明's avatar
刘基明 committed
21
import com.tanpu.community.dao.mapper.community.ThemeMapper;
刘基明's avatar
刘基明 committed
22 23
import com.tanpu.community.dao.mapper.community.VisitLogMapper;
import com.tanpu.community.util.ConvertUtil;
刘基明's avatar
刘基明 committed
24
import com.tanpu.community.util.TimeUtils;
刘基明's avatar
刘基明 committed
25
import org.apache.commons.collections4.CollectionUtils;
刘基明's avatar
刘基明 committed
26
import org.apache.commons.lang3.StringUtils;
刘基明's avatar
刘基明 committed
27
import org.springframework.stereotype.Service;
刘基明's avatar
刘基明 committed
28
import org.springframework.transaction.annotation.Transactional;
刘基明's avatar
刘基明 committed
29

刘基明's avatar
刘基明 committed
30
import javax.annotation.Resource;
张辰's avatar
张辰 committed
31
import java.util.*;
刘基明's avatar
刘基明 committed
32
import java.util.stream.Collectors;
刘基明's avatar
刘基明 committed
33

刘基明's avatar
刘基明 committed
34 35 36
@Service
public class ThemeService {

刘基明's avatar
刘基明 committed
37
    @Resource
刘基明's avatar
刘基明 committed
38
    private ThemeMapper themeMapper;
刘基明's avatar
刘基明 committed
39

刘基明's avatar
刘基明 committed
40
    @Resource
刘基明's avatar
刘基明 committed
41 42
    private UuidGenHelper uuidGenHelper;

刘基明's avatar
刘基明 committed
43
    @Resource
张辰's avatar
张辰 committed
44
    private RedisHelper redisHelper;
刘基明's avatar
刘基明 committed
45 46
    @Resource
    private VisitLogMapper visitLogMapper;
刘基明's avatar
刘基明 committed
47 48
    @Resource
    private FeignService feignService;
张辰's avatar
张辰 committed
49

刘基明's avatar
刘基明 committed
50
    @Transactional
刘基明's avatar
刘基明 committed
51
    public void insertTheme(ThemeEntity themeEntity) {
刘基明's avatar
刘基明 committed
52
        if (StringUtils.isBlank(themeEntity.getThemeId())) {
刘基明's avatar
刘基明 committed
53 54 55
            themeEntity.setThemeId(uuidGenHelper.getUuidStr());
        }

刘基明's avatar
刘基明 committed
56 57 58
        themeMapper.insert(themeEntity);
    }

刘基明's avatar
刘基明 committed
59
    @Transactional
刘基明's avatar
刘基明 committed
60 61
    public void update(ThemeEntity themeEntity, String themeId) {
        themeMapper.update(themeEntity, new LambdaUpdateWrapper<ThemeEntity>().eq(ThemeEntity::getThemeId, themeId));
刘基明's avatar
刘基明 committed
62 63
    }

张辰's avatar
张辰 committed
64
    //n天内发表的所有主题
刘基明's avatar
刘基明 committed
65
    public List<ThemeEntity> queryRecentdaysOrHasTopic(Integer days) {
66

刘基明's avatar
刘基明 committed
67
        return themeMapper.queryRecentdaysOrHasTopic(DeleteTagEnum.NOT_DELETED.getCode(), TimeUtils.getDaysBefore(days), "");
68 69 70 71 72 73 74 75
    }

    //最新的n条主题
    public List<ThemeEntity> queryLatestThemes(Integer n) {
        LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
                .eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode())
                .last("limit " + n)
                .orderByDesc(ThemeEntity::getId);
刘基明's avatar
刘基明 committed
76 77 78 79

        return themeMapper.selectList(queryWrapper);
    }

刘基明's avatar
刘基明 committed
80
    //根据id返回主题详情(未删)
刘基明's avatar
刘基明 committed
81
    public ThemeEntity queryByThemeId(String themeId) {
刘基明's avatar
刘基明 committed
82
        return themeMapper.selectOne(new LambdaQueryWrapper<ThemeEntity>()
刘基明's avatar
刘基明 committed
83 84
                .eq(ThemeEntity::getThemeId, themeId)
                .eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode()));
刘基明's avatar
刘基明 committed
85 86
    }

张辰's avatar
张辰 committed
87 88
    //根据id返回主题详情(未删)
    public ThemeEntity queryByThemeIdIgnoreDelete(String themeId) {
刘基明's avatar
刘基明 committed
89
        ThemeEntity themeEntity = themeMapper.selectOne(new LambdaQueryWrapper<ThemeEntity>()
张辰's avatar
张辰 committed
90
                .eq(ThemeEntity::getThemeId, themeId));
刘基明's avatar
刘基明 committed
91
        return themeEntity;
张辰's avatar
张辰 committed
92 93
    }

94
    //根据用户id查询主题list
刘基明's avatar
刘基明 committed
95
    public List<ThemeEntity> queryThemesByUserIdCreateDesc(String userId, String lastId, Integer pageSize, Set<String> userPermitTopics) {
刘基明's avatar
刘基明 committed
96 97
        LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
                .eq(ThemeEntity::getAuthorId, userId)
98
                .eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode())
刘基明's avatar
刘基明 committed
99
                .in(ThemeEntity::getTopicId, userPermitTopics)
100
                .orderByDesc(ThemeEntity::getCreateTime);
刘基明's avatar
刘基明 committed
101 102
        if (StringUtils.isNotEmpty(lastId)) {
            ThemeEntity lastEntity = queryByThemeId(lastId);
刘基明's avatar
刘基明 committed
103
            if (lastEntity == null) throw new BizException("主题未找到,id:" + lastId);
104
            queryWrapper.lt(ThemeEntity::getCreateTime, lastEntity.getCreateTime());
刘基明's avatar
刘基明 committed
105
        }
刘基明's avatar
刘基明 committed
106
        if (pageSize != null) {
张辰's avatar
张辰 committed
107
            queryWrapper.last("limit " + pageSize);
刘基明's avatar
刘基明 committed
108 109 110 111
        }
        return themeMapper.selectList(queryWrapper);
    }

刘基明's avatar
刘基明 committed
112
    //根据ids返回主题详情,带分页
刘基明's avatar
刘基明 committed
113
    public List<ThemeEntity> queryByThemeIds(List<String> themeIds, String lastId, Integer pageSize) {
114
        if (CollectionUtils.isEmpty(themeIds)) {
刘基明's avatar
刘基明 committed
115 116
            return Collections.emptyList();
        }
刘基明's avatar
刘基明 committed
117 118 119 120 121
        LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
                .in(ThemeEntity::getThemeId, themeIds)
                .eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
        if (StringUtils.isNotEmpty(lastId)) {
            ThemeEntity lastEntity = queryByThemeId(lastId);
刘基明's avatar
刘基明 committed
122
            if (lastEntity == null) throw new BizException("主题未找到,id:" + lastId);
123
            queryWrapper.lt(ThemeEntity::getCreateTime, lastEntity.getCreateTime());
刘基明's avatar
刘基明 committed
124
        }
刘基明's avatar
刘基明 committed
125 126
        if (pageSize != null) {
            queryWrapper.last("limit " + pageSize);
刘基明's avatar
刘基明 committed
127 128
        }
        return themeMapper.selectList(queryWrapper);
刘基明's avatar
刘基明 committed
129 130
    }

刘基明's avatar
刘基明 committed
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
    //根据ids返回主题详情,带分页
    public List<ThemeEntity> queryByThemeIds(List<String> themeIds, String lastId, Integer pageSize, Set<String> userPermitTopics) {
        if (CollectionUtils.isEmpty(themeIds)) {
            return Collections.emptyList();
        }
        LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
                .in(ThemeEntity::getThemeId, themeIds)
                .in(ThemeEntity::getTopicId, userPermitTopics)
                .eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
        if (StringUtils.isNotEmpty(lastId)) {
            ThemeEntity lastEntity = queryByThemeId(lastId);
            if (lastEntity == null) throw new BizException("主题未找到,id:" + lastId);
            queryWrapper.lt(ThemeEntity::getCreateTime, lastEntity.getCreateTime());
        }
        if (pageSize != null) {
            queryWrapper.last("limit " + pageSize);
        }
        return themeMapper.selectList(queryWrapper);
    }

刘基明's avatar
刘基明 committed
151 152
    /**
     * 根据主题Id查询列表
153
     *
刘基明's avatar
刘基明 committed
154 155 156
     * @param themeIds
     * @return
     */
刘基明's avatar
刘基明 committed
157
    public List<ThemeEntity> queryByThemeIds(List<String> themeIds) {
158
        if (CollectionUtils.isEmpty(themeIds)) {
刘基明's avatar
刘基明 committed
159 160
            return Collections.emptyList();
        }
刘基明's avatar
刘基明 committed
161 162 163 164
        LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
                .in(ThemeEntity::getThemeId, themeIds)
                .eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());

刘基明's avatar
刘基明 committed
165 166
        List<ThemeEntity> themeEntities = themeMapper.selectList(queryWrapper);
        return themeEntities;
刘基明's avatar
刘基明 committed
167 168
    }

刘基明's avatar
刘基明 committed
169

刘基明's avatar
刘基明 committed
170
    /**
刘基明's avatar
刘基明 committed
171
     * 根据话题查询最新主题(可分页)
刘基明's avatar
刘基明 committed
172 173
     *
     * @param topidId  话题Id
刘基明's avatar
刘基明 committed
174 175 176
     * @param pageSize 查询数量
     * @return
     */
刘基明's avatar
刘基明 committed
177
    public List<ThemeEntity> queryNewestByTopic(String topidId, Integer pageStart, Integer pageSize, List<String> excludeIds) {
刘基明's avatar
刘基明 committed
178
        LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
张辰's avatar
张辰 committed
179 180 181 182
                .eq(ThemeEntity::getTopicId, topidId);
        if (!excludeIds.isEmpty()) {
            queryWrapper.notIn(ThemeEntity::getThemeId, excludeIds);
        }
刘基明's avatar
刘基明 committed
183
        queryWrapper.last("limit " + pageStart + ", " + pageSize)
184 185
                .orderByDesc(ThemeEntity::getCreateTime)
                .eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
刘基明's avatar
刘基明 committed
186
        return themeMapper.selectList(queryWrapper);
刘基明's avatar
刘基明 committed
187
    }
刘基明's avatar
刘基明 committed
188

刘基明's avatar
刘基明 committed
189
    //根据话题查询所有的主题Id,包括已删除的主题
刘基明's avatar
刘基明 committed
190
    public List<String> queryThemeIdsByTopic(String topidId) {
刘基明's avatar
刘基明 committed
191
        if (StringUtils.isEmpty(topidId)) {
刘基明's avatar
刘基明 committed
192 193
            return Collections.emptyList();
        }
刘基明's avatar
刘基明 committed
194 195 196 197 198 199
        LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
                .eq(ThemeEntity::getTopicId, topidId);
        queryWrapper.select(ThemeEntity::getThemeId);
        return themeMapper.selectList(queryWrapper).stream().map(ThemeEntity::getThemeId).collect(Collectors.toList());
    }

张辰's avatar
张辰 committed
200 201 202 203 204 205 206 207 208 209
    public List<String> queryThemeIdsByTopic(String topidId, Date startDate, Date endDate) {
        if (StringUtils.isEmpty(topidId)) {
            return Collections.emptyList();
        }
        LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
                .eq(ThemeEntity::getTopicId, topidId).gt(ThemeEntity::getCreateTime, startDate).lt(ThemeEntity::getCreateTime, endDate);
        queryWrapper.select(ThemeEntity::getThemeId);
        return themeMapper.selectList(queryWrapper).stream().map(ThemeEntity::getThemeId).collect(Collectors.toList());
    }

刘基明's avatar
刘基明 committed
210
    /**
刘基明's avatar
刘基明 committed
211
     * 根据作者查询主题分页列表
刘基明's avatar
刘基明 committed
212
     *
刘基明's avatar
刘基明 committed
213
     * @param userIds
刘基明's avatar
刘基明 committed
214
     * @param pageStart
刘基明's avatar
刘基明 committed
215
     * @param pageSize
刘基明's avatar
刘基明 committed
216
     * @param userPermitTopics
刘基明's avatar
刘基明 committed
217 218
     * @return
     */
刘基明's avatar
刘基明 committed
219
    public List<ThemeEntity> queryByUserIdsCreateDesc(List<String> userIds, Integer pageStart, Integer pageSize, Set<String> userPermitTopics) {
刘基明's avatar
刘基明 committed
220
        if (CollectionUtils.isEmpty(userIds)) {
刘基明's avatar
刘基明 committed
221 222
            return Collections.emptyList();
        }
刘基明's avatar
刘基明 committed
223 224
        // 权限控制,添加主题为空的情况
        userPermitTopics.add("");
刘基明's avatar
刘基明 committed
225
        LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
刘基明's avatar
刘基明 committed
226
                .in(ThemeEntity::getAuthorId, userIds)
刘基明's avatar
刘基明 committed
227
                .in(ThemeEntity::getTopicId, userPermitTopics)
刘基明's avatar
刘基明 committed
228 229 230
                .last("limit " + pageStart + ", " + pageSize)
                .orderByDesc(ThemeEntity::getCreateTime)
                .eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
刘基明's avatar
刘基明 committed
231
        return themeMapper.selectList(queryWrapper);
刘基明's avatar
刘基明 committed
232 233 234

    }

刘基明's avatar
刘基明 committed
235 236
    public Integer getForwardCountById(String themeId) {
        return themeMapper.selectCount(new LambdaQueryWrapper<ThemeEntity>()
刘基明's avatar
刘基明 committed
237
                .eq(ThemeEntity::getFormerThemeId, themeId)
刘基明's avatar
刘基明 committed
238 239
                .eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED));
    }
刘基明's avatar
刘基明 committed
240

刘基明's avatar
刘基明 committed
241
    public boolean judgeForwardByUser(String themeId, String userId) {
刘基明's avatar
刘基明 committed
242 243 244
        return themeMapper.selectCount(new LambdaQueryWrapper<ThemeEntity>()
                .eq(ThemeEntity::getFormerThemeId, themeId)
                .eq(ThemeEntity::getAuthorId, userId)
刘基明's avatar
刘基明 committed
245
                .eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED)) > 0;
刘基明's avatar
刘基明 committed
246 247 248
    }

    public Set<String> getForwardUsers(List<String> themeIds) {
刘基明's avatar
刘基明 committed
249
        if (CollectionUtils.isEmpty(themeIds)) {
刘基明's avatar
刘基明 committed
250 251
            return new HashSet<>();
        }
刘基明's avatar
刘基明 committed
252 253 254 255
        return themeMapper.selectList(new LambdaQueryWrapper<ThemeEntity>()
                .in(ThemeEntity::getFormerThemeId, themeIds)
                .eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED))
                .stream().map(ThemeEntity::getAuthorId).collect(Collectors.toSet());
刘基明's avatar
刘基明 committed
256
    }
刘基明's avatar
刘基明 committed
257

刘基明's avatar
刘基明 committed
258

刘基明's avatar
刘基明 committed
259
    @Transactional
刘基明's avatar
刘基明 committed
260
    public void deleteById(String themeId, String userId) {
刘基明's avatar
刘基明 committed
261 262
        ThemeEntity themeEntity = themeMapper.selectOne(new LambdaQueryWrapper<ThemeEntity>()
                .eq(ThemeEntity::getThemeId, themeId));
刘基明's avatar
刘基明 committed
263
        if (themeEntity == null || !themeEntity.getAuthorId().equals(userId)) {
刘基明's avatar
刘基明 committed
264
            throw new BizException("主题与用户不匹配,id:" + themeId + ",userId" + userId);
刘基明's avatar
刘基明 committed
265 266 267 268
        }
        themeEntity.setDeleteTag(DeleteTagEnum.DELETED.getCode());
        themeMapper.updateById(themeEntity);
    }
刘基明's avatar
刘基明 committed
269

刘基明's avatar
刘基明 committed
270 271
    /**
     * 查询更新节点后的用户新建主题数
272
     *
刘基明's avatar
刘基明 committed
273 274
     * @param userIds 用户ids
     * @param lastId  更新时间节点
刘基明's avatar
刘基明 committed
275 276
     * @return
     */
张辰's avatar
张辰 committed
277
    public Integer queryCountFromLastId(List<String> userIds, Long lastId) {
刘基明's avatar
刘基明 committed
278 279 280 281 282
        if (CollectionUtils.isEmpty(userIds)) {
            return 0;
        }
        LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
                .in(ThemeEntity::getAuthorId, userIds)
张辰's avatar
张辰 committed
283
                .gt(ThemeEntity::getId, lastId)
刘基明's avatar
刘基明 committed
284 285 286
                .eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
        return themeMapper.selectCount(queryWrapper);
    }
刘基明's avatar
刘基明 committed
287 288


289 290 291
    public void updateReportStatus(String themeId) {
        ThemeEntity themeEntity = queryByThemeId(themeId);
        if (themeEntity == null) {
刘基明's avatar
刘基明 committed
292
            throw new BizException("主题未找到,id:" + themeId);
293 294 295 296
        }
        themeEntity.setReportStatus(ReportStatusEnum.REPORTED.getCode());
        themeMapper.updateById(themeEntity);
    }
刘基明's avatar
刘基明 committed
297 298 299

    //统计主题集合的浏览量
    public Map<String, Integer> getForwardCountMap(List<String> themeIds) {
刘基明's avatar
刘基明 committed
300
        if (CollectionUtils.isEmpty(themeIds)) {
刘基明's avatar
刘基明 committed
301 302
            return new HashMap<String, Integer>();
        }
刘基明's avatar
刘基明 committed
303 304
        LambdaQueryWrapper<ThemeEntity> wrapper = new LambdaQueryWrapper<ThemeEntity>()
                .eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED)
刘基明's avatar
刘基明 committed
305
                .in(ThemeEntity::getFormerThemeId, themeIds)
刘基明's avatar
刘基明 committed
306 307 308 309 310
                .groupBy(ThemeEntity::getFormerThemeId);
        return themeMapper.selectCountByThemeIds(wrapper).stream()
                .collect(Collectors.toMap(TimesCountEntity::getId, TimesCountEntity::getTimes));
    }

刘基明's avatar
刘基明 committed
311 312 313
    public List<ThemeEntity> queryAllForward() {
        return themeMapper.selectList(new LambdaQueryWrapper<ThemeEntity>()
                .eq(ThemeEntity::getThemeType, ThemeTypeEnum.FORWARD.getCode())
刘基明's avatar
刘基明 committed
314
                .eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode())
刘基明's avatar
刘基明 committed
315 316
                .orderByAsc(ThemeEntity::getCreateTime));
    }
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331

    public String commentSyncForward(CreateCommentReq req, String userId) {
        // 评论构造theme content
        List<ThemeContentReq> themeContentReqs = Arrays.asList(ThemeContentReq.builder().type(RelTypeEnum.TEXT.type).value(req.getComment()).build());
        ThemeContentReq.builder().type(RelTypeEnum.TEXT.type).value(req.getComment()).build();
        ThemeEntity themeEntity = ThemeEntity.builder()
                .content(JsonUtil.toJson(themeContentReqs))
                .topicId("")
                .formerThemeId(req.getThemeId())
                .authorId(userId)
                .themeType(ThemeTypeEnum.FORWARD.getCode())
                .build();
        this.insertTheme(themeEntity);
        return themeEntity.getThemeId();
    }
刘基明's avatar
刘基明 committed
332 333 334 335 336 337 338 339 340 341 342


    public void queryCommentForTopic(List<TopicFollowQo> topicQos, String userId) {


        for (TopicFollowQo topic : topicQos) {
            String topicId = topic.getTopicId();
            // 最近的一条讨论
            ThemeEntity themeEntity = themeMapper.queryOneByTopicIdOrderByUpdateTimeDesc(topicId);
            if (themeEntity != null) {
                ThemeQo themeQo = ConvertUtil.themeEntityToQo(themeEntity);
刘基明's avatar
刘基明 committed
343

刘基明's avatar
刘基明 committed
344
                topic.setLastTheme(getUserName(themeQo.getAuthorId()) + ":" + themeQo.content.get(0).getValue());
刘基明's avatar
刘基明 committed
345
                topic.setLastThemeTime(TimeUtils.formatTopicListTime(themeEntity.getUpdateTime()));
刘基明's avatar
刘基明 committed
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361

            }

            // 查询更新条数
            VisitLogEntity visitLogEntity = visitLogMapper.queryLastByVisitorIdAndRefId(userId, topicId);
            if (visitLogEntity != null) {

                Integer updates = themeMapper.countByTopicIdAndCreateTimeAfter(topicId, visitLogEntity.getUpdateTime());
                topic.setUpdateCount(updates);
            } else {
                topic.setUpdateCount(0);
            }

        }

    }
刘基明's avatar
刘基明 committed
362 363

    private String getUserName(String authorId) {
刘基明's avatar
刘基明 committed
364
        UserInfoResp userInfoById = feignService.getUserInfoById(authorId);
刘基明's avatar
刘基明 committed
365
        if (StringUtils.isNotBlank(userInfoById.getNickName())) {
刘基明's avatar
刘基明 committed
366 367 368
            return userInfoById.getNickName();
        }
        return "理财师";
刘基明's avatar
刘基明 committed
369
    }
刘基明's avatar
刘基明 committed
370
}