Merge branch 'feature/joint_log' into 'pre'

Feature/joint log

See merge request infra/oss!52
This commit is contained in:
田立勇 2022-12-21 03:15:41 +00:00
commit 62fa6d6840
3 changed files with 18 additions and 1 deletions

View File

@ -28,4 +28,6 @@ public interface FileDao extends IService<File> {
List<File> getByFileUuids(List<String> fileKey);
List<File> getByUrlMd5s(List<String> urlMd5List);
File getByUrlMd5(String urlMd5);
}

View File

@ -53,4 +53,13 @@ public class FileDaoImpl extends ServiceImpl<FileMapper, File> implements FileDa
.eq(File::getIsDelete, TableDelete.UN_DELETED)
.list();
}
@Override
public File getByUrlMd5(String urlMd5) {
return lambdaQuery().eq(File::getUrlMd5, urlMd5)
.eq(File::getStatus, FileStatus.SUCCESS)
.eq(File::getIsDelete, TableDelete.UN_DELETED)
.last("limit 1")
.one();
}
}

View File

@ -157,8 +157,14 @@ public class FileServiceImpl implements FileService {
@Override
public ServerFileDownloadResponse download(ServerFileDownloadDto dto) {
log.info("file download dto = {}", JsonUtil.obj2Str(dto));
File file = null;
String fileKey = dto.getFileKey();
File file = fileDao.getByFileUuid(fileKey);
if (fileKey.contains(IS_URL)) {
String urlMd5 = Utility.getMd5(fileKey);
file = fileDao.getByUrlMd5(urlMd5);
} else {
file = fileDao.getByFileUuid(fileKey);
}
if (Utility.objIsNull(file)) {
log.warn("file download is null, fileKey = {}", fileKey);
BizException.error(Utility.objIsNotNull(file), CodeEnum.FILE_NOT_FOUND);