mirror of https://github.com/1099438829/apeblog
Compare commits
2 Commits
1d35393458
...
e25404ee2f
| Author | SHA1 | Date |
|---|---|---|
|
|
e25404ee2f | |
|
|
1ba8bfcc4f |
|
|
@ -4,6 +4,7 @@ namespace app\admin\controller;
|
|||
|
||||
use app\admin\extend\Util as Util;
|
||||
use app\admin\model\AdminLog as lModel;
|
||||
use app\common\model\AdvertInfo;
|
||||
use app\Request;
|
||||
use Exception;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -254,6 +254,9 @@ class Advert extends AuthController
|
|||
* 保存修改
|
||||
* @param string $id
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function saveAdvert($id = "")
|
||||
{
|
||||
|
|
@ -283,4 +286,18 @@ class Advert extends AuthController
|
|||
cache(Data::DATA_ADVERT . '_' . $info['alias'], null);//清除缓存
|
||||
return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除广告
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function delAdvert(Request $request)
|
||||
{
|
||||
$where = Util::postMore([
|
||||
['id', ''],
|
||||
],$request);
|
||||
if (empty($where['id'])) return app("json")->fail("参数错误,请刷新后重试");
|
||||
return (new \app\common\model\AdvertInfo)->where('id',$where['id'])->delete() ? app("json")->success("删除成功") : app("json")->fail("删除失败");
|
||||
}
|
||||
}
|
||||
|
|
@ -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', ''],
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class Image extends AuthController
|
|||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function category(): array
|
||||
public function category()
|
||||
{
|
||||
return app("json")->success(AttachmentCategory::buildNodes($this->type, 0, $this->request->param("title", "")));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
@ -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)) {
|
||||
//配置的模版文件不存在则走默认模版
|
||||
|
|
|
|||
|
|
@ -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
|
||||
-- ----------------------------
|
||||
|
|
|
|||
Loading…
Reference in New Issue