Changeset 15782a6


Ignore:
Timestamp:
02/05/26 17:56:50 (5 months ago)
Author:
Filip Gavrilovski <filipgavrilovski28@…>
Branches:
main
Children:
694fc25
Parents:
929e93c
Message:

add cover to musical entity and endpoint for fetching all songs

Location:
finkwave/src/main/java/com/ukim/finki/develop/finkwave
Files:
2 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • finkwave/src/main/java/com/ukim/finki/develop/finkwave/model/MusicalEntity.java

    r929e93c r15782a6  
    3737    private LocalDate releaseDate;
    3838
     39    private String cover;
     40
    3941    @ManyToOne(fetch = FetchType.LAZY)
    4042    @OnDelete(action = OnDeleteAction.CASCADE)
  • finkwave/src/main/java/com/ukim/finki/develop/finkwave/model/dto/MusicalEntityDto.java

    r929e93c r15782a6  
    11package com.ukim.finki.develop.finkwave.model.dto;
    22
     3import jakarta.annotation.Nullable;
    34import lombok.AllArgsConstructor;
    45import lombok.Getter;
     
    1415    private String type;
    1516    private String releasedBy;
     17    private String cover;
    1618    private Boolean isLikedByCurrentUser;
     19
     20    public MusicalEntityDto(Long id, String title, String genre, String type, String releasedBy, Boolean isLikedByCurrentUser) {
     21        this.id = id;
     22        this.title = title;
     23        this.genre = genre;
     24        this.type = type;
     25        this.releasedBy = releasedBy;
     26        this.isLikedByCurrentUser = isLikedByCurrentUser;
     27    }
    1728}
  • finkwave/src/main/java/com/ukim/finki/develop/finkwave/repository/SongRepository.java

    r929e93c r15782a6  
    2121            "'SONG', " +
    2222            "u.fullName, " +
     23            "me.cover," +
    2324            "(CASE WHEN :currentUserId IS NOT NULL AND l.id IS NOT NULL THEN true ELSE false END)) " +
    2425            "FROM Song s " +
     
    3940            "'SONG', " +
    4041            "u.fullName, " +
     42            "me.cover," +
    4143            "(CASE WHEN :currentUserId IS NOT NULL AND l.id IS NOT NULL THEN true ELSE false END)) " +
    4244            "FROM Song s "+
     
    4951            "WHERE ps.playlist.id=:playlistId")
    5052    List<MusicalEntityDto>findSongsByPlaylistId(@Param("playlistId")Long playlistId, @Param("currentUserId")Long currentUserId);
     53
     54    @Query("SELECT NEW com.ukim.finki.develop.finkwave.model.dto.MusicalEntityDto(" +
     55            "s.id, " +
     56            "me.title, " +
     57            "me.genre, " +
     58            "'SONG', " +
     59            "u.fullName, " +
     60            "me.cover," +
     61            "FALSE ) " +
     62//            "(CASE WHEN :currentUserId IS NOT NULL AND l.id IS NOT NULL THEN true ELSE false END)) " +
     63//            "COUNT(*) " +
     64            "FROM Song s "+
     65            "JOIN s.musicalEntities me " +
     66            "JOIN me.releasedBy a " +
     67            "JOIN a.nonAdminUser nau "+
     68            "JOIN nau.user u " +
     69            "JOIN Listen l on l.song.id = s.id " +
     70            "GROUP BY s.id, me.title, me.genre, u.fullName, me.cover " +
     71            "ORDER BY count(*) desc "
     72    )
     73    // todo: handle likes, momentalno site se false za da raboti joinot
     74    // todo: add paging
     75    List<MusicalEntityDto> findTopByListens(@Param("currentUserId")Long currentUserId);
    5176}
Note: See TracChangeset for help on using the changeset viewer.