qingjian/app/controller/manager/System.php

79 lines
2.4 KiB
PHP
Raw Normal View History

2021-08-06 18:50:55 +08:00
<?php
namespace app\controller\manager;
use app\service\Tool;
use app\model\{System as MSystem, Log};
use app\service\Image;
use think\facade\Cache;
class System extends Base
{
/**
* 获取当前系统设置
*
* @return void
*/
public function index()
{
if ($this->request->isPost()) {
$item = input('post.item/a');
$img = input('post.img');
$imgwechat_img = input('post.imgwechat_img');
$resume = input('post.fileresume');
$clause = input('post.fileclause');
$system = MSystem::getSystem();
if (empty($system)) {
if (!empty($img)) {
$item['mark_img'] = $img;
}
if (!empty($imgwechat_img)) {
$item['wechat_img'] = $imgwechat_img;
}
$system = MSystem::create($item);
Log::write('system', 'index', "系统设置ID{$system->id}");
} else {
if (!empty($img)) {
Image::delImg($system['mark_img']);
$item['mark_img'] = $img;
}
if (!empty($resume)){
$item['resume'] = $resume;
}
if (!empty($clause)){
$item['clause'] = $clause;
}
if (!empty($imgwechat_img)) {
$item['wechat_img'] = $imgwechat_img;
}
MSystem::update($item, ['id' => $system['id']]);
Log::write('system', 'index', "系统设置ID{$system['id']}");
}
return $this->json();
} else {
$item = MSystem::getSystem();
$positions = Image::getMarkPosition();
$this->data['item'] = $item;
$this->data['positions'] = $positions;
return $this->view();
}
}
public function other()
{
return $this->view();
}
public function clearCache()
{
Cache::clear();
$cachePath = app()->getRuntimePath() . 'cache';
$tempPath = app()->getRuntimePath() . 'temp';
Tool::removeByPath($cachePath);
Tool::removeByPath($tempPath);
clearstatcache();
return $this->json();
}
}