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); } }