完善逻辑条正

This commit is contained in:
yumo 2023-12-14 16:32:56 +08:00
parent 1ba8bfcc4f
commit e25404ee2f
8 changed files with 117 additions and 22 deletions

View File

@ -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));

View File

@ -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', ''],

View File

@ -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();
}

View File

@ -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);

View File

@ -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)
{

View File

@ -0,0 +1,72 @@
<?php
namespace app\common\model;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Paginator;
/**
* 消息通知
* Class AdminNotify
* @package app\admin\model\admin
*/
class Message extends BaseModel
{
/**
* 系统分页
* @param array $where
* @return Paginator
* @throws DbException
*/
public static function systemPage(array $where)
{
$model = new self;
if ($where['start_time'] != "" && $where['end_time'] != "") {
$model = $model->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");
}
}

View File

@ -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)) {
//配置的模版文件不存在则走默认模版

View File

@ -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
-- ----------------------------