作者 lyh

gx

... ... @@ -5,6 +5,7 @@ namespace App\Helper;
use App\Models\Ai\AiCommand as AiCommandModel;
use App\Models\User\UserLog as UserLogModel;
use App\Models\User\UserLogin as UserLoginModel;
use Illuminate\Encryption\Encrypter;
use Illuminate\Support\Facades\Cache;
/**
... ... @@ -12,6 +13,8 @@ use Illuminate\Support\Facades\Cache;
*/
class Common
{
public $key = '66537a12d4fff992f6d8b67fdda6192f';
public $method = 'AES-256-CBC';
/**
* @name :生成用户操作日志
* @return void
... ... @@ -165,4 +168,19 @@ class Common
$days = floor(($currentTimestamp - $targetTimestamp) / (60 * 60 * 24));
return (int)$days;
}
// 生成授授权码
public function encrypt($data)
{
$crypt = new Encrypter($this->key, $this->method);
return $crypt->encrypt($data);
}
// 解密授权码
public function decrypt($string)
{
$crypt = new Encrypter($this->key, $this->method);
return $crypt->decrypt($string);
}
}
... ...
... ... @@ -15,7 +15,7 @@ class socket
// 创建一个Socket
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
// 绑定IP地址和端口
socket_bind($socket, '127.0.0.1', 8080);
socket_bind($socket, '127.0.0.1', 1213);
// 开始监听连接请求
socket_listen($socket);
// 接受客户端连接
... ...
... ... @@ -10,6 +10,7 @@
namespace App\Http\Controllers\Bside;
use App\Enums\Common\Code;
use App\Helper\Common;
use App\Helper\Translate;
use App\Helper\Wechat;
use App\Http\Logic\Bside\User\UserLoginLogic;
... ... @@ -144,4 +145,35 @@ class LoginController extends BaseController
@file_put_contents(storage_path('logs/lyh_error.log'), $message . PHP_EOL, FILE_APPEND);
$this->response('success');
}
/**
* @remark :生成token
* @name :generateToken
* @author :lyh
* @method :post
* @time :2023/8/24 17:27
*/
public function generateToken(){
$data = [
'phone' => $this->param['phone'],
'from_order_id' => $this->param['from_order_id'], // 提单系统 同步到个项目的唯一凭证(数字或者字符串)
'timestamp' => time(), // 接收到字符串解密出来以后需要 验证时间不超过30秒 超过时间视为无效授权
];
$common = new Common();
$str = $common->encrypt($data);
$this->response('success',Code::SUCCESS,['str'=>$str]);
}
/**
* @remark :解token
* @name :globalSo_v6_login
* @author :lyh
* @method :post
* @time :2023/8/24 17:37
*/
public function globalSo_v6_login(){
$common = new Common();
$arr = $common->decrypt($this->param['token']);
$this->response('success',Code::SUCCESS,$arr);
}
}
... ...
... ... @@ -339,4 +339,6 @@ Route::group([], function () {
Route::any('/sendLoginSms', [\App\Http\Controllers\Bside\LoginController::class, 'sendLoginSms'])->name('sendLoginSms');
Route::any('/autologin', [\App\Http\Controllers\Bside\LoginController::class, 'autologin'])->name('autologin');
Route::any('/qrcode', [\App\Http\Controllers\Bside\LoginController::class, 'qrcode'])->name('qrcode');
Route::any('/generateToken', [\App\Http\Controllers\Bside\LoginController::class, 'generateToken'])->name('generateToken');
Route::any('/globalSo_v6_login', [\App\Http\Controllers\Bside\LoginController::class, 'globalSo_v6_login'])->name('globalSo_v6_login');
});
... ...
... ... @@ -9,3 +9,4 @@ use Illuminate\Support\Facades\Route;
* @time :2023/8/24 10:14
*/
Route::any('/eventmessage', [\App\Http\Controllers\Bside\LoginController::class, 'eventMessage'])->name('eventMessage');
... ...