77 lines
1.8 KiB
PHP
77 lines
1.8 KiB
PHP
![]() |
<?php
|
|||
|
/**
|
|||
|
* 商城 cache 管理
|
|||
|
* 说明: 主要是一些说明、协议之类的文档管理
|
|||
|
*
|
|||
|
* @author:刘孝全
|
|||
|
* @email:q8197264@126.com
|
|||
|
* @date :2023年03月3日
|
|||
|
*/
|
|||
|
namespace app\admin\controller\merchant\system;
|
|||
|
|
|||
|
use app\admin\BaseController;
|
|||
|
use think\App;
|
|||
|
use app\common\model\merchant\system\Cache as CacheModel;
|
|||
|
|
|||
|
class Cache extends BaseController
|
|||
|
{
|
|||
|
protected $cache;
|
|||
|
|
|||
|
public function __construct(App $app, CacheModel $cache)
|
|||
|
{
|
|||
|
parent::__construct($app);
|
|||
|
$this->cache = $cache;
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
*
|
|||
|
*/
|
|||
|
public function getKeyLst()
|
|||
|
{
|
|||
|
$type = $this->request->param('type',0);
|
|||
|
$data = $this->cache->getAgreeList($type);
|
|||
|
|
|||
|
return to_assign(0,'',$data);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/**
|
|||
|
* @return mixed
|
|||
|
*/
|
|||
|
public function getAgree($key)
|
|||
|
{
|
|||
|
$allow = $this->cache->getAgreeKey();
|
|||
|
if (!in_array($key, $allow)) return app('json')->fail('数据不存在');
|
|||
|
$data = $this->cache->getResult($key);
|
|||
|
|
|||
|
return to_assign(0,'success', $data);
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* @return mixed
|
|||
|
*/
|
|||
|
public function saveAgree($key)
|
|||
|
{
|
|||
|
$allow = $this->cache->getAgreeKey();
|
|||
|
if (!in_array($key, $allow)) return app('json')->fail('KEY不存在');
|
|||
|
|
|||
|
$value = get_params('agree');
|
|||
|
$this->cache->saveCache($key, $value);
|
|||
|
|
|||
|
if ($key == CacheModel::USER_PRIVACY)
|
|||
|
$this->cache->setUserAgreement($value);
|
|||
|
if ($key == CacheModel::USER_AGREE)
|
|||
|
$this->cache->setUserRegister($value);
|
|||
|
|
|||
|
return to_assign(0, '保存成功');
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* TODO 清除缓存
|
|||
|
* @return \think\response\Json
|
|||
|
*/
|
|||
|
public function clearCache()
|
|||
|
{
|
|||
|
return to_assign(0,'清除缓存成功');
|
|||
|
}
|
|||
|
}
|