Resp.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /*
  3. * To change this license header, choose License Headers in Project Properties.
  4. * To change this template file, choose Tools | Templates
  5. * and open the template in the editor.
  6. */
  7. /**
  8. * Description of Resp
  9. * 应答体
  10. * @author jgao
  11. */
  12. class Resp {
  13. //put your code here
  14. /**
  15. * 应答数据
  16. * @var type
  17. */
  18. public $data = null;
  19. /**
  20. * 错误码
  21. * @var type
  22. */
  23. public $err = 0;
  24. /**
  25. * 错误消息
  26. * @var type
  27. */
  28. public $errMsg = "";
  29. function stringify(){
  30. return json_encode($this);
  31. }
  32. /**
  33. *
  34. * @param type $data
  35. * @return \Resp
  36. */
  37. static function ret($data){
  38. $resp = new Resp();
  39. $resp->data = $data;
  40. return $resp;
  41. }
  42. /**
  43. *
  44. * @param type $err
  45. * @param type $msg
  46. * @return \Resp
  47. */
  48. static function err($err, $msg){
  49. $resp = new Resp();
  50. $resp->err = $err;
  51. $resp->errMsg = $msg;
  52. return $resp;
  53. }
  54. }