1.fix song collect status

main
Gary 9 months ago
parent dc0083e0f9
commit 254863f7cc

@ -146,7 +146,7 @@ public class JournalController {
@VerifyParam CollectQueryReq queryReq) { @VerifyParam CollectQueryReq queryReq) {
List<String> objectIds= getJournalObjectIds(queryReq); List<String> objectIds= getJournalObjectIds(queryReq);
UserLoginDto user = jwtUtil.getUserLoginDto(authorization); UserLoginDto user = jwtUtil.getUserLoginDto(authorization);
return songController.getCollectSongs(user.getUserId(), queryReq.getUserId(),objectIds); return songController.getCollectSongs(user.getUserId(), queryReq.getUserId(),objectIds, true);
} }
private List<String> getJournalObjectIds(CollectQueryReq queryReq) { private List<String> getJournalObjectIds(CollectQueryReq queryReq) {

@ -91,23 +91,23 @@ public class SongController {
@VerifyParam CollectQueryReq queryReq) { @VerifyParam CollectQueryReq queryReq) {
List<String> objectIds= getSongIds(queryReq); List<String> objectIds= getSongIds(queryReq);
UserLoginDto user = jwtUtil.getUserLoginDto(authorization); UserLoginDto user = jwtUtil.getUserLoginDto(authorization);
return getCollectSongs(user.getUserId(),queryReq.getUserId(),objectIds); return getCollectSongs(user.getUserId(),queryReq.getUserId(),objectIds,false);
} }
public Result<PageResult<SongRespDTO>> getCollectSongs(String loginUserId, String queryUserId, List<String> objectIds) { public Result<PageResult<SongRespDTO>> getCollectSongs(String loginUserId, String queryUserId, List<String> objectIds, boolean isJouranlSource) {
if (objectIds.isEmpty()) { if (objectIds.isEmpty()) {
return Result.success(new PageResult<SongRespDTO>(0L, Collections.emptyList())); return Result.success(new PageResult<SongRespDTO>(0L, Collections.emptyList()));
} }
List<SongInfo> songs = songInfoService.orderByField(objectIds); List<SongInfo> songs = songInfoService.orderByField(objectIds);
Set<String> songCollectSet = getMyCollectSet(loginUserId,queryUserId,objectIds); Set<String> songCollectSet = getMyCollectSet(loginUserId,queryUserId,objectIds,isJouranlSource);
List<SongRespDTO> results = songs.stream().map(s -> SongMapper.getSongRespDTO(s, songCollectSet)) List<SongRespDTO> results = songs.stream().map(s -> SongMapper.getSongRespDTO(s, songCollectSet))
.collect(Collectors.toList()); .collect(Collectors.toList());
return Result.success(new PageResult<SongRespDTO>(Long.valueOf(results.size()), results)); return Result.success(new PageResult<SongRespDTO>(Long.valueOf(results.size()), results));
} }
private Set<String> getMyCollectSet(String loginUser, String checkUser, List<String> objectIds) { private Set<String> getMyCollectSet(String loginUser, String checkUser, List<String> objectIds, boolean isJouranlSource) {
if(loginUser.equals(checkUser)) { if(loginUser.equals(checkUser)&&!isJouranlSource) {
return new HashSet<>(objectIds); return new HashSet<>(objectIds);
} }
List<String> myObjectIds=userCollectInfoService.findByUserIdAndCollectTypeAndObjectIdIn(loginUser,CollectTypeEnum.SONG,objectIds); List<String> myObjectIds=userCollectInfoService.findByUserIdAndCollectTypeAndObjectIdIn(loginUser,CollectTypeEnum.SONG,objectIds);

Loading…
Cancel
Save