修正报错

增加统计代码支持
This commit is contained in:
muzi_ys 2022-11-30 11:41:51 +08:00
parent 172cfd9f3f
commit 5e21c27aae
10 changed files with 53 additions and 67 deletions

View File

@ -5,7 +5,7 @@ namespace app\admin\controller;
use app\admin\extend\Util as Util;
use app\common\model\Comment as CommentModel;
use app\common\model\Document;
use app\common\model\Category as cModel;
use app\common\model\DocumentCategory as cModel;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;

View File

@ -4,7 +4,7 @@ namespace app\admin\controller;
use app\admin\extend\Util as Util;
use app\common\constant\Data;
use app\common\model\Category as aModel;
use app\common\model\DocumentCategory as aModel;
use app\Request;
use Exception;
use think\db\exception\DataNotFoundException;

View File

@ -5,8 +5,8 @@ namespace app\admin\controller;
use app\common\model\AdminAuth;
use app\common\model\Document;
use app\common\model\Document as DocumentModel;
use app\common\model\Category;
use app\common\model\Category as DocumentCategoryModel;
use app\common\model\DocumentCategory;
use app\common\model\DocumentCategory as DocumentCategoryModel;
use app\common\model\FriendLink;
use app\common\model\MessageForm;
use app\common\model\AdminNotify;

View File

@ -40,7 +40,7 @@ class Document extends BaseModel
$model = $model->order("sort desc")->order("id desc");
$count = self::counts($model);
if ($where['page'] && $where['limit']) $model = $model->page((int)$where['page'], (int)$where['limit']);
$categoryList = Category::column('title', 'id');
$categoryList = DocumentCategory::column('title', 'id');
$data = $model->select()->each(function ($item) use ($categoryList) {
$item->category_title = $categoryList[$item->category_id] ?? "";
});

View File

@ -13,7 +13,7 @@ use think\db\exception\ModelNotFoundException;
* @author 木子的忧伤
* @date 2021-02-15 23:22
*/
class Category extends BaseModel
class DocumentCategory extends BaseModel
{
/**
* 列表

View File

@ -3,7 +3,7 @@
use app\common\constant\Data;
use app\common\model\Comment;
use app\common\model\Document;
use app\common\model\Category;
use app\common\model\DocumentCategory;
use app\common\model\Advert;
use app\common\model\FriendLink;
use app\common\model\Tag;
@ -44,7 +44,7 @@ function get_document_category_list()
//缓存文章菜单
$documentCategory = cache(Data::DATA_DOCUMENT_CATEGORY_LIST);
if ($documentCategory === null) {
$documentCategoryList = Category::where('status', 1)->order('sort asc')->select()->toArray();
$documentCategoryList = DocumentCategory::where('status', 1)->order('sort asc')->select()->toArray();
//转换让id作为数组的键
$documentCategory = [];
foreach ($documentCategoryList as $item) {
@ -112,7 +112,7 @@ function get_document_category_by_name($name, $field = false)
* @param int $row
* @param string $where
* @param string $orderby
* @return Category[]|array|bool|Collection
* @return DocumentCategory[]|array|bool|Collection
* @throws Exception
* @throws DataNotFoundException
* @throws DbException
@ -158,7 +158,7 @@ function tpl_get_channel($type, $typeId, $row = 100, $where = '', $orderby = '')
if (!$dc) {
throw new Exception('分类不存在或已删除!');
}
$tempArr = Category::where('id', 'in', $dc['child'])->where('status', 1)->limit($row);
$tempArr = DocumentCategory::where('id', 'in', $dc['child'])->where('status', 1)->limit($row);
$tempArr = $tempArr->select();
foreach ($tempArr as $key => $item) {
//根据栏目类型生成栏目url
@ -185,7 +185,7 @@ function tpl_get_channel($type, $typeId, $row = 100, $where = '', $orderby = '')
$dc = get_document_category($typeId);
if ($dc['pid'] != 0) {
//获取根分类,此操作读取数据库,非缓存!
$dc = Category::where('pid', 0)->where('status', 1)
$dc = DocumentCategory::where('pid', 0)->where('status', 1)
->where("CONCAT(',',child,',') like '%,$typeId,%'")->limit($row);
$dc = $dc->find();
}
@ -197,7 +197,7 @@ function tpl_get_channel($type, $typeId, $row = 100, $where = '', $orderby = '')
break;
case 'where':
//根据自定义条件获取分类where语句此操作读取数据库非缓存
$tempArr = Category::where('status', 1)->where($where)->order($orderby)->limit($row);
$tempArr = DocumentCategory::where('status', 1)->where($where)->order($orderby)->limit($row);
$tempArr = $tempArr->select();
foreach ($tempArr as $key => $item) {
//根据栏目类型生成栏目url
@ -208,7 +208,7 @@ function tpl_get_channel($type, $typeId, $row = 100, $where = '', $orderby = '')
break;
case 'ids':
//根据多个栏目id逗号隔开的那种获得栏目列表
$tempArr = Category::where('status', 1)->where('id', 'in', $typeId)->order($orderby)->limit($row);
$tempArr = DocumentCategory::where('status', 1)->where('id', 'in', $typeId)->order($orderby)->limit($row);
$tempArr = $tempArr->select();
foreach ($tempArr as $key => $item) {
//根据栏目类型生成栏目url
@ -1038,7 +1038,7 @@ function comment_face($incoming_comment,$path)
* @param int $row
* @param string $where
* @param string $orderby
* @return Category[]|array|bool|Collection
* @return DocumentCategory[]|array|bool|Collection
* @throws Exception
* @throws DataNotFoundException
* @throws DbException

View File

@ -6,7 +6,7 @@ use app\admin\extend\Util as Util;
use app\common\constant\Data;
use app\common\model\Comment as commentModel;
use app\common\model\Document;
use app\common\model\Category;
use app\common\model\DocumentCategory;
use app\Request;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
@ -50,7 +50,7 @@ class Article extends Base
}
//赋值分类id可能是通过栏目分类id获取的栏目分类数据
$id = $dc['id'];
$documentCategoryModel = new Category();
$documentCategoryModel = new DocumentCategory();
//栏目存在 增加访问量
$documentCategoryModel->where('id|alias', $id)->inc('view')->update();
//判断后台统计配置是否开启 1 开启

View File

@ -11,7 +11,7 @@
Target Server Version : 50726
File Encoding : 65001
Date: 27/11/2022 00:02:52
Date: 30/11/2022 11:40:29
*/
SET NAMES utf8mb4;
@ -128,15 +128,11 @@ CREATE TABLE `ape_admin_log` (
`user_agent` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT 'User-Agent',
`create_time` int(10) NOT NULL DEFAULT 0 COMMENT '操作时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '操作日志表' ROW_FORMAT = DYNAMIC;
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '操作日志表' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of ape_admin_log
-- ----------------------------
INSERT INTO `ape_admin_log` VALUES (1, 1, 'admin', 'admin', 'index', 'main', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.53', 1669478531);
INSERT INTO `ape_admin_log` VALUES (2, 1, 'admin', 'admin', 'admin', 'index', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.53', 1669478536);
INSERT INTO `ape_admin_log` VALUES (3, 1, 'admin', 'admin', 'admin_auth', 'index', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.53', 1669478536);
INSERT INTO `ape_admin_log` VALUES (4, 1, 'admin', 'admin', 'admin_role', 'index', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.53', 1669478537);
-- ----------------------------
-- Table structure for ape_admin_notify
@ -273,35 +269,6 @@ CREATE TABLE `ape_attachment_category` (
-- Records of ape_attachment_category
-- ----------------------------
-- ----------------------------
-- Table structure for ape_category
-- ----------------------------
DROP TABLE IF EXISTS `ape_category`;
CREATE TABLE `ape_category` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '标题',
`alias` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '标志',
`icon` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '分类图标',
`pid` int(10) NOT NULL DEFAULT 0 COMMENT '上级分类ID',
`sort` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '排序(同级有效)',
`meta_title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'SEO的网页标题',
`keywords` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '关键字',
`description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '描述',
`status` tinyint(2) NOT NULL DEFAULT 1 COMMENT '是否显示',
`template` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '分类模板',
`view` int(10) NOT NULL DEFAULT 0 COMMENT '访问数',
`create_time` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `alias`(`alias`) USING BTREE COMMENT '别名URl',
INDEX `t_p_s`(`title`, `pid`, `status`) USING BTREE COMMENT '标题'
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '分类表' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of ape_category
-- ----------------------------
INSERT INTO `ape_category` VALUES (1, '编程资料', '01df859b', '', 0, 99, '编程资料', '关于小站,源码云,源码云博客,关于源码云博客', '讲述的是傲娇天才酒评家陆微寻和元气失味少女何不醉因意外亲吻发生味觉互换,携手寻味觅爱的浪漫爱情故事。画风截然不同的二人因一场意外亲吻交换了味觉,从而开始了啼笑皆非又温馨浪漫的寻味之旅,在这个过程中他们互相了解,彼此影响,最终收获了味觉和爱情。', 1, 'list_default.html', 0, 0, 0);
-- ----------------------------
-- Table structure for ape_comment
-- ----------------------------
@ -361,12 +328,11 @@ CREATE TABLE `ape_document` (
UNIQUE INDEX `alias`(`alias`) USING BTREE,
INDEX `idx_category_status`(`category_id`, `status`) USING BTREE,
INDEX `idx_status_type_pid`(`status`, `uid`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '文档模型基础表' ROW_FORMAT = DYNAMIC;
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '文档模型基础表' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of ape_document
-- ----------------------------
INSERT INTO `ape_document` VALUES (1, 'about', 1, '超级管理员', '关于', 0, '/storage/image/20220710/4f392482c34a194fe8e7fb9b6da95ae9.png', 'page', 'article.html', 0, 0, 0, '', 0, 1, 10, '', '源码云BLOG源码云博客是一款基于ThinkPHP6 + bootstrap+ MySql打造的简单实用的开源免费的博客系统。各管理模块操作简单具有简约易用访问统计内存占用低等特点系统易', '', '', 99, '2022-07-10', 1657464554, 1657464554, 1, '');
-- ----------------------------
-- Table structure for ape_document_article
@ -381,16 +347,35 @@ CREATE TABLE `ape_document_article` (
-- ----------------------------
-- Records of ape_document_article
-- ----------------------------
INSERT INTO `ape_document_article` VALUES (0, '<p>阿萨大大大大大大大大大大大大大大大大大</p><p><br></p><p>dasdasdsaa</p><p><br></p><p>asdddddddddddddd</p>');
INSERT INTO `ape_document_article` VALUES (2, '<p>饿哇日日日日日日日日日日日日日日日</p>');
INSERT INTO `ape_document_article` VALUES (7, '<p>32423<br></p><p>32</p><p>423</p><p>423</p><p>4</p><p>2</p><p>34</p><p>2</p><p>34</p>');
INSERT INTO `ape_document_article` VALUES (8, '<p>21321312</p>');
INSERT INTO `ape_document_article` VALUES (9, '<p>2111111111111111111111</p>');
INSERT INTO `ape_document_article` VALUES (10, '<p>324324234</p>');
INSERT INTO `ape_document_article` VALUES (11, '<p>23423</p>');
INSERT INTO `ape_document_article` VALUES (12, '<p>撒旦撒旦</p>');
INSERT INTO `ape_document_article` VALUES (16, '<p>认为人</p>');
INSERT INTO `ape_document_article` VALUES (17, '<p>23123</p>');
-- ----------------------------
-- Table structure for ape_document_category
-- ----------------------------
DROP TABLE IF EXISTS `ape_document_category`;
CREATE TABLE `ape_document_category` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '标题',
`alias` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '标志',
`icon` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '分类图标',
`pid` int(10) NOT NULL DEFAULT 0 COMMENT '上级分类ID',
`sort` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '排序(同级有效)',
`meta_title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'SEO的网页标题',
`keywords` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '关键字',
`description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '描述',
`status` tinyint(2) NOT NULL DEFAULT 1 COMMENT '是否显示',
`template` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '分类模板',
`view` int(10) NOT NULL DEFAULT 0 COMMENT '访问数',
`create_time` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `alias`(`alias`) USING BTREE COMMENT '别名URl',
INDEX `t_p_s`(`title`, `pid`, `status`) USING BTREE COMMENT '标题'
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '分类表' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of ape_document_category
-- ----------------------------
INSERT INTO `ape_document_category` VALUES (1, '编程资料', '01df859b', '', 0, 99, '编程资料', '关于小站,源码云,源码云博客,关于源码云博客', '讲述的是傲娇天才酒评家陆微寻和元气失味少女何不醉因意外亲吻发生味觉互换,携手寻味觅爱的浪漫爱情故事。画风截然不同的二人因一场意外亲吻交换了味觉,从而开始了啼笑皆非又温馨浪漫的寻味之旅,在这个过程中他们互相了解,彼此影响,最终收获了味觉和爱情。', 1, 'list_default.html', 0, 0, 0);
-- ----------------------------
-- Table structure for ape_document_page
@ -545,7 +530,7 @@ CREATE TABLE `ape_system_config` (
`tag_type` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '标签类型',
`upload_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '上传配置',
`param` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '参数',
`value` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '内容',
`value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '内容',
`remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '备注',
`rank` tinyint(2) NOT NULL DEFAULT 0 COMMENT '排序',
`is_show` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '是否显示',
@ -569,7 +554,7 @@ INSERT INTO `ape_system_config` VALUES (6, 1, '站点logo', 'logo', 'file', 'inp
INSERT INTO `ape_system_config` VALUES (7, 1, '版权信息', 'copyright', 'text', 'input', 0, '', 'Copyright © 2022 apeBlog Powered by 源码云博客', '', 93, 1, 1, '1', '1', 1582793470, 1582793495);
INSERT INTO `ape_system_config` VALUES (8, 1, '备案信息', 'icp', 'text', 'textarea', 0, '', '<a href=\"http://beian.miit.gov.cn\">京ICP备19038953号</a> | <a target=\"_blank\" href=\"http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=62062102000138\">甘公网安备62062102000138号</a>', '', 92, 1, 1, '1', '1', 1582793563, 1583375542);
INSERT INTO `ape_system_config` VALUES (10, 1, '网站域名', 'domain', 'text', 'input', 0, '', 'http://apeblog.io', '', 90, 1, 1, '1', '1', 1588858018, 1582792265);
INSERT INTO `ape_system_config` VALUES (11, 1, '网站统计代码', 'statistics', 'text', 'textarea', 0, '', '', '', 89, 1, 1, '1', '1', 1582793470, 1582793495);
INSERT INTO `ape_system_config` VALUES (11, 1, '网站统计代码', 'statistics', 'text', 'textarea', 0, '', '<script>var _hmt = _hmt || [];\r\n(function() {\r\n var hm = document.createElement(\"script\");\r\n hm.src = \"https://hm.baidu.com/hm.js?df245a474077d4239ad5932ba71377b9\";\r\n var s = document.getElementsByTagName(\"script\")[0]; \r\n s.parentNode.insertBefore(hm, s);\r\n})();</script>', '', 89, 1, 1, '1', '1', 1582793470, 1582793495);
INSERT INTO `ape_system_config` VALUES (12, 1, '主题信息', 'web_template', 'select', 'input', 0, 'default=>默认\nnew=>新bolg', 'default', '', 88, 1, 1, '1', '1', 1582793563, 1620610858);
INSERT INTO `ape_system_config` VALUES (13, 1, '关闭网站', 'web_close', 'radio', 'input', 0, '1=>是\n0=>否', '0', '', 87, 1, 1, '1', '1', 1583126643, 1582792265);
INSERT INTO `ape_system_config` VALUES (14, 1, '网站统计', 'web_statistics', 'radio', 'input', 0, '1=>开启\n0=>关闭', '1', '', 86, 1, 1, '1', '1', 1583126643, 1582792265);

View File

@ -286,7 +286,7 @@ switch ($step) {
, 'ape_document'
, 'ape_document_article'
, 'ape_document_category'
, 'ape_document_category_content'
, 'ape_document_page'
, 'ape_document_product'
, 'ape_friend_link'
, 'ape_invitation_code'

View File

@ -89,4 +89,5 @@
</div>
</div>
</div>
</footer>
</footer>
{:web_config('statistics')}