SdkRegLogLogic.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | saiadmin [ saiadmin快速开发框架 ]
  4. // +----------------------------------------------------------------------
  5. // | Author: your name
  6. // +----------------------------------------------------------------------
  7. namespace app\v1\logic\gameLog;
  8. use plugin\saiadmin\basic\BaseLogic;
  9. use plugin\saiadmin\exception\ApiException;
  10. use plugin\saiadmin\utils\Helper;
  11. use app\v1\model\gameLog\SdkRegLog;
  12. /**
  13. * 注册日志逻辑层
  14. */
  15. class SdkRegLogLogic extends BaseLogic
  16. {
  17. /**
  18. * 构造函数
  19. */
  20. public function __construct()
  21. {
  22. $this->model = new SdkRegLog();
  23. }
  24. /**
  25. * 分页查询数据
  26. * @param $query
  27. * @return mixed
  28. */
  29. public function getList($query): mixed
  30. {
  31. $saiType = request()->input('saiType', 'list');
  32. $page = request()->input('page', 1);
  33. $limit = request()->input('limit', 10);
  34. $orderBy = request()->input('orderBy', '');
  35. $regTime = request()->input('reg_time', '');
  36. $orderType = request()->input('orderType', $this->orderType);
  37. if(empty($orderBy)) {
  38. $orderBy = $this->orderField !== '' ? $this->orderField : $this->model->getPk();
  39. }
  40. $query->order($orderBy, $orderType);
  41. $tableName = 'sdk_reg_log_'.date('Ym',strtotime($regTime));
  42. // 切换表名
  43. $query->table($tableName);
  44. if ($saiType === 'all') {
  45. return $query->select()->toArray();
  46. }
  47. return $query->paginate($limit, false, ['page' => $page])->toArray();
  48. }
  49. }