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

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
刘基明's avatar
刘基明 committed
4
import com.tanpu.community.api.enums.DeleteTagEnum;
刘基明's avatar
刘基明 committed
5 6
import com.tanpu.community.dao.entity.community.HomePageEntity;
import com.tanpu.community.dao.mapper.community.HomePageMapper;
刘基明's avatar
刘基明 committed
7
import org.apache.commons.collections4.CollectionUtils;
刘基明's avatar
刘基明 committed
8 9 10
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
刘基明's avatar
刘基明 committed
11
import java.util.Collections;
刘基明's avatar
刘基明 committed
12 13 14 15 16 17 18 19 20 21
import java.util.List;

@Service
public class HomePageService {

    @Resource

    private HomePageMapper homePageMapper;


刘基明's avatar
刘基明 committed
22 23

    public HomePageEntity selectByUserId(String userId) {
刘基明's avatar
刘基明 committed
24
        return homePageMapper.selectOne(new LambdaQueryWrapper<HomePageEntity>()
刘基明's avatar
刘基明 committed
25 26
                .eq(HomePageEntity::getUserId, userId)
                .eq(HomePageEntity::getDeleteTag,DeleteTagEnum.NOT_DELETED.getCode()));
刘基明's avatar
刘基明 committed
27 28
    }

刘基明's avatar
刘基明 committed
29 30
    public List<HomePageEntity> selectListByUserIds(List<String> userIds) {
        if (CollectionUtils.isEmpty(userIds)) {
刘基明's avatar
刘基明 committed
31 32
            return Collections.emptyList();
        }
刘基明's avatar
刘基明 committed
33
        return homePageMapper.selectList(new LambdaQueryWrapper<HomePageEntity>()
刘基明's avatar
刘基明 committed
34 35
                .eq(HomePageEntity::getDeleteTag,DeleteTagEnum.NOT_DELETED.getCode())
                .in(HomePageEntity::getUserId, userIds));
刘基明's avatar
刘基明 committed
36 37 38 39 40 41 42 43
    }

    public void update(HomePageEntity entity) {
        homePageMapper.updateById(entity);
    }

    public void insert(HomePageEntity entity) {
        homePageMapper.insert(entity);
刘基明's avatar
刘基明 committed
44 45
    }
}