'use strict'; const Controller = require('egg').Controller; const respFormat = require('../util/respFormat'); class KuGouController extends Controller { async songSearch() { const { ctx } = this; try { const res = await ctx.service.kugou.getSearchSongList(ctx.query); if (res.status === 1) { ctx.body = respFormat({ data: res.data }); } else { ctx.body = respFormat({ desc: '请求出错,请稍后再试!', errcode: res.err_code }); } } catch (err) { ctx.body = respFormat({ desc: '出现未知错误!', errcode: 1000 }); } } async newSong() { const { ctx } = this; try { const res = await ctx.service.kugou.getNewSongList(ctx.query); if (res.data && res.data.length && res.data.length > 0) { ctx.body = respFormat({ data: res.data }); } else { ctx.body = respFormat({ desc: '请求出错,请稍后再试!', errcode: res.err_code }); } } catch (err) { ctx.body = respFormat({ desc: '出现未知错误!', errcode: 1000 }); } } async songMsg() { const { ctx } = this; try { const res = await ctx.service.kugou.getSongMsg(ctx.query); if (res.status == 1) { ctx.body = respFormat({ data: res.data }); } else { ctx.body = respFormat({ desc: '请求出错,请稍后再试!', errcode: res.err_code }); } } catch (err) { ctx.body = respFormat({ desc: '出现未知错误!', errcode: 1000 }); } } } module.exports = KuGouController;