BaseLogic.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\common\logic;
  20. /**
  21. * 逻辑基类
  22. * Class BaseLogic
  23. * @package app\common\logic
  24. */
  25. class BaseLogic
  26. {
  27. /**
  28. * 错误信息
  29. * @var string
  30. */
  31. protected static $error;
  32. /**
  33. * 返回状态码
  34. * @var int
  35. */
  36. protected static $returnCode = 0;
  37. protected static $returnData;
  38. /**
  39. * @notes 获取错误信息
  40. * @return string
  41. * @author 段誉
  42. * @date 2021/7/21 18:23
  43. */
  44. public static function getError()
  45. {
  46. if (false === self::hasError()) {
  47. return '系统错误';
  48. }
  49. return self::$error;
  50. }
  51. /**
  52. * @notes 设置错误信息
  53. * @param $error
  54. * @author 段誉
  55. * @date 2021/7/21 18:20
  56. */
  57. public static function setError($error)
  58. {
  59. !empty($error) && self::$error = $error;
  60. }
  61. /**
  62. * @notes 是否存在错误
  63. * @return bool
  64. * @author 段誉
  65. * @date 2021/7/21 18:32
  66. */
  67. public static function hasError()
  68. {
  69. return !empty(self::$error);
  70. }
  71. /**
  72. * @notes 设置状态码
  73. * @param $code
  74. * @author 段誉
  75. * @date 2021/7/28 17:05
  76. */
  77. public static function setReturnCode($code)
  78. {
  79. self::$returnCode = $code;
  80. }
  81. /**
  82. * @notes 特殊场景返回指定状态码,默认为0
  83. * @return int
  84. * @author 段誉
  85. * @date 2021/7/28 15:14
  86. */
  87. public static function getReturnCode()
  88. {
  89. return self::$returnCode;
  90. }
  91. /**
  92. * @notes 获取内容
  93. * @return mixed
  94. * @author cjhao
  95. * @date 2021/9/11 17:29
  96. */
  97. public static function getReturnData()
  98. {
  99. return self::$returnData;
  100. }
  101. }