31 lines
940 B
PHP
31 lines
940 B
PHP
<?php
|
||
|
||
namespace app\admin\controller;
|
||
|
||
use app\BaseController;
|
||
use app\admin\service\UtillService;
|
||
use think\facade\Session;
|
||
|
||
class Utill extends BaseController
|
||
{
|
||
/* 获取需要导出的数据
|
||
$range范围:week,month
|
||
*/
|
||
public function getExportData(UtillService $UtillService)
|
||
{
|
||
$range = $this->request->post('range');
|
||
|
||
try {
|
||
# session中获取当前登录是否是管理员
|
||
$isAdmin = Session::get('user_info.role') === 'admin' ? true : false; // 后续用来判断
|
||
if (!$isAdmin) {
|
||
return json(['code' => 403, 'msg' => '权限不足', 'data' => []]);
|
||
}
|
||
$data = $UtillService->getExportData($range);
|
||
return json(['code' => 200, 'msg' => '查询成功', 'data' => $data]);
|
||
} catch (\Exception $e) {
|
||
return json(['code' => 500, 'msg' => '查询失败', 'data' => []]);
|
||
}
|
||
}
|
||
}
|