mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 23:57:49 +08:00
feat : admin log
This commit is contained in:
57
app/Repository/AdminUserLoginLogRepository.php
Normal file
57
app/Repository/AdminUserLoginLogRepository.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* This service file is part of item.
|
||||
*
|
||||
* @author ctexthuang
|
||||
* @contact ctexthuang@qq.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Model\AdminUserLoginLog;
|
||||
use Hyperf\Collection\Arr;
|
||||
use Hyperf\Database\Model\Builder;
|
||||
|
||||
final class AdminUserLoginLogRepository extends BaseRepository
|
||||
{
|
||||
/**
|
||||
* @param AdminUserLoginLog $model
|
||||
*/
|
||||
public function __construct(protected readonly AdminUserLoginLog $model) {}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param array $params
|
||||
* @return Builder
|
||||
*/
|
||||
public function handleSearch(Builder $query, array $params): Builder
|
||||
{
|
||||
return $query
|
||||
->when(Arr::get($params, 'username'), static function (Builder $query, $username) {
|
||||
$query->where('username', $username);
|
||||
})
|
||||
->when(Arr::get($params, 'ip'), static function (Builder $query, $ip) {
|
||||
$query->where('ip', $ip);
|
||||
})
|
||||
->when(Arr::get($params, 'os'), static function (Builder $query, $os) {
|
||||
$query->where('os', $os);
|
||||
})
|
||||
->when(Arr::get($params, 'browser'), static function (Builder $query, $browser) {
|
||||
$query->where('browser', $browser);
|
||||
})
|
||||
->when(Arr::get($params, 'status'), static function (Builder $query, $status) {
|
||||
$query->where('status', $status);
|
||||
})
|
||||
->when(Arr::get($params, 'message'), static function (Builder $query, $message) {
|
||||
$query->where('message', $message);
|
||||
})
|
||||
->when(Arr::get($params, 'login_time'), static function (Builder $query, $login_time) {
|
||||
$query->whereBetween('login_time', $login_time);
|
||||
})
|
||||
->when(Arr::get($params, 'remark'), static function (Builder $query, $remark) {
|
||||
$query->where('remark', $remark);
|
||||
});
|
||||
}
|
||||
}
|
||||
18
app/Repository/AdminUserOperationLogRepository.php
Normal file
18
app/Repository/AdminUserOperationLogRepository.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* This service file is part of item.
|
||||
*
|
||||
* @author ctexthuang
|
||||
* @contact ctexthuang@qq.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Model\AdminUserOperationLog;
|
||||
|
||||
final class AdminUserOperationLogRepository extends BaseRepository
|
||||
{
|
||||
public function __construct(protected readonly AdminUserOperationLog $model) {}
|
||||
}
|
||||
Reference in New Issue
Block a user