Debug.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use Illuminate\Support\Facades\Redis;
  4. use App\Http\Controllers\Core\Auth;
  5. use App\Http\Controllers\Controller;
  6. use Illuminate\Http\Request;
  7. class Debug extends Controller
  8. {
  9. public function get()
  10. {
  11. $uid = Auth::adminAuth();
  12. try {
  13. $admins = Redis::hgetall("fpdx_admin_debug");
  14. unset($admins['#']);
  15. $result = array();
  16. foreach ($admins as $k => $v) {
  17. array_push($result, [
  18. 'admin_uid' => $k,
  19. 'debug_uid' => $v
  20. ]);
  21. }
  22. return array(
  23. 'code' => 200,
  24. 'message' => 'success',
  25. 'data' => $result
  26. );
  27. } catch (\Exception $e) {
  28. throw new \ApiException($e->getMessage(), 501);
  29. }
  30. }
  31. public function store(Request $request)
  32. {
  33. $uid = Auth::adminAuth();
  34. try {
  35. $this->validate($request, [
  36. 'admin_uid' => 'required|integer',
  37. 'debug_uid' => 'required|integer'
  38. ]);
  39. Redis::hset("fpdx_admin_debug", $request->input('admin_uid'), $request->input('debug_uid'));
  40. return array(
  41. 'code' => 200,
  42. 'message' => 'success'
  43. );
  44. } catch (\Exception $e) {
  45. throw new \ApiException($e->getMessage(), 501);
  46. }
  47. }
  48. public function delete(Request $request)
  49. {
  50. $uid = Auth::adminAuth();
  51. try {
  52. $this->validate($request, [
  53. 'admin_uid' => 'required|integer'
  54. ]);
  55. Redis::hdel("fpdx_admin_debug", $request->input('admin_uid'));
  56. return array(
  57. 'code' => 200,
  58. 'message' => 'success'
  59. );
  60. } catch (\Exception $e) {
  61. throw new \ApiException($e->getMessage(), 501);
  62. }
  63. }
  64. }