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
package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.dao.entity.community.HomePageEntity;
import com.tanpu.community.dao.mapper.community.HomePageMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
@Service
public class HomePageService {
@Resource
private HomePageMapper homePageMapper;
public HomePageEntity selectByUserId(String userId) {
return homePageMapper.selectOne(new LambdaQueryWrapper<HomePageEntity>()
.eq(HomePageEntity::getUserId, userId)
.eq(HomePageEntity::getDeleteTag,DeleteTagEnum.NOT_DELETED.getCode()));
}
public List<HomePageEntity> selectListByUserIds(List<String> userIds) {
if (CollectionUtils.isEmpty(userIds)) {
return Collections.emptyList();
}
return homePageMapper.selectList(new LambdaQueryWrapper<HomePageEntity>()
.eq(HomePageEntity::getDeleteTag,DeleteTagEnum.NOT_DELETED.getCode())
.in(HomePageEntity::getUserId, userIds));
}
public void update(HomePageEntity entity) {
homePageMapper.updateById(entity);
}
public void insert(HomePageEntity entity) {
homePageMapper.insert(entity);
}
}