whereIn('label', $targetLabels) // 仅筛选指定的 label ->field('label, value') ->select(); $this->logSuccess('站点设置管理', '查看基本信息配置', [], $this->getAdminUserInfo()); return json([ 'code' => 200, 'msg' => '获取成功', 'data' => $siteSettings->toArray() ]); } /** * 保存基本信息 * @return Json */ public function saveNormalInfos() { $params = $this->request->param(); $rawData = isset($params['data']) ? json_decode($params['data'], true) : $params; $allowedLabels = ['sitename', 'logo', 'logow', 'description', 'copyright', 'companyname', 'icp']; foreach ($allowedLabels as $label) { if (isset($rawData[$label])) { SystemSiteSettings::update( ['value' => (string)$rawData[$label]], ['label' => $label] ); } } $this->logSuccess('站点设置管理', '保存基本信息', ['labels' => $allowedLabels], $this->getAdminUserInfo()); return json(['code' => 200, 'msg' => '基本信息保存成功']); } /** * 获取登录验证数据 * @return Json */ public function getVerifyInfos() { // 定义你需要的 label 列表 $targetLabels = [ 'openVerify', 'verifyModel', 'geetestID', 'geetestKEY' ]; $legalInfos = SystemSiteSettings::where('delete_time', null) ->whereIn('label', $targetLabels) // 仅筛选指定的 label ->field('label, value') ->select(); $this->logSuccess('站点设置管理', '查看登录验证数据', [], $this->getAdminUserInfo()); return json([ 'code' => 200, 'msg' => '获取成功', 'data' => $legalInfos->toArray() ]); } /** * 保存登录验证数据 * @return Json */ public function saveVerifyInfos() { $params = $this->request->param(); $allowedLabels = ['openVerify', 'verifyModel', 'geetestID', 'geetestKEY']; foreach ($allowedLabels as $label) { if (isset($params[$label])) { $val = $params[$label]; if (is_bool($val)) { $val = $val ? '1' : '0'; } SystemSiteSettings::where('label', $label)->update([ 'value' => (string)$val ]); } } $this->logSuccess('站点设置管理', '保存登录验证配置', $params, $this->getAdminUserInfo()); return json(['code' => 200, 'msg' => '保存成功']); } /** * 获取法律声明和隐私条款 * @return Json */ public function getLegalInfos() { // 定义你需要的 label 列表 $targetLabels = [ 'legalNotice', 'privacyTerms' ]; $legalInfos = SystemSiteSettings::where('delete_time', null) ->whereIn('label', $targetLabels) // 仅筛选指定的 label ->field('label, value') ->select(); $this->logSuccess('站点设置管理', '查看法律声明和隐私条款', [], $this->getAdminUserInfo()); return json([ 'code' => 200, 'msg' => '获取成功', 'data' => $legalInfos->toArray() ]); } /** * 保存法律声明和隐私条款 * @return Json */ public function saveLegalInfos() { $params = $this->request->param(); $rawData = isset($params['data']) ? json_decode($params['data'], true) : $params; $allowedLabels = ['legalNotice', 'privacyTerms']; foreach ($allowedLabels as $label) { if (isset($rawData[$label])) { SystemSiteSettings::update( ['value' => (string)$rawData[$label]], ['label' => $label] ); } } $this->logSuccess('站点设置管理', '保存法律声明和隐私条款', ['labels' => $allowedLabels], $this->getAdminUserInfo()); return json(['code' => 200, 'msg' => '法律声明和隐私条款保存成功']); } }