Solution.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\controller\api;
  3. use app\extra\basic\Base;
  4. use app\extra\dyLife\Token;
  5. use app\extra\dyMini\Relation;
  6. use app\middleware\AuthMiddleware;
  7. use LinFly\Annotation\Attributes\Route\Controller;
  8. use LinFly\Annotation\Attributes\Route\GetMapping;
  9. use LinFly\Annotation\Attributes\Route\RequestMapping;
  10. use support\Request;
  11. use support\Response;
  12. /**
  13. * 解决方案回传
  14. */
  15. #[Controller("/solution")]
  16. class Solution extends Base
  17. {
  18. #[RequestMapping(path: "notify")]
  19. public function getSolutionData(Request $request): Response
  20. {
  21. try {
  22. $data = $request->all();
  23. echo getDateFull()."===扩展回调\n";
  24. print_r($data);
  25. print_r($request->rawBody());
  26. return json(['err_no' => 0,"err_tips" => "success"]);
  27. } catch (\Throwable $throwable) {
  28. return error($throwable->getMessage());
  29. }
  30. }
  31. #[GetMapping("token")]
  32. public function setTestToken(Request $request): Response
  33. {
  34. try {
  35. $param = $this->_valid([
  36. "code.require" => ""
  37. ]);
  38. if (!is_array($param)) return error($param);
  39. $data = (new Token)->config($this->getDyConfig())->token()->getAccessTokenUser($param['code']);
  40. return success("ok",$data);
  41. } catch (\Throwable $throwable) {
  42. return error($throwable->getMessage());
  43. }
  44. }
  45. #[GetMapping("test")]
  46. public function setTest()
  47. {
  48. try {
  49. $data = (new Relation)->config($this->getDyConfig())->token()->createOrderFirst(['1865253598118939']);
  50. return success("ok",$data);
  51. } catch (\Throwable $throwable) {
  52. return error($throwable->getMessage());
  53. }
  54. }
  55. }