|
|
<?php |
|
|
|
|
|
namespace app\api\controller; |
|
|
|
|
|
use think\Controller; |
|
|
use think\Cache; |
|
|
use think\Db; |
|
|
use think\Request; |
|
|
use think\Validate; |
|
|
|
|
|
class Vod extends Base |
|
|
{ |
|
|
use PublicApi; |
|
|
public function __construct() |
|
|
{ |
|
|
parent::__construct(); |
|
|
$this->check_config(); |
|
|
|
|
|
} |
|
|
|
|
|
public function index() |
|
|
{ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function get_list(Request $request) |
|
|
{ |
|
|
|
|
|
$param = $request->param(); |
|
|
$validate = validate($request->controller()); |
|
|
if (!$validate->scene($request->action())->check($param)) { |
|
|
return json([ |
|
|
'code' => 1001, |
|
|
'msg' => '参数错误: ' . $validate->getError(), |
|
|
]); |
|
|
} |
|
|
$offset = isset($param['offset']) ? (int)$param['offset'] : 0; |
|
|
$limit = isset($param['limit']) ? (int)$param['limit'] : 20; |
|
|
|
|
|
$where = []; |
|
|
if (isset($param['type_id'])) { |
|
|
$where['type_id'] = (int)$param['type_id']; |
|
|
} |
|
|
if (isset($param['id'])) { |
|
|
$where['vod_id'] = (int)$param['id']; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($param['vod_letter'])) { |
|
|
$where['vod_letter'] = $param['vod_letter']; |
|
|
} |
|
|
if (isset($param['vod_tag']) && strlen($param['vod_tag']) > 0) { |
|
|
$where['vod_tag'] = ['like', '%' . format_sql_string($param['vod_tag']) . '%']; |
|
|
} |
|
|
if (isset($param['vod_name']) && strlen($param['vod_name']) > 0) { |
|
|
$where['vod_name'] = ['like', '%' . format_sql_string($param['vod_name']) . '%']; |
|
|
} |
|
|
if (isset($param['vod_blurb']) && strlen($param['vod_blurb']) > 0) { |
|
|
$where['vod_blurb'] = ['like', '%' . format_sql_string($param['vod_blurb']) . '%']; |
|
|
} |
|
|
if (isset($param['vod_class']) && strlen($param['vod_class']) > 0) { |
|
|
$where['vod_class'] = ['like', '%' . format_sql_string($param['vod_class']) . '%']; |
|
|
} |
|
|
if (isset($param['vod_area']) && strlen($param['vod_area']) > 0) { |
|
|
$where['vod_area'] = format_sql_string($param['vod_area']); |
|
|
} |
|
|
if (isset($param['vod_year']) && strlen($param['vod_year']) > 0) { |
|
|
$where['vod_year'] = format_sql_string($param['vod_year']); |
|
|
} |
|
|
|
|
|
$total = model('Vod')->getCountByCond($where); |
|
|
$list = []; |
|
|
if ($total > 0) { |
|
|
|
|
|
$order = "vod_time DESC"; |
|
|
if (strlen($param['orderby']) > 0) { |
|
|
$order = 'vod_' . $param['orderby'] . " DESC"; |
|
|
} |
|
|
$field = 'vod_id,vod_name,vod_actor,vod_hits,vod_hits_day,vod_hits_week,vod_hits_month,vod_time,vod_remarks,vod_score,vod_area,vod_year'; |
|
|
|
|
|
$list = model('Vod')->getListByCond($offset, $limit, $where, $order, $field); |
|
|
} |
|
|
|
|
|
return json([ |
|
|
'code' => 1, |
|
|
'msg' => '获取成功', |
|
|
'info' => [ |
|
|
'offset' => $offset, |
|
|
'limit' => $limit, |
|
|
'total' => $total, |
|
|
'rows' => $list, |
|
|
], |
|
|
]); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function get_detail(Request $request) |
|
|
{ |
|
|
$param = $request->param(); |
|
|
$validate = validate($request->controller()); |
|
|
if (!$validate->scene($request->action())->check($param)) { |
|
|
return json([ |
|
|
'code' => 1001, |
|
|
'msg' => '参数错误: ' . $validate->getError(), |
|
|
]); |
|
|
} |
|
|
|
|
|
$res = Db::table('mac_vod')->where(['vod_id' => $param['vod_id']])->select(); |
|
|
|
|
|
|
|
|
return json([ |
|
|
'code' => 1, |
|
|
'msg' => '获取成功', |
|
|
'info' => $res |
|
|
]); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function get_year(Request $request) |
|
|
{ |
|
|
$param = $request->param(); |
|
|
$validate = validate($request->controller()); |
|
|
if (!$validate->scene($request->action())->check($param)) { |
|
|
return json([ |
|
|
'code' => 1001, |
|
|
'msg' => '参数错误: ' . $validate->getError(), |
|
|
]); |
|
|
} |
|
|
|
|
|
$result = Db::table('mac_vod')->distinct(true)->field('vod_year')->where(['type_id_1' => $param['type_id_1']])->select(); |
|
|
$return = []; |
|
|
foreach ($result as $index => $item) { |
|
|
if (!empty($item['vod_year'])){ |
|
|
array_push($return,$item['vod_year']); |
|
|
} |
|
|
} |
|
|
|
|
|
return json([ |
|
|
'code' => 1, |
|
|
'msg' => '获取成功', |
|
|
'info' => [ |
|
|
'total' => count($return), |
|
|
'rows' => $return, |
|
|
], |
|
|
]); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function get_class(Request $request) |
|
|
{ |
|
|
$param = $request->param(); |
|
|
$validate = validate($request->controller()); |
|
|
if (!$validate->scene($request->action())->check($param)) { |
|
|
return json([ |
|
|
'code' => 1001, |
|
|
'msg' => '参数错误: ' . $validate->getError(), |
|
|
]); |
|
|
} |
|
|
|
|
|
$result = Db::table('mac_vod')->distinct(true)->field('vod_class')->where(['type_id_1' => $param['type_id_1']])->select(); |
|
|
$return = []; |
|
|
foreach ($result as $index => $item) { |
|
|
if (!empty($item['vod_class'])){ |
|
|
array_push($return,$item['vod_class']); |
|
|
} |
|
|
} |
|
|
|
|
|
return json([ |
|
|
'code' => 1, |
|
|
'msg' => '获取成功', |
|
|
'info' => [ |
|
|
'total' => count($return), |
|
|
'rows' => $return, |
|
|
], |
|
|
]); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function get_area(Request $request) |
|
|
{ |
|
|
$param = $request->param(); |
|
|
$validate = validate($request->controller()); |
|
|
if (!$validate->scene($request->action())->check($param)) { |
|
|
return json([ |
|
|
'code' => 1001, |
|
|
'msg' => '参数错误: ' . $validate->getError(), |
|
|
]); |
|
|
} |
|
|
|
|
|
$result = Db::table('mac_vod')->distinct(true)->field('vod_area')->where(['type_id_1' => $param['type_id_1']])->select(); |
|
|
$return = []; |
|
|
foreach ($result as $index => $item) { |
|
|
if (!empty($item['vod_area'])){ |
|
|
array_push($return,$item['vod_area']); |
|
|
} |
|
|
} |
|
|
|
|
|
return json([ |
|
|
'code' => 1, |
|
|
'msg' => '获取成功', |
|
|
'info' => [ |
|
|
'total' => count($return), |
|
|
'rows' => $return, |
|
|
], |
|
|
]); |
|
|
} |
|
|
} |