Пример #1
0
def one(request):
    pl_id = request.GET.get("id")
    # 信息进行记录
    wirteBrowse(user_name=request.GET.get("username"),click_id=pl_id,click_cate="2", user_click_time=getLocalTime(), desc="查看歌单")
    one = PlayList.objects.filter(pl_id=pl_id)[0]
    return JsonResponse({
        "code":1,
        "data":[
            {
                "pl_id":one.pl_id,
                "pl_creator": one.pl_creator.u_name,
                "pl_name":one.pl_name,
                "pl_create_time":one.pl_create_time,
                "pl_update_time":one.pl_update_time,
                "pl_songs_num": one.pl_songs_num,
                "pl_listen_num":one.pl_listen_num,
                "pl_share_num":one.pl_share_num,
                "pl_comment_num":one.pl_comment_num,
                "pl_follow_num":one.pl_follow_num,
                "pl_tags": one.pl_tags,
                "pl_img_url":one.pl_img_url,
                "pl_desc":one.pl_desc,
                "pl_rec": getRecBasedOne(pl_id),
                "pl_songs": getIncludeSong(pl_id)
            }
        ]
    })
Пример #2
0
def one(request):
    song_id = request.GET.get("id")
    song = Song.objects.filter(song_id=song_id)[0]
    s_name = list()
    if song.song_sing_id.__contains__("#"):
        for s_one in song.song_sing_id.split("#"):
            s_name.append(Sing.objects.filter(sing_id=s_one)[0].sing_name)
    else:
        s_name.append(
            Sing.objects.filter(sing_id=song.song_sing_id)[0].sing_name)
    song_lysic = SongLysic.objects.filter(song_id=song_id)[0]
    wirteBrowse(user_name=request.GET.get("username"),
                click_id=song_id,
                click_cate="3",
                user_click_time=getLocalTime(),
                desc="查看歌曲")
    return JsonResponse({
        "code":
        1,
        "data": [{
            "song_id": song.song_id,
            "song_name": song.song_name,
            "song_playlist": song.song_pl_id,
            "song_publish_time": song.song_publish_time,
            "song_sing": " / ".join(s_name),
            "song_total_comments": song.song_total_comments,
            "song_hot_comments": song.song_hot_comments,
            "song_url": song.song_url,
            "song_lysic": song_lysic.song_lysic,
            "song_rec": getRecBasedOne(song_id)
        }]
    })
Пример #3
0
def login(request):
    if request.method == "GET":
        # 返回选择的用户、歌手、歌曲
        users = User.objects.order_by("?").values("u_id","u_name")[:30]
        songs = Song.objects.order_by("?").values("song_id","song_name")[:30]
        sings = Sing.objects.order_by("?").values("sing_id","sing_name")[:20]
        return JsonResponse({
            "code":1,
            "data":{
                "users": { one["u_id"]: one["u_name"] for one in users },
                "songs": { one["song_id"]: one["song_name"] for one in songs },
                "sings": { one["sing_id"]: one["sing_name"] for one in sings }
            }
        })
    else:
        # 将用户信息写入session
        request.session["username"] = request.POST.get("username")
        request.session["sings"] = request.POST.get("sings")
        request.session["songs"] = request.POST.get("songs")
        # 信息进行记录
        wirteBrowse(user_name=request.POST.get("username"),user_click_time=getLocalTime(),desc="登录系统")
        return JsonResponse({
            "code":1,
            "data":{
                "username":request.POST.get("username"),
                "songs": request.POST.get("songs"),
                "sings": request.POST.get("sings")
            }
        })
Пример #4
0
def one(request):
    song_id = request.GET.get("id")
    song = Song.objects.filter(song_id=song_id)[0]
    song_lysic = SongLysic.objects.filter(song_id=song_id)[0]
    wirteBrowse(user_name=request.GET.get("username"),
                click_id=song_id,
                click_cate="3",
                user_click_time=getLocalTime(),
                desc="查看歌曲")
    return JsonResponse({
        "code":
        1,
        "data": [{
            "song_id":
            song.song_id,
            "song_name":
            song.song_name,
            "song_playlist":
            song.song_pl_id,
            "song_publish_time":
            song.song_publish_time,
            "song_sing":
            Sing.objects.filter(sing_id=song.song_sing_id)[0].sing_name,
            "song_total_comments":
            song.song_total_comments,
            "song_hot_comments":
            song.song_hot_comments,
            "song_url":
            song.song_url,
            "song_lysic":
            song_lysic.song_lysic,
            "song_rec":
            getRecBasedOne(song_id)
        }]
    })
Пример #5
0
def one(request):
    sing_id = request.GET.get("id")
    wirteBrowse(user_name=request.GET.get("username"),
                click_id=sing_id,
                click_cate="4",
                user_click_time=getLocalTime(),
                desc="查看歌手")
    if "12797496" in sing_id:
        one = Sing.objects.filter(sing_id__endswith="12797496")[0]
    else:
        one = Sing.objects.filter(sing_id=sing_id)[0]
    return JsonResponse({
        "code":
        1,
        "data": [{
            "sing_id": one.sing_id,
            "sing_name": one.sing_name,
            "sing_music_num": one.sing_music_num,
            "sing_mv_num": one.sing_mv_num,
            "sing_album_num": one.sing_album_num,
            "sing_url": one.sing_url,
            "sing_rec": getRecBasedOne(sing_id),
            "sing_songs": getSingerSong(sing_id)
        }]
    })
Пример #6
0
def login(request):
    if request.method == "GET":
        # 返回选择的用户、歌手、歌曲
        users = random.sample(
            list(User.objects.all().values("u_id", "u_name")), 50)
        songs = random.sample(
            list(Song.objects.all().values("song_id", "song_name")), 30)
        sings = random.sample(
            list(Sing.objects.all().values("sing_id", "sing_name")), 30)
        return JsonResponse({
            "code": 1,
            "data": {
                "users": {one["u_id"]: one["u_name"]
                          for one in users},
                "songs": {one["song_id"]: one["song_name"]
                          for one in songs},
                "sings": {one["sing_id"]: one["sing_name"]
                          for one in sings}
            }
        })
    else:
        # 将用户信息写入session
        request.session["username"] = request.POST.get("username")
        request.session["sings"] = request.POST.get("sings")
        request.session["songs"] = request.POST.get("songs")
        # 信息进行记录
        wirteBrowse(user_name=request.POST.get("username"),
                    user_click_time=getLocalTime(),
                    desc="登录系统")
        return JsonResponse({
            "code": 1,
            "data": {
                "username": request.POST.get("username"),
                "songs": request.POST.get("songs"),
                "sings": request.POST.get("sings")
            }
        })