diff --git a/app/admin/controller/Category.php b/app/admin/controller/Category.php
index a1fa948..6a73011 100644
--- a/app/admin/controller/Category.php
+++ b/app/admin/controller/Category.php
@@ -2,6 +2,7 @@
namespace app\admin\controller;
+use app\common\constant\Config;
use app\common\model\DocumentCategory as aModel;
use app\common\model\DocumentCategoryContent;
use app\Request;
@@ -87,6 +88,7 @@ class Category extends AuthController
$res = DocumentCategoryContent::update(['content'=>$content],['id'=>$id]);
}
}
+ cache(Config::DATA_DOCUMENT_CATEGORY_LIST,null);
return $res ? app("json")->success("操作成功",'code') : app("json")->fail("操作失败");
}
@@ -100,7 +102,8 @@ class Category extends AuthController
if (!$id) return app("json")->fail("参数有误,Id为空!");
$where = Util::postMore([['field',''],['value','']]);
if ($where['field'] == '' || $where['value'] =='') return app("json")->fail("参数有误!");
- return aModel::update([$where['field']=>$where['value']],['id'=>$id]) ? app("json")->success("操作成功") : app("json")->fail("操作失败");
+ cache(Config::DATA_DOCUMENT_CATEGORY_LIST,null);
+ return aModel::update([$where['field']=>$where['value']],['id'=>$id]) ? app("json")->success("操作成功",'code') : app("json")->fail("操作失败");
}
/**
@@ -176,6 +179,7 @@ class Category extends AuthController
$model = new aModel();
$model->where('id',$where['id'])->delete();
$res = DocumentCategoryContent::where('id',$where['id'])->delete();
+ cache(Config::DATA_DOCUMENT_CATEGORY_LIST,null);
return $res ? app("json")->success("操作成功",'code') : app("json")->fail("操作失败");
}
}
\ No newline at end of file
diff --git a/app/admin/controller/FriendLink.php b/app/admin/controller/FriendLink.php
index 85ee44a..7420627 100644
--- a/app/admin/controller/FriendLink.php
+++ b/app/admin/controller/FriendLink.php
@@ -2,6 +2,7 @@
namespace app\admin\controller;
+use app\common\constant\Config;
use app\common\model\FriendLink as aModel;
use app\admin\service\FormBuilderService as Form;
use app\Request;
@@ -123,6 +124,7 @@ class FriendLink extends AuthController
$data['uid'] = $this->adminId;
$res = aModel::update($data,['id'=>$id]);
}
+ cache(Config::DATA_FRIEND_LINK,null);//清除缓存
return $res ? app("json")->success("操作成功",'code') : app("json")->fail("操作失败");
}
@@ -138,6 +140,7 @@ class FriendLink extends AuthController
if (!$id) return app("json")->fail("参数有误,Id为空!");
$where = Util::postMore([['field',''],['value','']]);
if ($where['field'] == '' || $where['value'] =='') return app("json")->fail("参数有误!");
+ cache(Config::DATA_FRIEND_LINK,null);//清除缓存
return aModel::update([$where['field']=>$where['value']],['id'=>$id]) ? app("json")->success("操作成功") : app("json")->fail("操作失败");
}
}
\ No newline at end of file
diff --git a/app/admin/controller/Poster.php b/app/admin/controller/Poster.php
index 7bd1866..a57f346 100644
--- a/app/admin/controller/Poster.php
+++ b/app/admin/controller/Poster.php
@@ -3,6 +3,7 @@
namespace app\admin\controller;
use app\admin\service\FormBuilderService as Form;
+use app\common\constant\Config;
use app\common\model\Advert as aModel;
use app\Request;
use app\admin\service\UtilService as Util;
@@ -144,6 +145,7 @@ class Poster extends AuthController
}else {
$res = aModel::update($data,['id'=>$id]);
}
+ cache(Config::DATA_ADVERT.'_'.$data['type'],null);//清除缓存
return $res ? app("json")->success("操作成功",'code') : app("json")->fail("操作失败");
}
}
\ No newline at end of file
diff --git a/app/admin/controller/Slides.php b/app/admin/controller/Slides.php
index 48d4d3a..597209f 100644
--- a/app/admin/controller/Slides.php
+++ b/app/admin/controller/Slides.php
@@ -2,6 +2,7 @@
namespace app\admin\controller;
+use app\common\constant\Config;
use app\common\model\Slides as aModel;
use app\admin\service\FormBuilderService as Form;
use app\Request;
@@ -120,6 +121,7 @@ class Slides extends AuthController
}else {
$res = aModel::update($data,['id'=>$id]);
}
+ cache(Config::DATA_BANNER,null);//清除缓存
return $res ? app("json")->success("操作成功",'code') : app("json")->fail("操作失败");
}
}
\ No newline at end of file
diff --git a/app/admin/controller/SystemConfig.php b/app/admin/controller/SystemConfig.php
index 2471f1c..df93d44 100644
--- a/app/admin/controller/SystemConfig.php
+++ b/app/admin/controller/SystemConfig.php
@@ -2,6 +2,7 @@
namespace app\admin\controller;
+use app\common\constant\Config;
use app\common\model\SystemConfig as cModel;
use app\common\model\SystemConfigTab as tModel;
use app\Request;
@@ -184,7 +185,7 @@ class SystemConfig extends AuthController
$res = cModel::update($data,['id'=>$id]);
}
//修改完需要更新缓存
- cache('systemConfig',null);//清除缓存
+ cache(Config::DATA_SYSTEM_CONFIG,null);//清除缓存
return $res ? app("json")->success("操作成功",'code') : app("json")->fail("操作失败");
}
@@ -197,7 +198,7 @@ class SystemConfig extends AuthController
{
try {
foreach ($request->param() as $k => $v) cModel::editValueByFormName($k,$v);
- cache('systemConfig',null);//清除缓存
+ cache(Config::DATA_SYSTEM_CONFIG,null);//清除缓存
return app("json")->success("操作成功");
}catch (\Exception $e)
{
diff --git a/app/admin/controller/Theme.php b/app/admin/controller/Theme.php
index 0f3a4d9..53911c7 100644
--- a/app/admin/controller/Theme.php
+++ b/app/admin/controller/Theme.php
@@ -64,7 +64,7 @@ class Theme extends AuthController
]);
if ($data['value'] == "") return app("json")->fail("主题不能为空");
$res = cModel::update($data,['form_name'=>'web_template']);
- cache('systemConfig',null);//清除缓存
+ cache(Config::DATA_SYSTEM_CONFIG,null);//清除缓存
return $res ? app("json")->success("操作成功",'code') : app("json")->fail("操作失败");
}
}
\ No newline at end of file
diff --git a/app/admin/view/article/edit.html b/app/admin/view/article/edit.html
index b2ee8e7..1d018e5 100644
--- a/app/admin/view/article/edit.html
+++ b/app/admin/view/article/edit.html
@@ -93,7 +93,7 @@
推荐
@@ -102,7 +102,7 @@
热门
@@ -111,7 +111,7 @@
顶置
@@ -120,7 +120,7 @@
显示
diff --git a/app/admin/view/category/index.html b/app/admin/view/category/index.html
index b635e8f..51438e8 100644
--- a/app/admin/view/category/index.html
+++ b/app/admin/view/category/index.html
@@ -77,21 +77,17 @@
showColumns: true, // 是否显示所有的列
showRefresh: true, // 是否显示刷新按钮
columns: [
- // {
- // field: 'check',
- // checkbox: true
- // },
- {
- field: 'title',
- title: '名称',
- },
{
field: 'id',
title: 'ID',
},
+ {
+ field: 'title',
+ title: '名称',
+ },
{
field: 'display',
- title: '可见性',
+ title: '是否可见',
formatter: function (value, row, index) {
if (value == 0) {
is_checked = '';
@@ -141,7 +137,7 @@
});
},
'click .category-edit': function (e, value, row, index) {
- iframe.createIframe('修改分类','/admin/category/edit?id='+row.id)
+ location.href = '/admin/category/edit?id='+row.id;
}
},
formatter: operateFormatter
@@ -184,10 +180,10 @@
// 操作按钮
function operateFormatter(value, row, index) {
return [
- '',
+ '',
+ '',
+ '',
'',
- '',
- ''
].join('');
}
diff --git a/app/common.php b/app/common.php
index 31efc1c..0657415 100644
--- a/app/common.php
+++ b/app/common.php
@@ -1,5 +1,6 @@
order('sort asc')->select()->toArray();
+ $documentCategoryList = DocumentCategory::where('status', 1)->order('sort asc')->select()->toArray();
//转换,让id作为数组的键
$documentCategory = [];
foreach ($documentCategoryList as $key => $item) {
@@ -60,7 +59,7 @@ function get_document_category_list()
$item['url'] = curl($item);
$documentCategory[$item['id']] = $item;
}
- cache('DATA_DOCUMENT_CATEGORY_LIST', $documentCategory);
+ cache(Config::DATA_DOCUMENT_CATEGORY_LIST, $documentCategory);
}
return $documentCategory;
}
@@ -122,7 +121,7 @@ function tpl_get_channel($type, $typeid, $row = 100, $where = '', $orderby = '',
switch ($type) {
case "all":
//获取顶级分类
- return get_document_category_all(0, $row, $display);
+ return get_document_category_all($display);
break;
case 'top':
//获取顶级分类
@@ -155,7 +154,7 @@ function tpl_get_channel($type, $typeid, $row = 100, $where = '', $orderby = '',
if (!$dc) {
throw new Exception('分类不存在或已删除!');
}
- $tempArr = \app\common\model\DocumentCategory::where('id', 'in', $dc['child'])->where('status', 1)->limit($row);
+ $tempArr = DocumentCategory::where('id', 'in', $dc['child'])->where('status', 1)->limit($row);
if ($display) {
$tempArr = $tempArr->where('display', 1);
}
@@ -185,7 +184,7 @@ function tpl_get_channel($type, $typeid, $row = 100, $where = '', $orderby = '',
$dc = get_document_category($typeid);
if ($dc['pid'] != 0) {
//获取根分类,此操作读取数据库,非缓存!
- $dc = \app\common\model\DocumentCategory::where('pid', 0)->where('status', 1)
+ $dc = DocumentCategory::where('pid', 0)->where('status', 1)
->where("CONCAT(',',child,',') like '%,$typeid,%'")->limit($row);
if ($display) {
$dc = $dc->where('display', 1);
@@ -202,7 +201,7 @@ function tpl_get_channel($type, $typeid, $row = 100, $where = '', $orderby = '',
break;
case 'where':
//根据自定义条件获取分类(where语句),此操作读取数据库,非缓存!
- $tempArr = \app\common\model\DocumentCategory::where('status', 1)->where($where)->order($orderby)->limit($row);
+ $tempArr = DocumentCategory::where('status', 1)->where($where)->order($orderby)->limit($row);
if ($display) {
$tempArr = $tempArr->where('display', 1);
}
@@ -216,7 +215,7 @@ function tpl_get_channel($type, $typeid, $row = 100, $where = '', $orderby = '',
break;
case 'ids':
//根据多个栏目id,逗号隔开的那种,获得栏目列表
- $tempArr = \app\common\model\DocumentCategory::where('status', 1)->where('id', 'in', $typeid)->order($orderby)->limit($row);
+ $tempArr = DocumentCategory::where('status', 1)->where('id', 'in', $typeid)->order($orderby)->limit($row);
if ($display) {
$tempArr = $tempArr->where('display', 1);
}
@@ -288,7 +287,7 @@ function tpl_get_prenext($get, $cid = false, $none)
$get = 'next';
}
- $document = \app\common\model\Document::where('display', 1)->where('status', 1);
+ $document = Document::where('display', 1)->where('status', 1);
$document = $get == 'pre' ? $document->where("id", '<', $id) : $document->where("id", '>', $id);
//如果表明在同一分类下查询
@@ -320,7 +319,7 @@ function tpl_get_prenext($get, $cid = false, $none)
function tpl_get_list($orderby, $pagesize, $cid, $type, $table = 'article', $where = false, $display = 1)
{
- $documentListModel = (new \app\common\model\Document())
+ $documentListModel = (new Document())
->alias('a')
->join(config('database.prefix') . 'document_category b', 'a.category_id=b.id', 'LEFT')
->join(config('database.prefix') . "document_$table c", 'a.id=c.id', 'LEFT')
@@ -439,7 +438,7 @@ function aurl($item)
*/
function tpl_get_article($id, $table)
{
- $documentModel = \app\common\model\Document::alias('a')
+ $documentModel = Document::alias('a')
->join(config('database.prefix') . 'document_category b', 'a.category_id=b.id', 'LEFT')
->join(config('database.prefix') . "document_$table c", 'a.id=c.id', 'LEFT')
->where('a.status', 1)->where('a.id', $id)->where("a.type='$table'")
@@ -469,7 +468,7 @@ function tpl_get_article($id, $table)
function tpl_get_article_list($cid, $row, $orderby, $table = 'article', $type = 'son', $where = false, $display = 1, $ids = '')
{
- $documentListModel = \app\common\model\Document::alias('a')
+ $documentListModel = Document::alias('a')
->join(config('database.prefix') . 'document_category b', 'a.category_id=b.id', 'LEFT')
->join(config('database.prefix') . "document_$table c", 'a.id=c.id', 'RIGHT')
->where("a.type='$table'")->where('a.status', 1)->where('b.status', 1)
@@ -538,10 +537,10 @@ function tpl_get_product_list($cid, $row, $orderby, $table = 'article', $type =
*/
function tpl_get_friend_link($type, $row)
{
- $flinkList = cache('DATA_FRIEND_LINK');
+ $flinkList = cache(Config::DATA_FRIEND_LINK);
if ($flinkList === null) {
- $flinkList = \app\common\model\FriendLink::where('status', 1)->order('sort asc')->limit($row)->select();
- cache('DATA_FRIEND_LINK', $flinkList);
+ $flinkList = FriendLink::where('status', 1)->order('sort asc')->limit($row)->select();
+ cache(Config::DATA_FRIEND_LINK, $flinkList);
}
if ($type === 0) {
return $flinkList;
@@ -560,10 +559,10 @@ function tpl_get_friend_link($type, $row)
*/
function tpl_get_banner($type, $row)
{
- $bannerList = cache('DATA_BANNER');
+ $bannerList = cache(Config::DATA_BANNER);
if ($bannerList === null) {
$bannerList = Db::name('slides')->where('status', 1)->order('sort asc')->limit($row)->select();
- cache('DATA_BANNER', $bannerList);
+ cache(Config::DATA_BANNER, $bannerList);
}
if ($type === 0) {
return $bannerList;
@@ -608,24 +607,20 @@ function tpl_get_advert($type, $row)
return $advertListTemp;
}
-
if (!function_exists('web_config')) {
/**
* 获取系统配置值
* @param string $formName
* @return string
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
* @author 李玉坤
- * @date 2021-02-14 22:41
+ * @date 2021-11-12 0:34
*/
function web_config(string $formName): string
{
- $webConfig = cache('systemConfig');
+ $webConfig = cache(Config::DATA_SYSTEM_CONFIG);
if (empty($webConfig)) {
$webConfig = Db::name('system_config')->where("status", 1)->column('value', 'form_name');
- cache('systemConfig', $webConfig);
+ cache(Config::DATA_SYSTEM_CONFIG, $webConfig);
}
return $webConfig[$formName] ?? '';
}
@@ -633,6 +628,10 @@ if (!function_exists('web_config')) {
/**
* 模板-文章标签
+ * @param $tags
+ * @return array|bool
+ * @author 李玉坤
+ * @date 2021-11-12 0:34
*/
function tpl_get_tags_list($tags)
{
@@ -756,7 +755,7 @@ function IsActiveNav($curr_cid = false, $cid = false)
}
//判断是否在同一栏目树下。
- $parent_id = cache('curr_category_patent_id');
+ $parent_id = cache(Config::CURR_CATEGORY_PATENT_ID);
$parent_id = explode(',', $parent_id);
diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php
index d646535..a38cd3c 100644
--- a/app/index/controller/Article.php
+++ b/app/index/controller/Article.php
@@ -8,6 +8,7 @@ use app\common\model\Comment as commentModel;
use app\common\model\Tag as TagModel;
use app\Request;
use think\facade\Log;
+use app\common\constant\Config;
/**
* 应用入口
@@ -89,7 +90,7 @@ class Article extends Base
//当前页面所属分类id
$this->assign('cid',$id);
//缓存当前页面栏目分类树ids
- cache('curr_category_patent_id',$dc['pid']?$dc['pid'].','.$id:$id);
+ cache(Config::CURR_CATEGORY_PATENT_ID,$dc['pid']?$dc['pid'].','.$id:$id);
//去除后缀
$listTmp = substr($listTmp,0,strpos($listTmp,'.'));
return $this->fetch('category/'.$listTmp);
@@ -155,7 +156,7 @@ class Article extends Base
//当前页面所属分类id
$this->assign('cid',$article['category_id']);
//缓存当前页面栏目分类树ids
- cache('CURR_CATEGORY_PATENT_ID',$dc['pid']?$dc['pid'].','.$article['category_id']:$article['category_id']);
+ cache(Config::CURR_CATEGORY_PATENT_ID,$dc['pid']?$dc['pid'].','.$article['category_id']:$article['category_id']);
//设置文章的url
$article['link_str']=aurl($article);
//判断后台统计配置是否开启 1 开启
@@ -227,7 +228,7 @@ class Article extends Base
$this->assign('tag',$tag);
//清除可能存在的栏目分类树id
- cache('curr_category_patent_id',false);
+ cache(Config::CURR_CATEGORY_PATENT_ID,false);
//模板兼容性标签
$this->assign('id',false);
$this->assign('cid',false);
@@ -284,7 +285,7 @@ class Article extends Base
$this->assign('apeField',$apeField);
$this->assign('kw',$kw);
//清除可能存在的栏目分类树id
- cache('curr_category_patent_id',false);
+ cache(Config::CURR_CATEGORY_PATENT_ID,false);
//模板兼容性标签
$this->assign('id',false);
$this->assign('cid',false);