Changeset 591919d


Ignore:
Timestamp:
02/06/26 21:36:01 (5 months ago)
Author:
Filip Gavrilovski <filipgavrilovski28@…>
Branches:
main
Children:
5938bc9
Parents:
b071fb4
Message:

add album to songs on landing page

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • finkwave/src/main/java/com/ukim/finki/develop/finkwave/controller/SongController.java

    rb071fb4 r591919d  
    3232    public HttpEntity<List<MusicalEntityDto>> searchSongs(
    3333            @RequestParam(name = "q") String searchTerm){
    34         return ResponseEntity.ok(songService.searchSongs(null, searchTerm));
     34        return ResponseEntity.ok(songService.searchSongs(searchTerm));
    3535    }
    3636
  • finkwave/src/main/java/com/ukim/finki/develop/finkwave/model/dto/MusicalEntityDto.java

    rb071fb4 r591919d  
    1717    private String cover;
    1818    private Boolean isLikedByCurrentUser;
     19    private String album;
    1920
    2021    public MusicalEntityDto(Long id, String title, String genre, String type, String releasedBy, Boolean isLikedByCurrentUser) {
     
    2627        this.isLikedByCurrentUser = isLikedByCurrentUser;
    2728    }
     29
     30    public MusicalEntityDto(Long id, String title, String genre, String type, String releasedBy, String cover, Boolean isLikedByCurrentUser) {
     31        this.id = id;
     32        this.title = title;
     33        this.genre = genre;
     34        this.type = type;
     35        this.releasedBy = releasedBy;
     36        this.cover = cover;
     37        this.isLikedByCurrentUser = isLikedByCurrentUser;
     38    }
    2839}
  • finkwave/src/main/java/com/ukim/finki/develop/finkwave/repository/SongRepository.java

    rb071fb4 r591919d  
    4949    @Query("""
    5050        SELECT NEW com.ukim.finki.develop.finkwave.model.dto.MusicalEntityDto(
    51         s.id, me.title, me.genre, 'SONG', u.fullName, me.cover,
    52             (EXISTS (SELECT 1 FROM Like l WHERE l.musicalEntity.id = s.id AND l.listener.id = :currentUserId))
     51            s.id,
     52            s.musicalEntities.title,
     53            s.musicalEntities.genre,
     54            'SONG',
     55            s.musicalEntities.releasedBy.nonAdminUser.user.fullName,
     56            s.musicalEntities.cover,
     57            (EXISTS (SELECT 1 FROM Like l WHERE l.musicalEntity.id = s.id AND l.listener.id = :currentUserId)),
     58            s.album.musicalEntities.title
    5359        )
    5460        FROM Song s
    55         JOIN s.musicalEntities me
    56         JOIN me.releasedBy a
    57         JOIN a.nonAdminUser nau
    58         JOIN nau.user u
    59         JOIN Listen l on l.song.id = s.id
    60         GROUP BY s.id, me.title, me.genre, u.fullName, me.cover
     61        GROUP BY s.id, s.musicalEntities.title, s.musicalEntities.genre,
     62            s.musicalEntities.releasedBy.nonAdminUser.user.fullName, s.musicalEntities.cover, s.album.musicalEntities.title
    6163        ORDER BY count(*) desc
    6264    """)
     
    6466    List<MusicalEntityDto> findTopByListens(@Param("currentUserId")Long currentUserId);
    6567
    66     // todo: fix is liked by user, currently returns hard coded false
    6768    @Query("""
    6869        SELECT NEW com.ukim.finki.develop.finkwave.model.dto.MusicalEntityDto(
    69             s.id, me.title, me.genre, 'SONG', u.fullName, me.cover, FALSE )
     70            s.id,
     71            s.musicalEntities.title,
     72            s.musicalEntities.genre,
     73            'SONG',
     74            s.musicalEntities.releasedBy.nonAdminUser.user.fullName,
     75            s.musicalEntities.cover,
     76            (EXISTS (SELECT 1 FROM Like l WHERE l.musicalEntity.id = s.id AND l.listener.id = :currentUserId))
     77        )
    7078        FROM Song s
    71         JOIN s.musicalEntities me
    72         JOIN me.releasedBy a
    73         JOIN a.nonAdminUser nau
    74         JOIN nau.user u
    75         WHERE me.title ILIKE '%' || :searchTerm || '%'
     79        WHERE s.musicalEntities.title ILIKE '%' || :searchTerm || '%'
    7680    """)
    7781    List<MusicalEntityDto> searchSongs(@Param("currentUserId")Long currentUserId, @Param("searchTerm") String searchTerm);
  • finkwave/src/main/java/com/ukim/finki/develop/finkwave/service/SongService.java

    rb071fb4 r591919d  
    1919    }
    2020
    21     public List<MusicalEntityDto> searchSongs(Long userId, String searchTerm){
     21    public List<MusicalEntityDto> searchSongs(String searchTerm){
     22        Long userId = authService.getCurrentUserID();
    2223        return songRepository.searchSongs(userId, searchTerm);
    2324    }
  • frontend/src/pages/LandingPage.tsx

    rb071fb4 r591919d  
    350350                                                                                                        </h3>
    351351                                                                                                        <p className="text-sm text-gray-400 mb-3 overflow-hidden text-ellipsis whitespace-nowrap">
    352                                                                                                                 {"<album>"}
     352                                                                                                                {song.album}
    353353                                                                                                        </p>
    354354                                                                                                        <p className="text-sm text-gray-400 mb-3 overflow-hidden text-ellipsis whitespace-nowrap">
  • frontend/src/utils/types.ts

    rb071fb4 r591919d  
    2828export interface Song extends MusicalEntity {
    2929        type: "SONG";
     30        album?: string;
    3031}
    3132
Note: See TracChangeset for help on using the changeset viewer.