2024-07-11 00:10:33 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
|
|
use app\BaseController;
|
|
|
|
use app\common\model\TimeZone;
|
|
|
|
use app\common\service\UploadService;
|
|
|
|
use app\constant\ResponseCode;
|
|
|
|
use app\utils\QiniuUtils;
|
2024-07-11 23:17:02 +08:00
|
|
|
use support\Redis;
|
2024-07-11 00:10:33 +08:00
|
|
|
use support\Request;
|
|
|
|
use Tinywan\Jwt\JwtToken;
|
|
|
|
|
|
|
|
class TestController extends BaseController
|
|
|
|
{
|
|
|
|
|
|
|
|
protected $noNeedLogin = ['*'];
|
|
|
|
|
|
|
|
public function test(Request $request)
|
|
|
|
{
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
2024-07-11 23:17:02 +08:00
|
|
|
phpinfo();
|
|
|
|
$res = Redis::setEx('test', 60, 10);
|
|
|
|
|
|
|
|
print '<pre>';
|
|
|
|
print_r($res);
|
|
|
|
die;
|
|
|
|
|
2024-07-11 00:10:33 +08:00
|
|
|
|
|
|
|
$time_zone = json_decode(file_get_contents(base_path('/timezones.json')), true);
|
|
|
|
|
|
|
|
foreach ($time_zone as $index => $item) {
|
|
|
|
$res = TimeZone::create([
|
|
|
|
'name' => $item['value'],
|
|
|
|
'abbr' => $item['abbr'],
|
|
|
|
'text' => $item['text'],
|
|
|
|
'offset' => $item['offset'],
|
|
|
|
'utc' => json_encode($item['utc'], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
|
|
|
]);
|
|
|
|
if ($res) {
|
|
|
|
var_dump($index . '-成功');
|
|
|
|
} else {
|
|
|
|
var_dump($index . '-失败');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print '<pre>';
|
|
|
|
print_r('success');
|
|
|
|
die;
|
|
|
|
$token_data = [
|
|
|
|
'id' => 7
|
|
|
|
];
|
|
|
|
$token = JwtToken::generateToken($token_data);
|
|
|
|
print '<pre>';
|
|
|
|
print_r($token);
|
|
|
|
die;
|
|
|
|
// throw new \Exception('显示是错误测试');
|
|
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
return $this->json([
|
|
|
|
'code' => ResponseCode::FAIL,
|
|
|
|
'msg' => $e->getMessage()
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// return $this->json([
|
|
|
|
// 'code' => ResponseCode::SUCCESS,
|
|
|
|
// 'data'=>[1,2,3],
|
|
|
|
// 'msg' => '变更成功',
|
|
|
|
// ]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function upload(Request $request)
|
|
|
|
{
|
|
|
|
$service = new UploadService();
|
|
|
|
|
|
|
|
$res = $service->uploadImg($request);
|
|
|
|
return $this->json($res);
|
|
|
|
}
|
|
|
|
}
|