'否','1' => '是']; } public function getStatusList() { return ['0' => __('Status 0'),'1' => __('Status 1')]; } public function getIsAllTextAttr($value, $data) { $value = $value ? $value : $data['is_all']; $list = $this->getIsAllList(); return isset($list[$value]) ? $list[$value] : ''; } public function getStatusTextAttr($value, $data) { $value = $value ? $value : $data['status']; $list = $this->getStatusList(); return isset($list[$value]) ? $list[$value] : ''; } /** * 拉取API配置 * @param $client_id * @param bool $fromDb * @return array|mixed * @throws \think\Exception */ public function getInfo($client_id, $fromDb = false) { $redisKey = "DATAAPI:".$client_id; if ($fromDb == false) { $data = Redis::instance()->get($redisKey); if ($data) { return json_decode($data, true); } else { $fromDb = true; } } if ($fromDb) { $row = $this->where('client_id', 'eq', $client_id)->find(); if ($row) { $data = $row->toArray(); } else { $data = []; } Redis::instance()->set($redisKey, json_encode($data), 3600); return $data; } return []; } }