| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- /**
- * 日志模型
- * Created by PhpStorm.
- * User: XiaoMing
- * Date: 2019/10/30
- * Time: 14:26
- */
- namespace JinDouYun\Model\Log;
- use Mall\Framework\Core\StatusCode;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Core\ResultWrapper;
- use JinDouYun\Dao\Log\DLoginLog;
- class MLoginLog
- {
- private $objDLoginLog;
- private $enterpriseId;
- public function __construct($enterpriseId)
- {
- $this->enterpriseId = $enterpriseId;
- $this->objDLoginLog = new DLoginLog('log');
- //$this->objDLoginLog->setSearchIndex('login_log')->setType('login');
- }
- /**
- * 搜索条件 ES
- * @param $selectParams
- * @return array
- */
- public function setSearchWhere($selectParams = [])
- {
- $defaultDSL = [];
- if (isset($selectParams['offset'])) {
- $defaultDSL['from'] = $selectParams['offset'];
- }
- if (isset($selectParams['limit'])) {
- $defaultDSL['size'] = $selectParams['limit'];
- }
- $defaultDSL['sort'] =[
- 'createTime' => [
- 'order' => 'desc',
- 'unmapped_type' => 'long',
- ]
- ];
- $dsl = [];
- $dsl['query']['bool']['must'][] = [
- 'term' => ['enterpriseId' => $this->enterpriseId],
- ];
- $dsl = array_merge($defaultDSL, $dsl);
- return $dsl;
- }
- /**
- * @param array $selectParams 过滤条件
- * @return ResultWrapper
- * @throws Exception
- * @throws \Exception
- */
- public function getAllLoginLog($selectParams)
- {
- return ResultWrapper::success(['data'=>[],'total'=>0]);
- /*
- $dsl = $this->setSearchWhere($selectParams);
- $result = $this->objDLoginLog->getSearchQueryDsl($dsl);
- if (isset($result['status']) && $result['status'] == 400) {
- return ResultWrapper::success([
- 'data' => [],
- 'total' => 0
- ]);
- }
- if (!isset($result['hits']) || $result['hits']['total'] == 0) {
- return ResultWrapper::success([
- 'data' => [],
- 'total' => 0
- ]);
- }
- $total = $result['hits']['total'];
- $dbResult = $result['hits']['hits'];
- $list = [];
- foreach ($dbResult as $key => &$value) {
- $data = [];
- $data = $value['_source'];
- $data['id'] = $value['_id'];
- $list[] = $data;
- }
- $return = [
- 'data' => $list,
- 'total' => ($total) ? intval($total) : 0,
- ];
- return ResultWrapper::success($return);*/
- }
- }
|