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
package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.community.dao.entity.community.FansRelEntity;
import com.tanpu.community.dao.mapper.community.FansRelMapper;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
@EnableCaching
@Service
public class FansRelService {
@Resource
private FansRelMapper fansRelMapper;
public List<String> queryFansByFollowerId(String followerId) {
return fansRelMapper.selectList(new LambdaQueryWrapper<FansRelEntity>()
.eq(FansRelEntity::getFollowerId, followerId))
.stream().map(FansRelEntity::getIdolId).collect(Collectors.toList());
}
// @Cacheable(value = "tempCache", keyGenerator = "communityKeyGenerator")
public List<String> queryFansByIdolId(String idolId) {
return fansRelMapper.selectList(new LambdaQueryWrapper<FansRelEntity>()
.eq(FansRelEntity::getIdolId, idolId))
.stream().map(FansRelEntity::getFollowerId).collect(Collectors.toList());
}
public void addFans(String idolId, String followerId) {
FansRelEntity rel = new FansRelEntity();
rel.setIdolId(idolId);
rel.setFollowerId(followerId);
fansRelMapper.insert(rel);
}
}