forked from gzzfw/backEnd/gz-dyh

liyj
2024-09-05 716f57dacce347ba154f3b6a994f4e383e3a97a4
dyh-service/dyh-sys/src/main/java/cn/huge/module/file/service/FileRelateService.java
@@ -3,13 +3,22 @@
import cn.huge.base.common.exception.ServiceException;
import cn.huge.base.common.utils.DateUtils;
import cn.huge.base.common.utils.IdUtils;
import cn.huge.base.common.utils.ObjectUtils;
import cn.huge.module.client.api.impl.UtilsClientImpl;
import cn.huge.module.file.dao.mapper.FileRelateMapper;
import cn.huge.module.file.domain.po.FileInfo;
import cn.huge.module.file.domain.dto.UploaderDTO;
import cn.huge.module.file.domain.po.FileInfo;
import cn.huge.module.file.domain.po.FileRelate;
import cn.huge.module.sys.constant.FileOwnerTypeBaseEnum;
import cn.huge.module.sys.dto.FileInfoBaseDTO;
import cn.huge.module.sys.dto.FileTypeInfoBaseDTO;
import cn.huge.module.sys.dto.FileTypeTermsDTO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
@@ -20,9 +29,7 @@
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * @title: 附件关系表业务逻辑处理
@@ -173,4 +180,49 @@
        }
    }
    /**
     * 根据条件删除
     * @param fileTypeTermsDTO 条件
     */
    public void removeOne(FileTypeTermsDTO fileTypeTermsDTO){
        try{
            if (StringUtils.isNotEmpty(fileTypeTermsDTO.getOwnerId())) {
                QueryWrapper<FileRelate> fileRelateQueryWrapper = new QueryWrapper<>();
                fileRelateQueryWrapper.eq("owner_id", fileTypeTermsDTO.getOwnerId());
                if (StringUtils.isNotEmpty(fileTypeTermsDTO.getOwnerType())) {
                    fileRelateQueryWrapper.eq("owner_type", fileTypeTermsDTO.getOwnerType());
                }
                if (CollectionUtils.isNotEmpty(fileTypeTermsDTO.getOwnerTypeList())) {
                    fileRelateQueryWrapper.in("owner_type", fileTypeTermsDTO.getOwnerTypeList());
                }
                mapper.delete(fileRelateQueryWrapper);
            }
        }catch (Exception e){
            log.error("service方法[FileRelateService.removeOne]调用异常:"+e, e);
            throw new ServiceException("FileRelateService.removeOne", e);
        }
    }
    /**
     * 根据条件删除
     * @param fileTypeTermsDTO 条件
     */
    public void removeAll(FileTypeTermsDTO fileTypeTermsDTO){
        try{
            if (CollectionUtils.isNotEmpty(fileTypeTermsDTO.getOwnerIdList())) {
                QueryWrapper<FileRelate> fileRelateQueryWrapper = new QueryWrapper<>();
                fileRelateQueryWrapper.in("owner_id", fileTypeTermsDTO.getOwnerIdList());
                if (StringUtils.isNotEmpty(fileTypeTermsDTO.getOwnerType())) {
                    fileRelateQueryWrapper.eq("owner_type", fileTypeTermsDTO.getOwnerType());
                }
                if (CollectionUtils.isNotEmpty(fileTypeTermsDTO.getOwnerTypeList())) {
                    fileRelateQueryWrapper.in("owner_type", fileTypeTermsDTO.getOwnerTypeList());
                }
                mapper.delete(fileRelateQueryWrapper);
            }
        }catch (Exception e){
            log.error("service方法[FileRelateService.removeAll]调用异常:"+e, e);
            throw new ServiceException("FileRelateService.removeAll", e);
        }
    }
}