ThemeAttachmentService.java 1.53 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 5
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.tanpu.community.api.enums.DeleteTagEnum;
刘基明's avatar
刘基明 committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
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>()
刘基明's avatar
刘基明 committed
21 22
                .eq(ThemeAttachmentEntity::getThemeId,themeId)
                .eq(ThemeAttachmentEntity::getDeleteTag,DeleteTagEnum.NOT_DELETED));
刘基明's avatar
刘基明 committed
23
    }
刘基明's avatar
刘基明 committed
24 25 26 27 28 29 30

    public void insertList(List<ThemeAttachmentEntity> themeAttachments) {
        for (ThemeAttachmentEntity themeAttachment : themeAttachments) {
            themeAttachmentMapper.insert(themeAttachment);
        }
        return;
    }
刘基明's avatar
刘基明 committed
31 32 33 34 35 36 37

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

    }
刘基明's avatar
刘基明 committed
38
}