Exemple #1
0
 /**
  * 歌曲是否存在在歌单中
  *
  * @param musicid
  * @param musiclistId
  * @return
  * @throws Exception
  */
 public boolean isExitInMusiclist(String musicid, String musiclistId) throws Exception {
   String hql = "from MusicListAndMusic mliandm where mliandm.musicId=? and mliandm.musiclistId=?";
   List<MusicListAndMusic> musicListAndMusics =
       musicListAndMusicDao.find(hql, musicid, musiclistId);
   if (musicListAndMusics != null && musicListAndMusics.size() > 0) {
     return true;
   }
   return false;
 }
Exemple #2
0
 /**
  * 添加歌曲到歌单
  *
  * @param musicid 歌曲id
  * @param musiclistId 歌单id
  * @return 是否成功,如果已经被收藏到此歌单则不进行添加,返回一个false
  */
 public boolean addMusicToMusiclist(String musicid, String musiclistId) throws Exception {
   if (isExitInMusiclist(musicid, musiclistId)) {
     return false;
   }
   // 添加到歌单中
   MusicListAndMusic musicListAndMusic = new MusicListAndMusic();
   musicListAndMusic.setMusicId(musicid);
   musicListAndMusic.setMusiclistId(musiclistId);
   musicListAndMusicDao.save(musicListAndMusic);
   return true;
 }
Exemple #3
0
  /**
   * 收藏歌单到默认的我喜欢歌单中
   *
   * @param musicid 歌曲id
   * @param userid 用户Id
   * @return 是否已经存在
   * @throws Exception
   */
  public boolean addMusicToLove(String musicid, String userid) throws Exception {

    // 先找到用户的默认歌单
    String hql = "from Musiclist ml where ml.listName=? and ml.userId=?";
    Musiclist musiclist = musiclistDao.findUnique(hql, SysCode.MUSIC_LIST.DEFAULT_LOVE, userid);

    if (musiclist == null) return false;

    // 判断歌曲是否存在此歌单中
    if (isExitInMusiclist(musicid, musiclist.getId())) {
      // 已经存在
      return false;
    }

    // 添加到我喜欢中
    MusicListAndMusic musicListAndMusic = new MusicListAndMusic();
    musicListAndMusic.setMusicId(musicid);
    musicListAndMusic.setMusiclistId(musiclist.getId());
    musicListAndMusicDao.save(musicListAndMusic);

    return true;
  }
Exemple #4
0
 /**
  * 从歌单中移除歌曲
  *
  * @param musicid 歌曲id
  * @param musiclistId 歌单id
  * @throws Exception
  */
 public void removeMusicFromMusiclist(String musicid, String musiclistId) throws Exception {
   String hql =
       "delete from MusicListAndMusic mliandm where mliandm.musicId=? and  mliandm.musiclistId=?";
   musicListAndMusicDao.batchExecute(hql, musicid, musiclistId);
 }