更新若干bug
This commit is contained in:
@@ -43,7 +43,7 @@ class SiteSettingsController extends BaseController
|
||||
$data = [
|
||||
'sitename' => $siteSetting->sitename ?? '',
|
||||
'logo' => $siteSetting->logo ?? '',
|
||||
'logow' => $siteSetting->{'logo-w'} ?? '',
|
||||
'logow' => $siteSetting->logow ?? '',
|
||||
'description' => $siteSetting->description ?? '',
|
||||
'copyright' => $siteSetting->copyright ?? '',
|
||||
'companyname' => $siteSetting->companyname ?? '',
|
||||
@@ -89,7 +89,7 @@ class SiteSettingsController extends BaseController
|
||||
$siteSetting->logo = (string)$rawData['logo'];
|
||||
}
|
||||
if (isset($rawData['logow'])) {
|
||||
$siteSetting->{'logo-w'} = (string)$rawData['logow'];
|
||||
$siteSetting->logow = (string)$rawData['logow'];
|
||||
}
|
||||
if (isset($rawData['description'])) {
|
||||
$siteSetting->description = (string)$rawData['description'];
|
||||
@@ -300,4 +300,77 @@ class SiteSettingsController extends BaseController
|
||||
|
||||
return json(['code' => 200, 'msg' => '企业信息保存成功']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取企业SEO
|
||||
* @return Json
|
||||
*/
|
||||
public function getCompanySeo()
|
||||
{
|
||||
// 获取当前租户ID
|
||||
$tid = $this->getTenantId();
|
||||
|
||||
// 直接根据 ID 查询租户记录
|
||||
$tenant = Tenant::where('delete_time', null)
|
||||
->where('id', $tid)
|
||||
->field('seoTitle, seoKeywords, seoDescription')
|
||||
->find();
|
||||
|
||||
// 如果没有数据,返回默认空值
|
||||
if (!$tenant) {
|
||||
$data = [
|
||||
'seoTitle' => '',
|
||||
'seoKeywords' => '',
|
||||
'seoDescription' => ''
|
||||
];
|
||||
} else {
|
||||
// 直接读取模型对象的属性
|
||||
$data = [
|
||||
'seoTitle' => $tenant->seoTitle ?? '',
|
||||
'seoKeywords' => $tenant->seoKeywords ?? '',
|
||||
'seoDescription' => $tenant->seoDescription ?? ''
|
||||
];
|
||||
}
|
||||
|
||||
$this->logSuccess('站点设置管理', '查看企业SEO', ['tid' => $tid], $this->getAdminUserInfo());
|
||||
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => '获取成功',
|
||||
'data' => $data
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存企业SEO
|
||||
* @return Json
|
||||
*/
|
||||
public function saveCompanySeo()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
|
||||
$id = $this->getTenantId();
|
||||
|
||||
$tenant = Tenant::where('delete_time', null)
|
||||
->where('id', $id)
|
||||
->find();
|
||||
|
||||
if (!$tenant) {
|
||||
return json(['code' => 404, 'msg' => '租户不存在']);
|
||||
}
|
||||
|
||||
// 构建更新数据
|
||||
$updateData = [];
|
||||
if (isset($params['seoTitle'])) $updateData['seoTitle'] = (string)$params['seoTitle'];
|
||||
if (isset($params['seoKeywords'])) $updateData['seoKeywords'] = (string)$params['seoKeywords'];
|
||||
if (isset($params['seoDescription'])) $updateData['seoDescription'] = (string)$params['seoDescription'];
|
||||
|
||||
if (!empty($updateData)) {
|
||||
$tenant->save($updateData);
|
||||
}
|
||||
|
||||
$this->logSuccess('站点设置管理', '保存企业SEO', ['tid' => $id], $this->getAdminUserInfo());
|
||||
|
||||
return json(['code' => 200, 'msg' => '企业SEO保存成功']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,3 +10,5 @@ Route::get('legalInfos', 'app\\admin\\controller\\SiteSettingsController@getLega
|
||||
Route::post('saveLegalInfos', 'app\\admin\\controller\\SiteSettingsController@saveLegalInfos');
|
||||
Route::get('companyInfos', 'app\\admin\\controller\\SiteSettingsController@getCompanyInfos');
|
||||
Route::post('saveCompanyInfos', 'app\\admin\\controller\\SiteSettingsController@saveCompanyInfos');
|
||||
Route::get('companySeo', 'app\\admin\\controller\\SiteSettingsController@getCompanySeo');
|
||||
Route::post('saveCompanySeo', 'app\\admin\\controller\\SiteSettingsController@saveCompanySeo');
|
||||
|
||||
Reference in New Issue
Block a user