|
|
@@ -133,6 +133,42 @@ public class AlbumService {
|
|
|
return PageList.pageList(pn, pageSize, total, list1);
|
|
|
}
|
|
|
|
|
|
+ public PageList<AlbumInfo> getUserAlbums(long userId, int pn) {
|
|
|
+ List<Integer> scopes = contentPermission.getUserScopes();
|
|
|
+ long loginUser = UserContext.getUserId();
|
|
|
+ if (loginUser == userId) {
|
|
|
+ scopes.add(PostScope.PRIVATE.getCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ AlbumQuery albumQuery = new AlbumQuery.Builder()
|
|
|
+ .createBy(userId)
|
|
|
+ .scope(scopes)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ int total = albumRepository.countPostAlbum(albumQuery);
|
|
|
+ Page page = new Page(pn, pageSize);
|
|
|
+ List<PostAlbum> list = albumRepository.getPostAlbums(page, albumQuery);
|
|
|
+ List<AlbumInfo> list1 = list.stream().map(postAlbum -> {
|
|
|
+ int scope = postAlbum.getScope();
|
|
|
+ String coverUrl = postAlbum.getCoverUrl();
|
|
|
+ if (scope != PostScope.PUBLIC.getCode() && coverUrl != null) {
|
|
|
+ ImageFile imageFile = imageRepository.getByUrl(coverUrl);
|
|
|
+ if (imageFile != null) {
|
|
|
+ int channelCode = imageFile.getChannelCode();
|
|
|
+ String objectId = imageFile.getObjectId();
|
|
|
+ try {
|
|
|
+ String signedUrl = ossService.getSignedUrl(channelCode, objectId);
|
|
|
+ postAlbum.setCoverUrl(signedUrl);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new AlbumInfo(postAlbum);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return PageList.pageList(pn, pageSize, total, list1);
|
|
|
+ }
|
|
|
+
|
|
|
public String getAlbumContent(Long albumId, Integer pn) {
|
|
|
long loginUser = UserContext.getUserId();
|
|
|
AlbumQuery albumQuery;
|