first commit

This commit is contained in:
Your Name
2026-01-19 14:19:22 +08:00
commit fe2d9c1868
4777 changed files with 665503 additions and 0 deletions

View 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
// ]);
// }
}
}
}