SdkLoginLogLogic.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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\SdkLoginLog;
  12. /**
  13. * 登录日志逻辑层
  14. */
  15. class SdkLoginLogLogic extends BaseLogic
  16. {
  17. /**
  18. * 构造函数
  19. */
  20. public function __construct()
  21. {
  22. $this->model = new SdkLoginLog();
  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. $loginTime = request()->input('login_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_login_log_'.date('Ym',strtotime($loginTime));
  42. print_r('tableName:'.$tableName);
  43. // 切换表名
  44. $query->table($tableName);
  45. if ($saiType === 'all') {
  46. return $query->select()->toArray();
  47. }
  48. return $query->paginate($limit, false, ['page' => $page])->toArray();
  49. }
  50. }