Files
xstore/inc/Hura8/Components/Staff/Model/StaffAuthModel.php

65 lines
1.5 KiB
PHP
Raw Normal View History

2025-10-04 11:46:59 +07:00
<?php
namespace Hura8\Components\Staff\Model;
use Hura8\System\Model\AuthModel;
/**
*
*/
class StaffAuthModel extends AuthModel
{
private $tb_staff_login = "tb_staff_login";
private $tb_staff_access_code = "tb_staff_access_code";
private $tb_staff_login_log = "tb_staff_login_log";
public function __construct() {
parent::__construct($this->tb_staff_login, $this->tb_staff_access_code);
}
public function getLoginListByIds(array $staff_ids) {
if(!sizeof($staff_ids)) {
return [];
}
list($parameterized_ids, $bind_types) = create_bind_sql_parameter_from_value_list($staff_ids, 'int');
$bind_values = $staff_ids;
$query = $this->db->runQuery(
"SELECT `user_id`, `last_login_time`, `last_login_ip`, `last_login_device`, `last_login_browser`
FROM ".$this->tb_staff_login."
WHERE `user_id` IN (".$parameterized_ids.") ",
$bind_types,
$bind_values
);
$item_list = [];
foreach ($this->db->fetchAll($query) as $item) {
$item_list[$item['user_id']] = $item;
}
return $item_list;
}
public function getLoginLog(array $conditions = []) {
$bind_types = [];
$bind_values = [];
$query = $this->db->runQuery(
"SELECT * FROM ".$this->tb_staff_login_log." WHERE 1 ORDER BY `id` DESC LIMIT 100 ",
$bind_types,
$bind_values
);
return $this->db->fetchAll($query) ;
}
}