You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
977 B

5 years ago
  1. <?php
  2. namespace App\Controller\v3;
  3. use App\Controller\BaseController;
  4. use App\Service\v3\Interfaces\ParamsTokenServiceInterface;
  5. use Hyperf\Di\Annotation\Inject;
  6. /**
  7. * 参数token控制器
  8. * Class ParamsTokenController
  9. * @package App\Controller
  10. */
  11. class ParamsTokenController extends BaseController
  12. {
  13. /**
  14. * @Inject
  15. * @var ParamsTokenServiceInterface
  16. */
  17. protected $paramsTokenService;
  18. /**
  19. * 生成token存储对应参数数据
  20. * @return \Psr\Http\Message\ResponseInterface
  21. */
  22. public function generate()
  23. {
  24. $token = $this->paramsTokenService->generate($this->request->all());
  25. return $this->success(['token' => $token]);
  26. }
  27. /**
  28. * 解析token获取对应参数数据
  29. * @return \Psr\Http\Message\ResponseInterface
  30. */
  31. public function analyze()
  32. {
  33. $params = $this->paramsTokenService->analyze($this->request->input('token'));
  34. return $this->success($params);
  35. }
  36. }