| | |
| | | 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; |
| | |
| | | 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: 附件关系表业务逻辑处理 |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据所属业务编号和类型统计 |
| | | * @param ownerId 所属业务编号 |
| | | * @param ownerType 所属业务类型 |
| | | * @return int 统计数 |
| | | */ |
| | | public int countByOwnerIdAndType(String ownerId, String ownerType){ |
| | | QueryWrapper<FileRelate> fileRelateQueryWrapper = new QueryWrapper<>(); |
| | | fileRelateQueryWrapper.eq("owner_id", ownerId).eq("owner_type", ownerType); |
| | | return mapper.selectCount(fileRelateQueryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 根据附件信息新增附件业务关系 |
| | | * @param fileInfo 附件信息 |
| | | */ |
| | | public void saveByFileInfo(FileInfo fileInfo) { |
| | | try { |
| | | // 保存业务关系 |
| | | FileRelate fileRelate = new FileRelate(); |
| | | fileRelate.setId(utilsClient.getNewTimeId()); |
| | | fileRelate.setFileId(fileInfo.getId()); |
| | | fileRelate.setMainId(fileInfo.getMainId()); |
| | | fileRelate.setOwnerId(fileInfo.getOwnerId()); |
| | | fileRelate.setOwnerCat(fileInfo.getOwnerCat()); |
| | | fileRelate.setOwnerType(fileInfo.getOwnerType()); |
| | | fileRelate.setUploaderId(fileInfo.getUploaderId()); |
| | | fileRelate.setUploaderName(fileInfo.getUploaderName()); |
| | | fileRelate.setUploaderType(fileInfo.getUploaderType()); |
| | | fileRelate.setCustId(fileInfo.getCustId()); |
| | | Date nowDate = DateUtils.getNowDate(); |
| | | fileRelate.setCreateTime(nowDate); |
| | | fileRelate.setUpdateTime(nowDate); |
| | | mapper.insert(fileRelate); |
| | | } catch (Exception e) { |
| | | log.error("service方法[FileRelateService.uploadFile]调用失败,异常信息:"+e, e); |
| | | throw new ServiceException("FileRelateService.uploadFile", e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据条件删除 |
| | | * @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); |
| | | } |
| | | } |
| | | } |