|
|
@@ -10,8 +10,6 @@ import cn.reghao.tnb.common.util.ConstantId;
|
|
|
import cn.reghao.tnb.common.util.StringUtil;
|
|
|
import cn.reghao.tnb.file.app.zdisk.db.mapper.CameraPhotoMapper;
|
|
|
import cn.reghao.tnb.file.app.zdisk.model.constant.AlbumType;
|
|
|
-import cn.reghao.tnb.file.app.zdisk.model.po.CameraPhoto;
|
|
|
-import cn.reghao.tnb.file.app.zdisk.model.query.DiskQuery;
|
|
|
import cn.reghao.tnb.file.app.zdisk.model.vo.DiskAlbumDetail;
|
|
|
import cn.reghao.tnb.file.app.zdisk.model.vo.DiskAlbumInfo;
|
|
|
import cn.reghao.tnb.file.app.zdisk.model.vo.DiskFileDetail;
|
|
|
@@ -353,42 +351,21 @@ public class DiskAlbumService {
|
|
|
public PageList<PhotoItem> getPhotoItems(int pageNumber) {
|
|
|
long loginUser = UserContext.getUserId();
|
|
|
Page page = new Page(pageNumber, ConstantId.PAGE_SIZE);
|
|
|
- String path = "/我的相册";
|
|
|
- DiskQuery diskQuery = new DiskQuery.Builder()
|
|
|
- .owner(loginUser)
|
|
|
- .path(path)
|
|
|
- .build();
|
|
|
- int total = diskFileMapper.countByDiskQuery(diskQuery);
|
|
|
- List<DiskFile> diskFileList = diskFileMapper.findDiskQueryByPage(page, diskQuery);
|
|
|
- List<String> fileIds = diskFileList.stream().map(DiskFile::getFileId).toList();
|
|
|
- if (fileIds.isEmpty()) {
|
|
|
- return PageList.empty();
|
|
|
- }
|
|
|
-
|
|
|
- List<CameraPhoto> cameraPhotoList = cameraPhotoMapper.findByFileIds(fileIds);
|
|
|
- if (cameraPhotoList.size() != fileIds.size()) {
|
|
|
- return PageList.empty();
|
|
|
- }
|
|
|
-
|
|
|
- Map<String, CameraPhoto> groupMap = cameraPhotoList.stream().collect(
|
|
|
- Collectors.groupingBy(CameraPhoto::getFileId,
|
|
|
- Collectors.collectingAndThen(Collectors.toList(), List::getFirst)));
|
|
|
- List<PhotoItem> list = diskFileList.stream().map(diskFile -> {
|
|
|
- String fileId = diskFile.getFileId();
|
|
|
- String sizeStr = byteConverter.convert(ByteType.Bytes, diskFile.getSize());
|
|
|
+ int total = cameraPhotoMapper.countPhotoItemsByOwner(loginUser);
|
|
|
+ List<PhotoItem> list = cameraPhotoMapper.findPhotoItemsByPage(page, loginUser);
|
|
|
+ list.forEach(item -> {
|
|
|
+ String fileId = item.getFileId();
|
|
|
+ String sizeStr = byteConverter.convert(ByteType.Bytes, Long.parseLong(item.getSize()));
|
|
|
String objectUrl = ossService.getSignedUrl(fileId, null);
|
|
|
- String url = "";
|
|
|
- String videoUrl = "";
|
|
|
- if (diskFile.getFileType() == ObjectType.Image.getCode()) {
|
|
|
- url = objectUrl;
|
|
|
- } else {
|
|
|
- videoUrl = objectUrl;
|
|
|
+ item.setSize(sizeStr);
|
|
|
+ item.setUrl(objectUrl);
|
|
|
+ if (item.getFileType() == ObjectType.Video.getCode()) {
|
|
|
+ item.setVideoUrl(objectUrl);
|
|
|
+ double duration1 = Double.parseDouble(item.getDuration());
|
|
|
+ String durationStr = StringUtil.getTimeStr((int) duration1);
|
|
|
+ item.setDuration(durationStr);
|
|
|
}
|
|
|
-
|
|
|
- CameraPhoto cameraPhoto = groupMap.get(fileId);
|
|
|
- String durationStr = StringUtil.getTimeStr(cameraPhoto.getDuration().intValue());
|
|
|
- return new PhotoItem(diskFile, sizeStr, url, videoUrl, cameraPhoto, durationStr);
|
|
|
- }).toList();
|
|
|
+ });
|
|
|
return PageList.pageList(pageNumber, ConstantId.PAGE_SIZE, total, list);
|
|
|
}
|
|
|
}
|