@RequestMapping(method = RequestMethod.GET, value = "/artist/{artistName}/songs")
  public String viewArtistSongs(
      @PathVariable("artistName") String artistName, Model map, HttpSession session) {
    artistName = UtilImpl.rewriteParams(artistName);
    Integer artistId;
    Integer songNumberOfArtist;
    Integer songPageNumberOfArtist;
    Artist artist = serviceFactory.getArtistService().getArtistByName(artistName);
    artistId = artist.getArtistid();
    songNumberOfArtist = serviceFactory.getSongService().getSongNumberOfArtist(artistId);
    // List songs = serviceFactory.getListenHistoryService().getMostListenedSongsByArtist(artist, 0,
    // 10);
    // List<SongStats> songs = serviceFactory.getSongService().getTopSongsByArtist(artist, 0, 10);

    List<SongStats> songs = serviceFactory.getSongService().getSongsOfArtistByPage(artist, 1);

    songPageNumberOfArtist = (songNumberOfArtist / 10) + 1;
    map.addAttribute("songs", songs);
    map.addAttribute("artistId", artistId);
    map.addAttribute("songPageNumberOfArtist", songPageNumberOfArtist);
    return "artist/artist_popular_songs";
  }
  @RequestMapping(
      method = RequestMethod.GET,
      value = "/artistList/songs/{currentPage}/artistNO/{artistID}")
  public String viewArtistSongList(
      @PathVariable Integer currentPage,
      @PathVariable Integer artistID,
      Model map,
      HttpSession session) {
    Artist artist = new Artist(artistID);

    List<SongStats> songs =
        serviceFactory.getSongService().getSongsOfArtistByPage(artist, currentPage);
    map.addAttribute("songs", songs);
    return "artist/list/artistSongList";
  }
  @RequestMapping(method = RequestMethod.GET, value = "/artist/{artistName}/general")
  public String viewArtistGeneral(
      @PathVariable("artistName") String artistName, Model map, HttpSession session) {
    artistName = UtilImpl.rewriteParams(artistName);
    Artist artist = serviceFactory.getArtistService().getArtistByName(artistName);
    List<UserActivity> activities =
        serviceFactory.getUserService().getArtistActivity(artist, 0, 10);
    List<Album> albums = serviceFactory.getAlbumService().getAlbumsByArtist(artist, 0, 4);
    List<ArtistFans> artistFans = serviceFactory.getArtistService().getArtistFans(artist, 0, 5);
    // List songs = serviceFactory.getListenHistoryService().getMostListenedSongsByArtist(artist, 0,
    // 10);
    List<SongStats> songs = serviceFactory.getSongService().getTopSongsByArtist(artist, 0, 10);
    List<ArtistSimiliar> similiars =
        serviceFactory.getArtistService().getSimiliarArtists(artist, 0, 5);

    serviceFactory.getArtistService().saveArtistBioAndPicture(artist);
    for (ArtistSimiliar similiar : similiars) {
      serviceFactory.getArtistService().saveArtistBioAndPicture(similiar.getSimiliarArtistid());
    }

    // List<ArtistSimiliar> similiars = new ArrayList<ArtistSimiliar>();
    ArtistStats stats = artist.getArtistStats();
    map.addAttribute("artist", artist);
    map.addAttribute("activities", activities);
    map.addAttribute("albums", albums);
    String biography = artist.getBiography();
    if (biography != null && artist.getBiography().length() > 800) {
      biography = biography.substring(0, 800);
    }
    String moreInfo = artist.getMoreInfo();
    if (moreInfo != null && moreInfo.length() > 400) {
      moreInfo = moreInfo.substring(0, 400);
    }
    map.addAttribute("moreInfo", moreInfo);
    map.addAttribute("biography", biography);
    map.addAttribute("artistFans", artistFans);
    map.addAttribute("songs", songs);
    map.addAttribute("similiars", similiars);
    return "artist/artist_general";
  }