Yin-Hongwei / music-website

🎧 Vue + SpringBoot + MyBatis 音乐网站
Apache License 2.0
5.59k stars 1.47k forks source link

搜索不出来,一搜索就显示下图 #285

Open SakuraFate opened 7 months ago

SakuraFate commented 7 months ago

~TNEEOU`MJ~J3N@M_V@)V1Y

nanshaws commented 7 months ago

截图_20240506112329 截图_20240506112352 可能是管理端没有添加到数据库

ALk330 commented 2 months ago

前端没判空导致的,SearchSong.vue中,result.data为null

if (!result.data.length) {
  currentSongList.value = [];
  (proxy as any).$message({
    message: "暂时没有相关歌曲",
    type: "warning",
  });
} else {
  currentSongList.value = result.data;
}

后端在没查到音乐时,返回的是return R.error("添加失败,没有找到该歌,无法加入该歌单");,导致data为null

public R songOfSingerName(String name) {
    QueryWrapper<Song> queryWrapper = new QueryWrapper<>();
    queryWrapper.like("name",name);
    List<Song> songs = songMapper.selectList(queryWrapper);
    if (songs.isEmpty()){
        return R.error("添加失败,没有找到该歌,无法加入该歌单");
    }

    return R.success(null, songMapper.selectList(queryWrapper));
}