processor.php 770 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 2016/10/6
  6. * Time: 下午10:35
  7. */
  8. namespace search;
  9. class processor implements IProcessor
  10. {
  11. const GetRelatedWord = 1;
  12. const SearchReasult = 2;
  13. public function handle_input($body)
  14. {
  15. $body = unserialize($body);
  16. $type = $body['type'];
  17. if($type == self::GetRelatedWord)
  18. {
  19. $words = $body['keyword'];
  20. $result = searcher::instance()->get_word($words);
  21. return serialize($result);
  22. }
  23. else if($type == self::SearchReasult) {
  24. $params = $body['params'];
  25. $result = searcher::instance()->get_result($params);
  26. return serialize($result);
  27. }
  28. else {
  29. }
  30. }
  31. }