|
|
@@ -97,6 +97,34 @@ class ConfigService extends BaseService
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 获取配置选项值
|
|
|
+ * @param $groupId
|
|
|
+ * @return array|mixed
|
|
|
+ */
|
|
|
+ public function getConfigOptionByGroup($groupId){
|
|
|
+ $cacheKey = "caches:config:groups:value_{$groupId}";
|
|
|
+ $datas = RedisService::get($cacheKey);
|
|
|
+ if($datas){
|
|
|
+ return $datas;
|
|
|
+ }
|
|
|
+ $datas = $this->model::where(['config_group_id'=> $groupId, 'status'=> 1])
|
|
|
+ ->select('title','code','value')
|
|
|
+ ->orderBy('sort','asc')
|
|
|
+ ->get()
|
|
|
+ ->keyBy('code');
|
|
|
+ $datas = $datas? $datas->toArray() : [];
|
|
|
+ $result = [];
|
|
|
+ if($datas){
|
|
|
+ foreach ($datas as $k => $v){
|
|
|
+ $result[$k] = $v['value'];
|
|
|
+ }
|
|
|
+ RedisService::set($cacheKey, $result, 30);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 获取单个配置
|
|
|
* @param $groupId
|
|
|
* @return mixed
|