12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace app\services\system\log;
- use app\dao\system\log\SystemLogDao;
- use app\services\BaseServices;
- use app\services\system\admin\SystemAdminServices;
- use app\services\system\SystemMenusServices;
- class SystemLogServices extends BaseServices
- {
-
- public function __construct(SystemLogDao $dao)
- {
- $this->dao = $dao;
- }
-
- public function recordAdminLog(int $adminId, string $adminName, string $module, string $rule, string $ip, string $type)
- {
-
- $service = app()->make(SystemMenusServices::class);
- $data = [
- 'method' => $module,
- 'add_time' => time(),
- 'admin_name' => $adminName,
- 'path' => $rule,
- 'page' => $service->getVisitName($rule) ?: '未知',
- 'ip' => $ip,
- 'type' => $type
- ];
- if ($type == 'store') {
- $data['store_id'] = $adminId;
- } else {
- $data['admin_id'] = $adminId;
- }
- if ($this->dao->save($data)) {
- return true;
- } else {
- return false;
- }
- }
-
- public function getLogList(array $where, int $level)
- {
- [$page, $limit] = $this->getPageValue();
- if (!$where['admin_id']) {
-
- $service = app()->make(SystemAdminServices::class);
- $where['admin_id'] = $service->getAdminIds($level);
- }
- $list = $this->dao->getLogList($where, $page, $limit);
- $count = $this->dao->count($where);
- return compact('list', 'count');
- }
- }
|