first commit
This commit is contained in:
46
app/api/controller/BaseApiController.php
Normal file
46
app/api/controller/BaseApiController.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseLikeAdminController;
|
||||
use app\common\model\user\{User,UserLog};
|
||||
|
||||
class BaseApiController extends BaseLikeAdminController
|
||||
{
|
||||
protected int $userId = 0;
|
||||
protected array $userInfo = [];
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
if (isset($this->request->userInfo) && $this->request->userInfo) {
|
||||
$this->userInfo = $this->request->userInfo;
|
||||
$this->userId = $this->request->userInfo['user_id'];
|
||||
|
||||
//更新最后操作时间,大于5分钟才更新
|
||||
$online_time = time() - 5*60;
|
||||
User::where(['id' => $this->userId])->where("last_time <= $online_time")->update(['last_time' => time()]);
|
||||
|
||||
// //更新用户操作记录 (统计活跃人数)
|
||||
// $start_time = strtotime(date('Y-m-d 00:00:00', time()));//0点
|
||||
// $userLog = UserLog::where("create_time >= $start_time")->where(['user_id' => $this->userId,'type' => 1])->findOrEmpty();
|
||||
// if ($userLog->isEmpty()) {
|
||||
// UserLog::create([
|
||||
// 'user_id' => $this->userId,
|
||||
// 'type' => 1
|
||||
// ]);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user