1
0
Code Issues Pull Requests Projects Releases Wiki Activity GitHub Gitee

netease_music 的一些改动

This commit is contained in:
2023-06-02 18:03:41 +08:00
parent 59336c15b6
commit a29dc77417
4 changed files with 38 additions and 36 deletions

View File

@@ -74,6 +74,25 @@ module.exports = {
albumIds = albumIds.map(item => item.id);
return albumIds;
},
getInfoById: async (albumId, { getRelation = true }) => {
if (!albumId) return {}
// 查询出专辑
const sql = 'SELECT * FROM album WHERE album_id = ?'
let infoResultSet = await dbUtils.query(sql, [albumId]);
if (infoResultSet.length == 0) return {};
let albumInfo = JSON.parse(JSON.stringify(infoResultSet[0]));
if (getRelation) {
// 查出专辑与歌曲对应关系
const sql2 = 'SELECT * FROM song_album_relation WHERE album_id = ?'
let relationResultSet = await dbUtils.query(sql2, [albumId]);
// 拼装
albumInfo.songIds = relationResultSet.map(song => song.song_id);
} else {
albumInfo.songIds = null;
}
return albumInfo;
},
},
@@ -97,6 +116,25 @@ module.exports = {
artistIds = artistIds.map(item => item.id);
return artistIds;
},
getInfoById: async (artistId, { getRelation = true }) => {
if (!artistId) return {}
// 查询出歌手
const sql = 'SELECT * FROM artist WHERE artist_id = ?'
let infoResultSet = await dbUtils.query(sql, [artistId]);
if (infoResultSet.length == 0) return {};
let artistInfo = JSON.parse(JSON.stringify(infoResultSet[0]));
if (getRelation) {
// 查出歌手与歌曲对应关系
const sql2 = 'SELECT * FROM song_artist_relation WHERE artist_id = ?'
let relationResultSet = await dbUtils.query(sql2, [artistId]);
// 拼装
artistInfo.songIds = relationResultSet.map(song => song.song_id);
} else {
artistInfo.songIds = null;
}
return artistInfo;
},
},