91 lines
2.8 KiB
JavaScript
91 lines
2.8 KiB
JavaScript
/**
|
|
*
|
|
* @authors Tony.Deng (dengtongyu123@163.com)
|
|
* @date 2017-11-07 17:54:22
|
|
* @version $Id$
|
|
*/
|
|
const forwarding = require('./forwarding');
|
|
const url = require('url');
|
|
|
|
module.exports = function(app) {
|
|
|
|
app.get('/data/songSearch', function(req, res) {
|
|
let param = url.parse(req.url).query;
|
|
let json = {};
|
|
if(param) {
|
|
forwarding.getSearchSongList(param,req,function(data){
|
|
//console.log('------接口数据------',data);
|
|
if(data.status == 1) {
|
|
json.desc = '';
|
|
json.result = true;
|
|
json.data = data.data;
|
|
res.send(json);
|
|
}else{
|
|
json.desc = '请求出错,错误代码:'+data.err_code;
|
|
json.result = false;
|
|
json.data = null;
|
|
res.send(json);
|
|
}
|
|
});
|
|
}else{
|
|
json.desc = '缺少参数';
|
|
json.result = false;
|
|
json.data = null;
|
|
res.send(json);
|
|
}
|
|
});
|
|
|
|
app.get('/data/newSong', function(req, res) {
|
|
let param = url.parse(req.url).query;
|
|
let json = {};
|
|
if(param) {
|
|
forwarding.getNewSongList(param,req,function(data){
|
|
//console.log('------接口数据------',data.data);
|
|
if(data.data && data.data.length && data.data.length > 0) {
|
|
json.desc = '';
|
|
json.result = true;
|
|
json.data = data.data;
|
|
res.send(json);
|
|
}else{
|
|
json.desc = '请求出错,错误代码:'+data.err_code;
|
|
json.result = false;
|
|
json.data = null;
|
|
res.send(json);
|
|
}
|
|
});
|
|
}else{
|
|
json.desc = '缺少参数';
|
|
json.result = false;
|
|
json.data = null;
|
|
res.send(json);
|
|
}
|
|
});
|
|
|
|
app.get('/data/songMsg', function(req, res) {
|
|
let hash = req.query.hash;
|
|
let json = {};
|
|
if(hash) {
|
|
forwarding.getSongMsg(hash,req,function(data){
|
|
//console.log('------接口数据------',data);
|
|
if(data.status == 1) {
|
|
json.desc = '';
|
|
json.result = true;
|
|
json.data = data.data;
|
|
res.send(json);
|
|
}else{
|
|
json.desc = '请求出错,错误代码:'+data.err_code;
|
|
json.result = false;
|
|
json.data = null;
|
|
res.send(json);
|
|
}
|
|
});
|
|
}else{
|
|
json.desc = '缺少参数';
|
|
json.result = false;
|
|
json.data = null;
|
|
res.send(json);
|
|
}
|
|
});
|
|
|
|
}
|