192 lines
6.1 KiB
PHP
192 lines
6.1 KiB
PHP
|
|
<?php
|
|||
|
|
|
|||
|
|
namespace app\api\controller;
|
|||
|
|
|
|||
|
|
use think\Controller;
|
|||
|
|
|
|||
|
|
|
|||
|
|
class Agora extends Common
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
protected function initialize()
|
|||
|
|
{
|
|||
|
|
$validate_action_list = ['get_code',"get_sstoken",'update_sstoken','get_user_info','report_game_info'];
|
|||
|
|
$action = request()->action();
|
|||
|
|
if(!in_array($action, $validate_action_list)) {
|
|||
|
|
parent::initialize();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//---------------------游戏相关服务-------------------------------------------
|
|||
|
|
/**
|
|||
|
|
* 登录接口,获取针对当前用户(UID)的短期令牌Code
|
|||
|
|
* 调用方:APP端
|
|||
|
|
*/
|
|||
|
|
public function get_code(){
|
|||
|
|
$uid = input('uid', 0);
|
|||
|
|
$reslut = model('AgoraAuth')->get_code($uid);
|
|||
|
|
return ajaxReturn($reslut['code'], $reslut['msg'], $reslut['data']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 短期令牌Code更换长期令牌SSToken
|
|||
|
|
* 调用方:游戏服务
|
|||
|
|
*
|
|||
|
|
*/
|
|||
|
|
public function get_sstoken(){
|
|||
|
|
// $code = input('code', '');
|
|||
|
|
$data = input('post.');
|
|||
|
|
$reslut = model('AgoraAuth')->get_sstoken($data);
|
|||
|
|
// return ajaxReturn($reslut['code'], $reslut['msg'], $reslut['data']);
|
|||
|
|
return json($reslut);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 刷新长期令牌
|
|||
|
|
* 调用方:游戏服务
|
|||
|
|
*
|
|||
|
|
*/
|
|||
|
|
public function update_sstoken(){
|
|||
|
|
// $token = input('ss_token', '');
|
|||
|
|
$data = input('post.');
|
|||
|
|
$reslut = model('AgoraAuth')->update_sstoken($data);
|
|||
|
|
// return ajaxReturn($reslut['code'], $reslut['msg'], $reslut['data']);
|
|||
|
|
return json($reslut);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 获取用户信息
|
|||
|
|
* 调用方:游戏服务
|
|||
|
|
*
|
|||
|
|
*/
|
|||
|
|
public function get_user_info(){
|
|||
|
|
// $token = input('ss_token', '');
|
|||
|
|
$data = input('post.');
|
|||
|
|
$reslut = model('AgoraAuth')->get_user_info($data);
|
|||
|
|
// return ajaxReturn($reslut['code'], $reslut['msg'], $reslut['data']);
|
|||
|
|
return json($reslut);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 游戏服务端上报游戏接入方的游戏的数据
|
|||
|
|
* 调用方:游戏服务
|
|||
|
|
*
|
|||
|
|
*/
|
|||
|
|
public function report_game_info(){
|
|||
|
|
// $report_type = input('report_type', '');
|
|||
|
|
// $report_msg = input('report_msg', '');
|
|||
|
|
// $uid = input('uid', 0);
|
|||
|
|
// $ss_token = input('ss_token', '');
|
|||
|
|
// $reslut = model('AgoraAuth')->report_game_info($report_type, $report_msg, $uid, $ss_token);
|
|||
|
|
$data = input('post.');
|
|||
|
|
$reslut = model('AgoraAuth')->report_game_info($data);
|
|||
|
|
// return ajaxReturn($reslut['code'], $reslut['msg'], $reslut['data']);
|
|||
|
|
return json($reslut);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//获取歌曲列表
|
|||
|
|
public function agora_song_list(){
|
|||
|
|
// dump(111);exit;
|
|||
|
|
$page = input('page',0);
|
|||
|
|
$song_code = input('song_code',0);
|
|||
|
|
$page_limit = input('page_limit',20);
|
|||
|
|
$key_name = "api:agora:agora_song_list:".$song_code;
|
|||
|
|
redis_lock_exit($key_name);
|
|||
|
|
$reslut = model('Agora')->agora_song_list($page,$page_limit,$song_code);
|
|||
|
|
redis_unlock($key_name);
|
|||
|
|
return ajaxReturn($reslut['code'], $reslut['msg'], $reslut['data']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//获取增量歌曲列表
|
|||
|
|
public function agora_new_song_list(){
|
|||
|
|
$page = input('page', 0);
|
|||
|
|
$page_limit = input('page_limit',20);
|
|||
|
|
$add_time = input('add_time', 0);
|
|||
|
|
$reslut = model('Agora')->agora_new_song_list($page, $page_limit, $add_time);
|
|||
|
|
return ajaxReturn($reslut['code'], $reslut['msg'], $reslut['data']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//获取指定歌曲详情
|
|||
|
|
public function agora_song_info(){
|
|||
|
|
$song_code = input('song_code',0);
|
|||
|
|
$lyric_type = input('lyric_type',0);
|
|||
|
|
$key_name = "api:agora:agora_song_info:".$song_code;
|
|||
|
|
redis_lock_exit($key_name);
|
|||
|
|
$reslut = model('Agora')->agora_song_info($song_code, $lyric_type);
|
|||
|
|
redis_unlock($key_name);
|
|||
|
|
return ajaxReturn($reslut['code'], $reslut['msg'], $reslut['data']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**********************************************分 割 线***********************************************************/
|
|||
|
|
|
|||
|
|
//同步热门歌曲
|
|||
|
|
public function synchro_hot_song(){
|
|||
|
|
$hot_type = input('hot_type', 1);
|
|||
|
|
$key_name = "api:agora:synchro_hot_song";
|
|||
|
|
redis_lock_exit($key_name);
|
|||
|
|
$reslut = model('Agora')->synchro_hot_song($hot_type);
|
|||
|
|
redis_unlock($key_name);
|
|||
|
|
return ajaxReturn($reslut['code'], $reslut['msg'], $reslut['data']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//获取热门歌曲列表
|
|||
|
|
public function hot_song_list(){
|
|||
|
|
$page = input('page', 1);
|
|||
|
|
$page_limit = input('page_limit', 20);
|
|||
|
|
$reslut = model('Agora')->hot_song_list($page, $page_limit);
|
|||
|
|
return ajaxReturn($reslut['code'], $reslut['msg'], $reslut['data']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//获得歌曲列表
|
|||
|
|
public function song_list(){
|
|||
|
|
$name = input('name','');
|
|||
|
|
$page = input('page', 1);
|
|||
|
|
$page_limit = input('page_limit', 20);
|
|||
|
|
$reslut = model('Agora')->song_list($name, $page, $page_limit);
|
|||
|
|
return ajaxReturn($reslut['code'], $reslut['msg'], $reslut['data']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//点歌
|
|||
|
|
public function dot_song(){
|
|||
|
|
$rid = input('rid', 0);
|
|||
|
|
$song_code = input('song_code', '');
|
|||
|
|
$is_accapella = input('is_accapella', 2);
|
|||
|
|
$key_name = "api:agora:dot_song:".$this->uid;
|
|||
|
|
redis_lock_exit($key_name);
|
|||
|
|
$reslut = model('Agora')->dot_song($this->uid, $rid, $song_code,$is_accapella);
|
|||
|
|
redis_unlock($key_name);
|
|||
|
|
return ajaxReturn($reslut['code'], $reslut['msg'], $reslut['data']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//取消点歌
|
|||
|
|
public function dot_song_del(){
|
|||
|
|
$rid = input('rid', 0);
|
|||
|
|
$song_code = input('song_code', '');
|
|||
|
|
$key_name = "api:agora:dot_song_del:".$this->uid;
|
|||
|
|
redis_lock_exit($key_name);
|
|||
|
|
$reslut = model('Agora')->dot_song_del($this->uid, $rid, $song_code);
|
|||
|
|
redis_unlock($key_name);
|
|||
|
|
return ajaxReturn($reslut['code'], $reslut['msg'], $reslut['data']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//点歌列表
|
|||
|
|
public function dot_song_list(){
|
|||
|
|
$rid = input('rid', 0);
|
|||
|
|
$reslut = model('Agora')->dot_song_list($rid);
|
|||
|
|
return ajaxReturn($reslut['code'], $reslut['msg'], $reslut['data']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|