diff --git a/app/admin/controller/AdminNotify.php b/app/admin/controller/AdminNotify.php index b84e299..a774772 100644 --- a/app/admin/controller/AdminNotify.php +++ b/app/admin/controller/AdminNotify.php @@ -25,7 +25,7 @@ class AdminNotify extends AuthController ['start_time', ''], ['end_time', ''], ['is_read', ''], - ['aid', $this->adminId], + ['uid', $this->adminId], ]); $this->assign("where", $where); $this->assign("list", nModel::systemPage($where)); diff --git a/app/admin/controller/Article.php b/app/admin/controller/Article.php index 6149523..46da842 100644 --- a/app/admin/controller/Article.php +++ b/app/admin/controller/Article.php @@ -88,7 +88,7 @@ class Article extends AuthController ['is_recommend', 0], ['is_top', 0], ['is_hot', 0], - ['theme', 'detail.html'], + ['template', 'detail.html'], ['link_str', ''], ['is_jump', 0], ['cover_path', ''], diff --git a/app/admin/controller/Index.php b/app/admin/controller/Index.php index 92bed9e..77902e6 100644 --- a/app/admin/controller/Index.php +++ b/app/admin/controller/Index.php @@ -19,7 +19,7 @@ class Index extends AuthController { $this->assign("adminInfo", $this->adminInfo); $this->assign("menu", AdminAuth::getAuthList($this->adminId,$this->auth)); - $this->assign("message", AdminNotify::pageList(5)); + $this->assign("message", AdminNotify::pageList($this->adminId,5)); return $this->fetch(); } diff --git a/app/admin/model/AdminNotify.php b/app/admin/model/AdminNotify.php index f829842..9c55a91 100644 --- a/app/admin/model/AdminNotify.php +++ b/app/admin/model/AdminNotify.php @@ -31,7 +31,7 @@ class AdminNotify extends BaseModel } if ($where['title'] != '') $model = $model->where("title|content", "like", "%$where[title]%"); if ($where['is_read'] != '') $model = $model->where("is_read", $where['is_read']); - if ($where['aid'] != '') $model = $model->where("aid", $where['aid']); + if ($where['uid'] != '') $model = $model->where("uid", $where['uid']); $model = $model->order("is_read"); $model = $model->order("create_time desc"); return $model->paginate(10)->appends($where); @@ -53,16 +53,17 @@ class AdminNotify extends BaseModel /** * 后台首页获取通知信息 + * @param $uid * @param int $num * @return array * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException */ - public static function pageList(int $num): array + public static function pageList($uid,int $num): array { $model = new self; - $model = $model->where("is_read", 0); + $model = $model->where("is_read", 0)->where("uid",$uid); $count = self::count(); $model = $model->order("create_time desc"); $model = $model->page(1, $num); diff --git a/app/common/model/Document.php b/app/common/model/Document.php index 1059c59..2a5172a 100644 --- a/app/common/model/Document.php +++ b/app/common/model/Document.php @@ -87,11 +87,9 @@ class Document extends BaseModel /** * 更新文件信息 - * @param $date + * @param $data * @param string $type - * @throws DataNotFoundException - * @throws DbException - * @throws ModelNotFoundException + * @return bool */ public function updateInfo($data, string $type = Data::DOCUMENT_TYPE_ARTICLE) { diff --git a/app/common/model/Message.php b/app/common/model/Message.php new file mode 100644 index 0000000..aa0f2ae --- /dev/null +++ b/app/common/model/Message.php @@ -0,0 +1,72 @@ +where("create_time", "between", [strtotime($where['start_time'] . " 00:00:00"), strtotime($where['end_time'] . " 23:59:59")]); + } + if ($where['title'] != '') $model = $model->where("title|content", "like", "%$where[title]%"); + if ($where['is_read'] != '') $model = $model->where("is_read", $where['is_read']); + if ($where['uid'] != '') $model = $model->where("aid", $where['aid']); + $model = $model->order("is_read"); + $model = $model->order("create_time desc"); + return $model->paginate(10)->appends($where); + } + + /** + * 添加记录 + * @param array $data + * @return int|string + */ + public static function addLog(array $data): bool + { + if (self::create($data)){ + return true; + }else{ + return false; + } + } + + /** + * 后台首页获取通知信息 + * @param int $num + * @return array + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException + */ + public static function pageList(int $num): array + { + $model = new self; + $model = $model->where("is_read", 0); + $count = self::count(); + $model = $model->order("create_time desc"); + $model = $model->page(1, $num); + $data = $model->select(); + if ($data) $data = $data->toArray(); + return compact("data", "count"); + } +} \ No newline at end of file diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php index c68fdf4..38920e0 100644 --- a/app/index/controller/Article.php +++ b/app/index/controller/Article.php @@ -126,7 +126,7 @@ class Article extends Base //更新浏览次数 $documentModel->where('id', $article['id'])->inc('view')->update(); //读取模板文件 - $template = Data::DOCUMENT_TYPE_ARTICLE . '/' . ($article['theme'] ?: 'detail.html'); + $template = Data::DOCUMENT_TYPE_ARTICLE . '/' . ($article['template'] ?: 'detail.html'); $templateFile = config('view.view_path') . $template; if (!is_file($templateFile)) { //配置的模版文件不存在则走默认模版 diff --git a/public/install/ape_blog.sql b/public/install/ape_blog.sql index ad66d2e..55692ca 100644 --- a/public/install/ape_blog.sql +++ b/public/install/ape_blog.sql @@ -143,17 +143,17 @@ COMMIT; -- ---------------------------- DROP TABLE IF EXISTS `ape_admin_notify`; CREATE TABLE `ape_admin_notify` ( - `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '消息ID', - `aid` int(10) NOT NULL DEFAULT '0' COMMENT '管理员ID', - `title` varchar(255) NOT NULL DEFAULT '' COMMENT '标题', - `content` mediumtext NOT NULL COMMENT '内容', - `from` varchar(10) NOT NULL DEFAULT '' COMMENT '消息来源 谁发的', - `type` varchar(10) NOT NULL DEFAULT 'system' COMMENT '消息类型 timer:定时器 system:系统', - `url` varchar(255) NOT NULL DEFAULT '' COMMENT '跳转路径 不填写时自动判断', - `is_read` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否已读', - `create_time` int(10) NOT NULL DEFAULT '0' COMMENT '添加时间', - `update_time` int(10) NOT NULL DEFAULT '0' COMMENT '更新时间', - PRIMARY KEY (`id`) USING BTREE + `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '消息ID', + `aid` int(10) NOT NULL DEFAULT '0' COMMENT '管理员ID', + `title` varchar(255) NOT NULL DEFAULT '' COMMENT '标题', + `content` mediumtext NOT NULL COMMENT '内容', + `from` varchar(10) NOT NULL DEFAULT '' COMMENT '消息来源 谁发的', + `type` varchar(10) NOT NULL DEFAULT 'system' COMMENT '消息类型 timer:定时器 system:系统', + `url` varchar(255) NOT NULL DEFAULT '' COMMENT '跳转路径 不填写时自动判断', + `is_read` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否已读', + `create_time` int(10) NOT NULL DEFAULT '0' COMMENT '添加时间', + `update_time` int(10) NOT NULL DEFAULT '0' COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='后台信息表'; -- ---------------------------- @@ -704,6 +704,30 @@ CREATE TABLE `ape_url_log` ( BEGIN; COMMIT; +-- ---------------------------- +-- Table structure for ape_message +-- ---------------------------- +DROP TABLE IF EXISTS `ape_message`; +CREATE TABLE `ape_message` ( + `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '消息ID', + `uid` int(10) NOT NULL DEFAULT '0' COMMENT '用户id包含管理员', + `title` varchar(255) NOT NULL DEFAULT '' COMMENT '标题', + `content` mediumtext NOT NULL COMMENT '内容', + `from` varchar(10) NOT NULL DEFAULT '' COMMENT '消息来源 谁发的', + `type` varchar(10) NOT NULL DEFAULT 'system' COMMENT '消息类型 公告、通知、私信等', + `url` varchar(255) NOT NULL DEFAULT '' COMMENT '跳转路径 不填写时自动判断', + `is_read` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否已读', + `create_time` int(10) NOT NULL DEFAULT '0' COMMENT '添加时间', + `update_time` int(10) NOT NULL DEFAULT '0' COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='消息通知表'; + +-- ---------------------------- +-- Records of ape_message +-- ---------------------------- +BEGIN; +COMMIT; + -- ---------------------------- -- Table structure for ape_user -- ----------------------------