LogDao.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\common\dao\system\admin;
  3. use app\common\dao\BaseDao;
  4. use app\common\model\BaseModel;
  5. use app\common\model\system\admin\Log;
  6. use think\db\BaseQuery;
  7. /**
  8. * Class LogDao
  9. * @package app\common\dao\system\admin
  10. * @author zfy
  11. * @day 2020-04-16
  12. */
  13. class LogDao extends BaseDao
  14. {
  15. /**
  16. * @return BaseModel
  17. * @author zfy
  18. * @day 2020-03-30
  19. */
  20. protected function getModel(): string
  21. {
  22. return Log::class;
  23. }
  24. /**
  25. * @param array $where
  26. * @param $merId
  27. * @return BaseQuery
  28. * @author zfy
  29. * @day 2020-04-16
  30. */
  31. public function search(array $where, $merId)
  32. {
  33. $query = Log::getDB()->where('mer_id', $merId)->when(isset($where['date']) && $where['date'] !== '', function ($query) use ($where) {
  34. getModelTime($query, $where['date']);
  35. });
  36. if (isset($where['method']) && $where['method'] !== '') $query->where('method', $where['method']);
  37. if (isset($where['admin_id']) && $where['admin_id'] !== '') $query->where('admin_id', $where['admin_id']);
  38. if (isset($where['section_startTime']) && $where['section_startTime'] && isset($where['section_endTime']) && $where['section_endTime'])
  39. $query->where('create_time', '>', $where['section_startTime'])->where('create_time', '<', $where['section_endTime']);
  40. return $query;
  41. }
  42. }