CommandController.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Http\Api\Mq;
  4. use App\Services\AuthService;
  5. use Illuminate\Http\Request;
  6. use Illuminate\Http\Response;
  7. class CommandController extends Controller
  8. {
  9. /**
  10. * Display a listing of the resource.
  11. *
  12. * @return Response
  13. */
  14. public function index()
  15. {
  16. //
  17. return $this->ok('ok');
  18. }
  19. /**
  20. * Store a newly created resource in storage.
  21. *
  22. * @return Response
  23. */
  24. public function store(Request $request)
  25. {
  26. //
  27. $user = AuthService::current($request);
  28. if (! $user || $user['user_uid'] !== 'ba5463f3-72d1-4410-858e-eadd10884713') {
  29. return $this->error(__('auth.failed'), 403, 403);
  30. }
  31. Mq::publish('task', [
  32. 'name' => $request->input('name'),
  33. 'param' => $request->input('param'),
  34. ]);
  35. return $this->ok('ok');
  36. }
  37. /**
  38. * Display the specified resource.
  39. *
  40. * @param int $id
  41. * @return Response
  42. */
  43. public function show($id)
  44. {
  45. //
  46. }
  47. /**
  48. * Update the specified resource in storage.
  49. *
  50. * @param int $id
  51. * @return Response
  52. */
  53. public function update(Request $request, $id)
  54. {
  55. //
  56. }
  57. /**
  58. * Remove the specified resource from storage.
  59. *
  60. * @param int $id
  61. * @return Response
  62. */
  63. public function destroy($id)
  64. {
  65. //
  66. }
  67. }