AdminHistory.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace App\Http\Controllers\manager;
  3. use App\Http\Controllers\Controller;
  4. use App\Http\Requests\Manager\AdminHistory as Request;
  5. use App\Models\Manager\AdminHistory as AdminHistoryModel;
  6. /**
  7. * 操作日志记录
  8. * @author 唐远望
  9. * @version 1.0
  10. * @date 2025-12-24
  11. */
  12. class AdminHistory extends Controller
  13. {
  14. /**
  15. * 列表
  16. * @author 唐远望
  17. * @version 1.0
  18. * @date 2025-12-24
  19. *
  20. */
  21. public function list(Request $request, AdminHistoryModel $AdminHistoryModel)
  22. {
  23. $request->scene('list')->validate();
  24. // 查询条件
  25. $map = [];
  26. $limit = request('limit', config('page_num', 10));
  27. $status = request('status', '');
  28. $start_time = request('start_time', '');
  29. $end_time = request('end_time', '');
  30. $module_menu_name = request('module_menu_name', '');
  31. $general_description = request('general_description', '');
  32. $notes_type = request('notes_type', '');
  33. // 时间条件
  34. if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
  35. if ($end_time) $map[] = ['insert_time', '<=', strtotime($end_time)];
  36. // 其他条件
  37. if (is_numeric($status)) $map[] = ['status', '=', $status];
  38. if ($module_menu_name) $map[] = ['module_menu_name', 'like', "%$module_menu_name%"];
  39. if ($general_description) $map[] = ['general_description', 'like', "%$general_description%"];
  40. if ($notes_type) $map[] = ['notes_type', '=', $notes_type];
  41. // 查询数据
  42. $result = $AdminHistoryModel->join('admin', 'admin.uid', '=', 'admin_history.admin_uid')
  43. ->where($map)
  44. ->select(['admin_history.id','admin.username','admin_history.admin_uid','admin_history.module_menu_name','admin_history.notes_type','admin_history.general_description','admin_history.insert_time'])
  45. ->orderByDesc('admin_history.id')
  46. ->paginate($limit);
  47. // 分配数据
  48. if (!$result) return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => []]);
  49. // 加载模板
  50. return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $result]);
  51. }
  52. }