登录
This commit is contained in:
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use app\common\model\Resource;
|
||||
use app\common\service\SysDictService;
|
||||
use app\common\service\UploadService;
|
||||
use app\common\utils\scaffold\Generate;
|
||||
use support\Request;
|
||||
use support\Db;
|
||||
use support\Cache;
|
||||
use support\Redis;
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
|
||||
protected $noNeedLogin = ['index', 'view', 'perm', 'createResource', 'pdf', 'test'];
|
||||
|
||||
protected $noNeedHeaderData = ['index', 'view', 'perm', 'createResource', 'pdf', 'test'];
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
return htmlpage();
|
||||
}
|
||||
|
||||
/**
|
||||
* 调试飞书
|
||||
*/
|
||||
public function view(Request $request)
|
||||
{
|
||||
return view('index/qrcode', ['name' => 'webman']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 临时增加用户权限
|
||||
*/
|
||||
public function perm(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $request->get();
|
||||
|
||||
if (Db::table('user_roles')->where('user_id', $data['user_id'])->first()) {
|
||||
Db::table('user_roles')->where('user_id', $data['user_id'])->update([
|
||||
'role_id' => $data['role_id']
|
||||
]);
|
||||
} else {
|
||||
Db::table('user_roles')->insert([
|
||||
'user_id' => $data['user_id'],
|
||||
'role_id' => $data['role_id']
|
||||
]);
|
||||
}
|
||||
|
||||
if (!Db::table('user_systems')->where('user_id', $data['user_id'])->where('system_id', $data['system_id'])->first()) {
|
||||
Db::table('user_systems')->where('user_id', $data['user_id'])->insert([
|
||||
'user_id' => $data['user_id'],
|
||||
'system_id' => $data['system_id'],
|
||||
'created_at' => time()
|
||||
]);
|
||||
}
|
||||
|
||||
Cache::delete("user_resources_{$data['user_id']}");
|
||||
return json(['code' => 0, 'msg' => 'success']);
|
||||
} catch (\Throwable $e) {
|
||||
return json(['code' => 1, 'msg' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成资源
|
||||
*/
|
||||
public function createResource()
|
||||
{
|
||||
$options = [
|
||||
'controller' => [
|
||||
'module' => 'common',
|
||||
'name' => 'inv_requisition_item_return_attachment'
|
||||
],
|
||||
'model' => [
|
||||
'module' => 'common',
|
||||
'name' => 'inv_requisition_item_return_attachment'
|
||||
],
|
||||
'service' => [
|
||||
'module' => 'common',
|
||||
'name' => 'inv_requisition_item_return_attachment'
|
||||
],
|
||||
'logic' => [
|
||||
'module' => 'common',
|
||||
'name' => 'inv_requisition_item_return_attachment'
|
||||
],
|
||||
'validate' => [
|
||||
'module' => 'common',
|
||||
'name' => 'inv_requisition_item_return_attachment'
|
||||
],
|
||||
'table' => 'inv_requisition_item_return_attachment'
|
||||
];
|
||||
|
||||
$result = (new Generate($options))->doGenerate();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜单迁移
|
||||
*/
|
||||
public function doMenu()
|
||||
{
|
||||
// 菜单迁移 (部分)
|
||||
$where[] = ['id', '>', 239];
|
||||
(new \app\common\utils\MigrationResources())->do('resources', 'resources_20251012_bak', $where);
|
||||
|
||||
// 整体
|
||||
// $list = (new \app\common\utils\MigrationResources())->getFullResourceTreeOptimized('resources_20250916_bak', []);
|
||||
// var_dump($list);
|
||||
}
|
||||
|
||||
|
||||
public function pdf(Request $request)
|
||||
{
|
||||
$id = $request->get('id');
|
||||
$service = new \app\common\service\StockOrdersService();
|
||||
$service->createdPdfFile($id);
|
||||
return json(['code' => 0, 'msg' => 'success']);
|
||||
}
|
||||
|
||||
|
||||
public function tocurl($url, $header = null, $content = null)
|
||||
{
|
||||
$ch = curl_init();
|
||||
if(substr($url,0,5)=='https'){
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
|
||||
curl_setopt($ch, CURLOPT_SSLVERSION, 1);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
if (is_array($header)) {
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
if (!empty($content)) {
|
||||
if (is_array($content)) {
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($content));
|
||||
} else if (is_string($content)) {
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
|
||||
}
|
||||
}
|
||||
$response = curl_exec($ch);
|
||||
$error=curl_error($ch);
|
||||
if($error){
|
||||
die($error);
|
||||
}
|
||||
$header = curl_getinfo($ch);
|
||||
curl_close($ch);
|
||||
$data = array('header' => $header,'body' => $response);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function test(Request $request)
|
||||
{
|
||||
$service = new \app\common\utils\crawl\service\UsedCarCrawl();
|
||||
|
||||
$result = $service->pushUrl('https://www.dongchedi.com/usedcar/21631642');
|
||||
|
||||
// $result = $service->doData();
|
||||
|
||||
// $result = $service->decodeDongchediPrice('.');
|
||||
|
||||
// $result = $service->detectEnergyType('油电混合');
|
||||
|
||||
return json($result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user