mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 11:19:56 +00:00
no message
This commit is contained in:
parent
86d9baa503
commit
f7206c1603
@ -2493,7 +2493,7 @@ class UsersController extends AbstractController
|
||||
{
|
||||
$user = User::auth();
|
||||
//
|
||||
$list = UserDevice::whereUserid($user->userid)->orderByDesc('id')->take(100)->get();
|
||||
$list = UserDevice::whereUserid($user->userid)->orderByDesc('id')->take(UserDevice::$deviceLimit)->get();
|
||||
//
|
||||
return Base::retSuccess('success', [
|
||||
'list' => $list
|
||||
|
||||
@ -49,6 +49,8 @@ class UserDevice extends AbstractModel
|
||||
|
||||
protected $table = 'user_devices';
|
||||
|
||||
public static int $deviceLimit = 200; // 每个用户设备限制数量
|
||||
|
||||
protected $appends = [
|
||||
'is_current',
|
||||
];
|
||||
@ -234,7 +236,17 @@ class UserDevice extends AbstractModel
|
||||
unset($deviceData['detail']);
|
||||
}
|
||||
return $deviceData;
|
||||
}, $deviceData);
|
||||
}, $deviceData, $isInsert);
|
||||
if ($isInsert) {
|
||||
$currentDeviceCount = self::whereUserid($userid)->count();
|
||||
if ($currentDeviceCount > self::$deviceLimit) {
|
||||
// 删除多余的设备记录
|
||||
$rows = self::whereUserid($userid)->orderBy('id')->take($currentDeviceCount - self::$deviceLimit)->get();
|
||||
foreach ($rows as $row) {
|
||||
UserDevice::forget($row);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($row) {
|
||||
Cache::put(self::ck($hash), $row->userid, now()->addHour());
|
||||
return $row;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user