LogDao.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\common\dao\system\admin;
  12. use app\common\dao\BaseDao;
  13. use app\common\model\BaseModel;
  14. use app\common\model\system\admin\Log;
  15. use think\db\BaseQuery;
  16. /**
  17. * Class LogDao
  18. * @package app\common\dao\system\admin
  19. * @author xaboy
  20. * @day 2020-04-16
  21. */
  22. class LogDao extends BaseDao
  23. {
  24. /**
  25. * @return BaseModel
  26. * @author xaboy
  27. * @day 2020-03-30
  28. */
  29. protected function getModel(): string
  30. {
  31. return Log::class;
  32. }
  33. /**
  34. * @param array $where
  35. * @param $merId
  36. * @return BaseQuery
  37. * @author xaboy
  38. * @day 2020-04-16
  39. */
  40. public function search(array $where, $merId)
  41. {
  42. $query = Log::getDB()->where('mer_id', $merId)->when(isset($where['date']) && $where['date'] !== '', function ($query) use ($where) {
  43. getModelTime($query, $where['date']);
  44. });
  45. if (isset($where['method']) && $where['method'] !== '') $query->where('method', $where['method']);
  46. if (isset($where['admin_id']) && $where['admin_id'] !== '') $query->where('admin_id', $where['admin_id']);
  47. if (isset($where['section_startTime']) && $where['section_startTime'] && isset($where['section_endTime']) && $where['section_endTime'])
  48. $query->where('create_time', '>', $where['section_startTime'])->where('create_time', '<', $where['section_endTime']);
  49. return $query;
  50. }
  51. }