| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.config.Interceptor.UserHelper; |
| | | import com.moral.api.entity.FileTable; |
| | | import com.moral.api.exception.BusinessException; |
| | | import com.moral.api.mapper.FileTableMapper; |
| | | import com.moral.api.pojo.enums.FileType; |
| | | import com.moral.api.pojo.enums.YesOrNo; |
| | | import com.moral.api.pojo.vo.file.FileAddressVo; |
| | | import com.moral.api.pojo.vo.file.FileVo; |
| | | import com.moral.api.pojo.vo.user.QxUser; |
| | | import com.moral.api.service.FileTableService; |
| | |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | sysFile.setCreateId(user.getUserId()).setCreateName(user.getUserName()); |
| | | } |
| | | save(sysFile); |
| | | return new FileVo().setFileId(sysFile.getFileId()).setFileName(originalFilename); |
| | | return new FileVo().setFileId(sysFile.getFileId()).setFileName(originalFilename).setFileType(fileType.getValue()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | private String getFilePath(String sysCode) { |
| | | return sysCode.concat(StringUtils.SLASH).concat(StringUtils.SLASH).concat(DateUtils.dateToDateString(new Date(),DateUtils.yyyyMMdd_EN)).concat(StringUtils.SLASH); |
| | | return sysCode.concat(StringUtils.SLASH).concat(DateUtils.dateToDateString(new Date(),DateUtils.yyyyMMdd_EN)).concat(StringUtils.SLASH); |
| | | } |
| | | |
| | | public void storageFile(MultipartFile file, String originalFilename, String targetFolder) { |
| | |
| | | // 2.2.筛选出需要保存的文件 |
| | | list.forEach(it -> { |
| | | existsList.removeIf(file -> file.getFileId().equals(it.getFileId())); |
| | | it.setFileId(relationId); |
| | | FileTable file = new FileTable(); |
| | | BeanUtils.copyProperties(it,file); |
| | | file.setRelationId(relationId); |
| | | addList.add(file); |
| | | }); |
| | | if (!CollectionUtils.isEmpty(addList)) { |
| | |
| | | FileVo fileVo = new FileVo(); |
| | | fileVo.setFileId(it.getFileId()); |
| | | fileVo.setFileName(it.getFileName()); |
| | | fileVo.setFileType(it.getFileType()); |
| | | list.add(fileVo); |
| | | }); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public List<FileAddressVo> list(int relationId, int fileModule, int fileType) { |
| | | List<FileAddressVo> list = new ArrayList<>(); |
| | | List<FileTable> existsList = this.lambdaQuery().eq(FileTable::getRelationId, relationId) |
| | | .eq(FileTable::getFileModule, fileModule) |
| | | .eq(Objects.nonNull(fileType),FileTable::getFileType,fileType) |
| | | .eq(FileTable::getIsDel, YesOrNo.NO.value).orderByAsc(FileTable::getCreateTime).list(); |
| | | existsList.forEach(it->{ |
| | | FileAddressVo fileVo = new FileAddressVo(); |
| | | fileVo.setFileId(it.getFileId()); |
| | | fileVo.setFileName(it.getFileName()); |
| | | fileVo.setFileType(it.getFileType()); |
| | | fileVo.setFileAddress(it.getFileAddress()); |
| | | list.add(fileVo); |
| | | }); |
| | | return list; |