package com.tanpu.community.service; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.tanpu.community.api.enums.DeleteTagEnum; import com.tanpu.community.dao.entity.community.ThemeAttachmentEntity; import com.tanpu.community.dao.mapper.community.ThemeAttachmentMapper; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; @Service public class ThemeAttachmentService { @Resource private ThemeAttachmentMapper themeAttachmentMapper; public List<ThemeAttachmentEntity> selectByThemeId(String themeId){ return themeAttachmentMapper.selectList(new LambdaQueryWrapper<ThemeAttachmentEntity>() .eq(ThemeAttachmentEntity::getThemeId,themeId) .eq(ThemeAttachmentEntity::getDeleteTag,DeleteTagEnum.NOT_DELETED)); } public void insertList(List<ThemeAttachmentEntity> themeAttachments) { for (ThemeAttachmentEntity themeAttachment : themeAttachments) { themeAttachmentMapper.insert(themeAttachment); } return; } public int deleteByThemeId(String themeId) { ThemeAttachmentEntity target = ThemeAttachmentEntity.builder().deleteTag(DeleteTagEnum.DELETED.getCode()).build(); LambdaUpdateWrapper<ThemeAttachmentEntity> update = new LambdaUpdateWrapper<ThemeAttachmentEntity>().eq(ThemeAttachmentEntity::getThemeId, themeId); return themeAttachmentMapper.update(target,update); } }