【程序陌路】优化版权信息写入和查询

This commit is contained in:
吴昊天 2022-12-23 15:49:28 +08:00
parent 2faad235ff
commit d59edba229
2 changed files with 9 additions and 65 deletions

View File

@ -361,30 +361,8 @@ class Common extends AuthController
*/
public function copyright()
{
try {
if (Cache::has('nncnL_crmeb_copyright')) {
$copyrightContext = Cache::get('nncnL_crmeb_copyright');
} else {
/** @var SystemConfigServices $services */
$services = app()->make(SystemConfigServices::class);
$copyrightContext = $services->value(['menu_name' => 'nncnL_crmeb_copyright'], 'value');
$copyrightContext = $copyrightContext ? json_decode($copyrightContext, true) : null;
Cache::set('nncnL_crmeb_copyright', $copyrightContext, 3600);
}
if (Cache::has('nncnL_crmeb_copyright_image')) {
$copyrightImage = Cache::get('nncnL_crmeb_copyright_image');
} else {
/** @var SystemConfigServices $services */
$services = app()->make(SystemConfigServices::class);
$copyrightImage = $services->value(['menu_name' => 'nncnL_crmeb_copyright_image'], 'value');
$copyrightImage = $copyrightImage ? json_decode($copyrightImage, true) : null;
Cache::set('nncnL_crmeb_copyright_image', $copyrightImage, 3600);
}
} catch (\Throwable $e) {
$copyrightContext = '';
$copyrightImage = '';
}
$copyrightContext = sys_config('nncnL_crmeb_copyright', '');
$copyrightImage = sys_config('nncnL_crmeb_copyright_image', '');
return app('json')->success(compact('copyrightContext', 'copyrightImage'));
}
@ -395,15 +373,10 @@ class Common extends AuthController
public function saveCopyright()
{
[$copyright, $copyrightImg] = $this->request->postMore(['copyright', 'copyright_img',], true);
/** @var SystemConfigServices $services */
$services = app()->make(SystemConfigServices::class);
if ($services->count(['menu_name' => 'nncnL_crmeb_copyright'])) {
$services->update([
'menu_name' => 'nncnL_crmeb_copyright'
], [
'value' => json_encode($copyright)
]);
$services->update(['menu_name' => 'nncnL_crmeb_copyright'], ['value' => json_encode($copyright)]);
} else {
$services->save([
'menu_name' => 'nncnL_crmeb_copyright',
@ -415,13 +388,8 @@ class Common extends AuthController
'info' => ''
]);
}
if ($services->count(['menu_name' => 'nncnL_crmeb_copyright_image'])) {
$services->update([
'menu_name' => 'nncnL_crmeb_copyright_image'
], [
'value' => json_encode($copyrightImg)
]);
$services->update(['menu_name' => 'nncnL_crmeb_copyright_image'], ['value' => json_encode($copyrightImg)]);
} else {
$services->save([
'menu_name' => 'nncnL_crmeb_copyright_image',
@ -433,9 +401,6 @@ class Common extends AuthController
'info' => ''
]);
}
Cache::set('nncnL_crmeb_copyright', $copyright, 3600);
Cache::set('nncnL_crmeb_copyright_image', $copyrightImg, 3600);
return app('json')->success(100000);
}

View File

@ -556,32 +556,11 @@ class PublicController
*/
public function copyright()
{
try {
if (Cache::has('nncnL_crmeb_copyright')) {
$copyrightContext = Cache::get('nncnL_crmeb_copyright');
} else {
/** @var SystemConfigServices $services */
$services = app()->make(SystemConfigServices::class);
$copyrightContext = $services->value(['menu_name' => 'nncnL_crmeb_copyright'], 'value');
$copyrightContext = $copyrightContext ? json_decode($copyrightContext, true) : null;
Cache::set('nncnL_crmeb_copyright', $copyrightContext, 3600);
}
// dump(Cache::has('nncnL_crmeb_copyright_image'));
if (Cache::has('nncnL_crmeb_copyright_image')) {
$copyrightImage = Cache::get('nncnL_crmeb_copyright_image');
} else {
/** @var SystemConfigServices $services */
$services = app()->make(SystemConfigServices::class);
$copyrightImage = $services->value(['menu_name' => 'nncnL_crmeb_copyright_image'], 'value');
$copyrightImage = $copyrightImage ? json_decode($copyrightImage, true) : null;
Cache::set('nncnL_crmeb_copyright_image', $copyrightImage, 3600);
}
} catch (\Throwable $e) {
$copyrightContext = '';
$copyrightImage = '';
}
return app('json')->success(compact('copyrightContext', 'copyrightImage'));
$copyrightContext = sys_config('nncnL_crmeb_copyright', '');
$copyrightImage = sys_config('nncnL_crmeb_copyright_image', '');
$siteName = sys_config('site_name', '');
$siteLogo = sys_config('wap_login_logo', '');
return app('json')->success(compact('copyrightContext', 'copyrightImage', 'siteName', 'siteLogo'));
}
/**