修正完善

This commit is contained in:
muzi_ys 2022-07-10 00:01:52 +08:00
parent 0bd6676770
commit c491923d38
42 changed files with 347 additions and 532 deletions

View File

@ -1 +1 @@
APP_DEBUG = true [APP] CDN = http://apeblog.io/ DEFAULT_TIMEZONE = Asia/Shanghai [DATABASE] TYPE = mysql HOSTNAME = 127.0.0.1 DATABASE = test USERNAME = username PASSWORD = password HOSTPORT = 3306 CHARSET = utf8 DEBUG = true [LANG] default_lang = zh-cn
APP_DEBUG = true [APP] CDN = http://apeblog.io/ DEFAULT_TIMEZONE = Asia/Shanghai [DATABASE] TYPE = mysql HOSTNAME = 127.0.0.1 DATABASE = test USERNAME = username PASSWORD = password HOSTPORT = 3306 CHARSET = utf8 DEBUG = true [LANG] default_lang = zh-cn [FILESYSTEM] DRIVER=public

View File

@ -143,3 +143,21 @@ if (!function_exists('get_tree_list')) {
}
}
if (!function_exists('get_theme_list')) {
function get_theme_list($type = ''):array
{
$themeList = [];
$themeDir = public_path('template') . system_config('web_template') . '/pc/' .$type;
if ($dh = opendir($themeDir)) {
while (($file = readdir($dh)) !== false) {
if ($file != "." && $file != "..") {
$themeList[] = $file;
}
}
closedir($dh);
}
return $themeList;
}
}

View File

@ -18,7 +18,7 @@ use think\facade\Route as Url;
/**
* Class Advert
* @package app\admin\controller
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-07-26 17:53
*/
class Advert extends AuthController
@ -27,7 +27,7 @@ class Advert extends AuthController
* 广告管理
* @return string
* @throws Exception
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-19 11:53
*/
public function index()
@ -47,7 +47,7 @@ class Advert extends AuthController
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:26
*/
public function lst(Request $request)

View File

@ -3,12 +3,10 @@
namespace app\admin\controller;
use app\common\model\Document;
use app\common\model\Document as aModel;
use app\common\model\DocumentCategory as cModel;
use app\common\model\Tag as TagModel;
use app\common\model\DocumentArticle;
use app\common\model\Comment as CommentModel;
use app\Request;
use app\admin\extend\Util as Util;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
@ -20,7 +18,7 @@ use think\facade\Log;
/**
* Class Article
* @package app\admin\controller\system
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:20
*/
class Article extends AuthController
@ -51,7 +49,7 @@ class Article extends AuthController
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:26
*/
public function lst()
@ -65,14 +63,14 @@ class Article extends AuthController
['limit', 20],
]);
$where['type'] = Document::DOCUMENT_TYPE_ARTICLE;
return app("json")->layui(aModel::systemPage($where));
return app("json")->layui(Document::systemPage($where));
}
/**
* 保存
* @param string $id
* @return mixed
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-28 22:43
*/
public function save($id = "")
@ -97,81 +95,16 @@ class Article extends AuthController
['tags', ''],
['sort', ''],
['status', 1],
['author', $this->adminInfo['nickname']],
['uid', $this->adminId],
]);
if ($data['title'] == "") return app("json")->fail("文章名称不能为空");
if ($data['category_id'] == "") return app("json")->fail("栏目分类不能为空");
if ($data['cover_path'] == "") return app("json")->fail("主图不能为空");
$error = "";
try {
$data['author'] = $data['author'] ?: $this->adminInfo['nickname'];
$data['uid'] = $this->adminId;
$content = '';
if (!empty($data['content'])) {
$content = $data['content'];
}
//判断摘要是否为空,为空则从内容摘取
$data['abstract'] = $data['abstract'] ?: mb_substr(strip_tags($content), 0, 100);
//判断是否写了别名,没写则需要生成
if ($data['alias'] == "") $data['alias'] = get_rand_str(6);
unset($data['content']);
if ($data['is_recommend']) $data['is_recommend'] = 1;
if ($data['is_hot']) $data['is_hot'] = 1;
if ($data['display']) $data['display'] = 1;
if ($data['is_top']) $data['is_top'] = 1;
// 启动事务
Db::startTrans();
if ($id == "") {
$data['uid'] = $this->adminInfo['uid'];
$data['author'] = $data['author'] ?: $this->adminInfo['nickname'];
$data['create_date'] = date("Y-m-d");
$data['create_time'] = time();
$data['update_time'] = time();
$id = aModel::insertGetId($data);
if (!empty($content)) {
$updateData = [
'id' => $id,
'content' => $content
];
DocumentArticle::insert($updateData);
}
if (!empty($data['tags'])) {
$tagModel = new TagModel();
$tagModel->createTags($data['tags'], $id, $this->adminId);
}
} else {
$ainfo = aModel::get($id);
if (!$ainfo) return app("json")->fail("数据不存在");
aModel::where('id', $id)->save($data);
if (!empty($content)) {
$contentInfo = DocumentArticle::where('id', $id)->find();
if (!$contentInfo) {
$updateData = [
'id' => $id,
'content' => $content
];
DocumentArticle::insert($updateData);
} else {
//更新文档
DocumentArticle::where('id', $id)->save(['content' => $content]);
}
}
if (!empty($data['tags'])) {
$tagModel = new TagModel();
$tagModel->createTags($data['tags'], $id, $this->adminId);
}
}
// 启动事务
Db::startTrans();
$res = true;
} catch (Exception $e) {
Log::error('文章修改失败:失败原因:' . $e->getMessage());
$error = $e->getMessage();
$res = false;
// 回滚事务
Db::rollback();
}
return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败,错误原因:".$error);
$model = new Document();
$res = $model->updateInfo($data,Document::DOCUMENT_TYPE_ARTICLE);
return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败,错误原因:".$model->getError());
}
@ -179,7 +112,7 @@ class Article extends AuthController
* 修改字段
* @param $id
* @return mixed
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-16 23:12
*/
public function field($id)
@ -187,7 +120,7 @@ class Article 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("操作失败");
return Document::update([$where['field'] => $where['value']], ['id' => $id]) ? app("json")->success("操作成功") : app("json")->fail("操作失败");
}
/**
@ -197,7 +130,7 @@ class Article extends AuthController
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-03-10 14:46
*/
public function add($category_id = '')
@ -217,7 +150,7 @@ class Article extends AuthController
* 编辑页
* @return string
* @throws \Exception
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-20 17:00
*/
public function edit()
@ -227,21 +160,14 @@ class Article extends AuthController
['id', '']
]);
if ($where['id'] == '') {
$this->error('数据不存在');
$this->error('参数错误');
}
$info = (new DocumentArticle())->getInfo($where["id"]);
$info = (new Document())->getInfo($where["id"],Document::DOCUMENT_TYPE_ARTICLE);
if (empty($info)) {
$this->error('数据不存在');
}
$category = cModel::systemPage($where);
$category = get_tree_list($category);
$info = aModel::get($where['id']);
$content = DocumentArticle::get($where['id']);
if ($content) {
$info->content = $content->content;
} else {
$info->content = '';
}
$this->assign("category", $category);
$this->assign("info", $info);
return $this->fetch();
@ -263,7 +189,7 @@ class Article extends AuthController
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-11-03 23:28
*/
public function commentList()
@ -287,7 +213,7 @@ class Article extends AuthController
* 修改字段
* @param $id
* @return mixed
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-16 23:12
*/
public function commentField($id)

View File

@ -15,7 +15,7 @@ use think\db\exception\ModelNotFoundException;
/**
* Class Article
* @package app\admin\controller\system
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:20
*/
class Category extends AuthController
@ -24,7 +24,7 @@ class Category extends AuthController
* 分类
* @return string
* @throws Exception
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-17 11:40
*/
public function index()
@ -66,30 +66,18 @@ class Category extends AuthController
['description', ''],
['template', ''],
['link_str', ''],
['content', ''],
['sort', 0],
['status', 1]
]);
if ($data['title'] == "") return app("json")->fail("分类名称不能为空");
if ($data['type'] == "") return app("json")->fail("类型不能为空");
$content = $data['content'];
unset($data['content']);
//判断是否写了别名,没写则需要生成
if ($data['alias'] == "") $data['alias'] = get_rand_str(8);
if ($id == "") {
$model = new aModel();
$id = $model->insert($data, true);
$data = [
'id' => $id,
'content' => $content
];
$model = new DocumentCategoryContent();
$res = $model->save($data);
$res = $model->insert($data);
} else {
$res = aModel::update($data, ['id' => $id]);
if ($res) {
$res = DocumentCategoryContent::update(['content' => $content], ['id' => $id]);
}
}
cache(Data::DATA_DOCUMENT_CATEGORY_LIST, null);
return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败");
@ -140,7 +128,7 @@ class Category extends AuthController
* 编辑页
* @return string
* @throws Exception
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-20 17:00
*/
public function edit(Request $request)
@ -160,7 +148,6 @@ class Category extends AuthController
$category = aModel::systemPage($where);
$category = get_tree_list($category);
$info = aModel::get($request->param(['id']));
$info->content = DocumentCategoryContent::get($request->param(['id']))->content;
$this->assign("category", $category);
$this->assign("info", $info);
$this->assign("template_list", $themeList);
@ -171,7 +158,7 @@ class Category extends AuthController
* 删除分类
* @param Request $request
* @return mixed|void
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-04-01 21:56
*/
public function del(Request $request)
@ -180,8 +167,7 @@ class Category extends AuthController
['id', ''],
]);
$model = new aModel();
$model->where('id', $where['id'])->delete();
$res = DocumentCategoryContent::where('id', $where['id'])->delete();
$res = $model->where('id', $where['id'])->delete();
cache(Data::DATA_DOCUMENT_CATEGORY_LIST, null);
return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败");
}

View File

@ -30,7 +30,7 @@ class Databases extends AuthController
* @param null $type
* @return string
* @throws Exception
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-10-30 12:45
*/
public function index($type = null)
@ -61,7 +61,7 @@ class Databases extends AuthController
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-10-31 0:12
*/
public function lst(Request $request)
@ -126,7 +126,7 @@ class Databases extends AuthController
/**
* 优化表
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-10-30 12:46
*/
public function optimize()
@ -148,7 +148,7 @@ class Databases extends AuthController
/**
* 修复表
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-10-31 0:12
*/
public function repair()
@ -174,7 +174,7 @@ class Databases extends AuthController
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-10-30 13:31
*/
public function delOne()
@ -195,7 +195,7 @@ class Databases extends AuthController
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-10-31 0:35
*/
public function export()
@ -277,7 +277,7 @@ class Databases extends AuthController
/**
* 还原数据库
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-10-30 12:46
*/
public function import()

View File

@ -18,7 +18,7 @@ use think\facade\Route as Url;
/**
* Class Message
* @package app\admin\controller\system
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:20
*/
class FriendLink extends AuthController
@ -40,7 +40,7 @@ class FriendLink extends AuthController
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:26
*/
public function lst(Request $request)
@ -136,7 +136,7 @@ class FriendLink extends AuthController
* 修改字段
* @param $id
* @return mixed
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-16 23:12
*/
public function field($id)

View File

@ -13,7 +13,7 @@ use think\db\exception\ModelNotFoundException;
/**
* Class Invitation
* @package app\admin\controller\system
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:20
*/
class Invitation extends AuthController
@ -32,7 +32,7 @@ class Invitation extends AuthController
* 邀请码列表
* @return string
* @throws Exception
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-16 13:15
*/
public function index()
@ -47,7 +47,7 @@ class Invitation extends AuthController
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:26
*/
public function lst(Request $request)
@ -67,7 +67,7 @@ class Invitation extends AuthController
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-20 14:32
*/
public function save($id = "")
@ -99,7 +99,7 @@ class Invitation extends AuthController
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-20 14:35
*/
public function addMultiple($id = "")

View File

@ -13,7 +13,7 @@ use think\db\exception\ModelNotFoundException;
/**
* Class Message
* @package app\admin\controller\system
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:20
*/
class Message extends AuthController
@ -32,7 +32,7 @@ class Message extends AuthController
* 留言管理
* @return string
* @throws Exception
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-19 11:53
*/
public function index()
@ -47,7 +47,7 @@ class Message extends AuthController
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-19 11:54
*/
public function lst(Request $request)

View File

@ -3,6 +3,7 @@
namespace app\admin\controller;
use app\admin\extend\FormBuilder as Form;
use app\common\constant\Data;
use app\common\model\Nav as aModel;
use app\Request;
use app\admin\extend\Util as Util;
@ -17,7 +18,7 @@ use think\facade\Route as Url;
/**
* Class Nav
* @package app\admin\controller\system
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:20
*/
class Nav extends AuthController
@ -123,7 +124,7 @@ class Nav extends AuthController
$res = aModel::update($data, ['id' => $id]);
}
//清理缓存
aModel::clearCache($this->adminId);
cache(Data::DATA_NAV_LIST, null);
return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败");
}
@ -138,7 +139,7 @@ class Nav extends AuthController
$where = Util::postMore([['field', ''], ['value', '']]);
if ($where['field'] == '' || $where['value'] == '') return app("json")->fail("参数有误!");
//清理缓存
aModel::clearCache($this->adminId);
cache(Data::DATA_NAV_LIST, null);
return aModel::update([$where['field'] => $where['value']], ['id' => $id]) ? app("json")->success("操作成功") : app("json")->fail("操作失败");
}
}

View File

@ -3,22 +3,16 @@
namespace app\admin\controller;
use app\common\model\Document;
use app\common\model\Document as aModel;
use app\common\model\DocumentPage;
use app\common\model\Tag as TagModel;
use app\common\model\Comment as CommentModel;
use app\admin\extend\Util as Util;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Exception;
use think\facade\Db;
use think\facade\Log;
/**
* Class Page
* @package app\admin\controller\system
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:20
*/
class Page extends AuthController
@ -50,7 +44,7 @@ class Page extends AuthController
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:26
*/
public function lst()
@ -63,18 +57,18 @@ class Page extends AuthController
['page', 1],
['limit', 20],
]);
$where["type"] = aModel::DOCUMENT_TYPE_PAGE;
return app("json")->layui(aModel::systemPage($where));
$where["type"] = Document::DOCUMENT_TYPE_PAGE;
return app("json")->layui(Document::systemPage($where));
}
/**
* 保存
* @param string $id
* @return mixed
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-28 22:43
*/
public function save($id = "")
public function save()
{
$data = Util::postMore([
['id', ''],
@ -90,86 +84,22 @@ class Page extends AuthController
['is_recommend', 0],
['is_top', 0],
['is_hot', 0],
['theme',''],
['link_str', ''],
['cover_path', ''],
['display', 1],
['tags', ''],
['sort', ''],
['status', 1],
['author', $this->adminInfo['nickname']],
['uid', $this->adminId],
]);
if ($data['title'] == "") return app("json")->fail("文章名称不能为空");
if ($data['theme'] == "") return app("json")->fail("文章模板不能为空");
if ($data['cover_path'] == "") return app("json")->fail("主图不能为空");
$error = "";
try {
$data['author'] = $data['author'] ?: $this->adminInfo['nickname'];
$data['uid'] = $this->adminId;
$content = '';
if (!empty($data['content'])) {
$content = $data['content'];
}
//判断摘要是否为空,为空则从内容摘取
$data['abstract'] = $data['abstract'] ?: mb_substr(strip_tags($content), 0, 100);
//判断是否写了别名,没写则需要生成
if ($data['alias'] == "") $data['alias'] = get_rand_str(6);
unset($data['content']);
if ($data['is_recommend']) $data['is_recommend'] = 1;
if ($data['is_hot']) $data['is_hot'] = 1;
if ($data['display']) $data['display'] = 1;
if ($data['is_top']) $data['is_top'] = 1;
// 启动事务
Db::startTrans();
if ($id == "") {
$data['uid'] = $this->adminInfo['uid'];
$data['author'] = $data['author'] ?: $this->adminInfo['nickname'];
$data['create_date'] = date("Y-m-d");
$data['create_time'] = time();
$data['update_time'] = time();
$id = aModel::insertGetId($data);
if (!empty($content)) {
$updateData = [
'id' => $id,
'content' => $content
];
DocumentPage::insert($updateData);
}
if (!empty($data['tags'])) {
$tagModel = new TagModel();
$tagModel->createTags($data['tags'], $id, $this->adminId);
}
} else {
$ainfo = aModel::get($id);
if (!$ainfo) return app("json")->fail("数据不存在");
aModel::where('id', $id)->save($data);
if (!empty($content)) {
$contentInfo = DocumentPage::where('id', $id)->find();
if (!$contentInfo) {
$updateData = [
'id' => $id,
'content' => $content
];
DocumentPage:insert($updateData);
} else {
//更新文档
DocumentPage::where('id', $id)->save(['content' => $content]);
}
}
if (!empty($data['tags'])) {
$tagModel = new TagModel();
$tagModel->createTags($data['tags'], $id, $this->adminId);
}
}
// 启动事务
Db::startTrans();
$res = true;
} catch (Exception $e) {
Log::error('文章修改失败:失败原因:' . $e->getMessage());
$error = $e->getMessage();
$res = false;
// 回滚事务
Db::rollback();
}
return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败,错误原因:".$error);
$model = new Document();
$res = $model->updateInfo($data,Document::DOCUMENT_TYPE_PAGE);
return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败,错误原因:".$model->getError());
}
@ -177,7 +107,7 @@ class Page extends AuthController
* 修改字段
* @param $id
* @return mixed
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-16 23:12
*/
public function field($id)
@ -185,7 +115,7 @@ class Page 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("操作失败");
return Document::update([$where['field'] => $where['value']], ['id' => $id]) ? app("json")->success("操作成功") : app("json")->fail("操作失败");
}
/**
@ -194,24 +124,15 @@ class Page extends AuthController
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-03-10 14:46
*/
public function add()
{
// 获取页面模板列表
$themeList = [];
$themeDir = public_path('template').system_config('web_template').'/pc/page';
if ($dh = opendir($themeDir)) {
while (($file = readdir($dh)) !== false) {
if ( $file != "." && $file != "..") {
$themeList[] = $file;
}
}
closedir($dh);
}
$this->assign("themeList", $themeList);
$this->getThemeList();
$themeList = get_theme_list(Document::DOCUMENT_TYPE_PAGE);
$this->assign("theme_list", $themeList);
return $this->fetch();
}
@ -230,24 +151,13 @@ class Page extends AuthController
if ($where['id'] == '') {
$this->error('数据不存在');
}
$info = (new DocumentPage())->getInfo($where["id"]);
$info = (new Document())->getInfo($where["id"],Document::DOCUMENT_TYPE_PAGE);
if (empty($info)) {
$this->error('数据不存在');
}
// 获取页面模板列表
$themeList = [];
$themeDir = public_path('template/');
$defaultTheme = system_config('web_template');
if ($dh = opendir($themeDir.'/'.$defaultTheme.'/pc/page')) {
if ((is_dir($themeDir . "/" . $file)) && $file != "." && $file != "..") {
while (($file = readdir($dh)) !== false) {
$pageList[] = $file;
}
}
closedir($dh);
}
$this->assign("themeList", $themeList);
$themeList = get_theme_list(Document::DOCUMENT_TYPE_PAGE);
$this->assign("theme_list", $themeList);
$this->assign("info", $info);
return $this->fetch();
}
@ -268,7 +178,7 @@ class Page extends AuthController
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-11-03 23:28
*/
public function commentList()
@ -292,7 +202,7 @@ class Page extends AuthController
* 修改字段
* @param $id
* @return mixed
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-16 23:12
*/
public function commentField($id)
@ -302,5 +212,4 @@ class Page extends AuthController
if ($where['field'] == '' || $where['value'] == '') return app("json")->fail("参数有误!");
return CommentModel::update([$where['field'] => $where['value']], ['id' => $id]) ? app("json")->success("操作成功") : app("json")->fail("操作失败");
}
}

View File

@ -10,7 +10,7 @@ use Exception;
/**
* Class Theme
* @package app\admin\controller\system
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:20
*/
class Theme extends AuthController
@ -19,7 +19,7 @@ class Theme extends AuthController
* 主题列表
* @return string
* @throws Exception
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-17 11:40
*/
public function index()
@ -55,7 +55,7 @@ class Theme extends AuthController
* 更新主题
* @return string
* @throws Exception
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-17 11:40
*/
public function change_theme()

View File

@ -18,7 +18,7 @@ use think\facade\Route as Url;
* 用户管理
* Class User
* @package app\admin\controller\system
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:20
*/
class User extends AuthController

View File

@ -33,7 +33,7 @@
<div class="form-group form-controls">
<select name="theme" id="theme" class="form-control">
<option value="0">请选择</option>
{volist name="themeList" id="vo"}
{volist name="theme_list" id="vo"}
<option value="{$vo}">{$vo}</option>
{/volist}
</select>

View File

@ -24,7 +24,8 @@
<form action="#!" method="post" class="row add-form" onsubmit="return false;">
<div class="form-group col-md-12">
<label>页面名称</label>
<input type="text" class="form-control" id="title" name="title" value="" placeholder="页面名称"/>
<input type="hidden" name="id" value="{$info.id}">
<input type="text" class="form-control" id="title" name="title" value="{$info.title}" placeholder="页面名称"/>
</div>
<div class="form-group col-md-12">
<div class="row">
@ -33,7 +34,7 @@
<div class="form-group form-controls">
<select name="theme" id="theme" class="form-control">
<option value="0">请选择</option>
{volist name="themeList" id="vo"}
{volist name="theme_list" id="vo"}
<option value="{$vo}" {if $vo == $info.theme}selected{/if}>{$vo}</option>
{/volist}
</select>

View File

@ -46,7 +46,7 @@ class Index extends AuthController
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-10-17 1:03
*/
public function msg(Request $request)
@ -82,7 +82,7 @@ class Index extends AuthController
/**
* 标签列表
* @return mixed
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-11-11 0:27
*/
public function tagList()

View File

@ -136,7 +136,7 @@ if (!function_exists('file_cdn')) {
* 文件cdn
* @param $path
* @return string
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-17 23:32
*/
function file_cdn($path)
@ -169,7 +169,7 @@ if (!function_exists('get_rand_str')) {
* 生成随机字符串
* @param $length
* @return string
* @author 李玉坤
* @author 木子的忧伤
* @date 2022-04-11 18:26
*/
function get_rand_str($length){

View File

@ -1,6 +1,6 @@
<?php
/**
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-11-11 23:57
*/

View File

@ -1,7 +1,7 @@
<?php
namespace app\common\extend;
/**
* @author 李玉坤
* @author 木子的忧伤
* @date 2022-01-22 1:29
*/

View File

@ -111,7 +111,7 @@ class AdminAuth extends BaseModel
* 获取菜单列表缓存key
* @param $adminId
* @return string
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-06-09 17:24
*/
public static function getMenuCacheKey($adminId)
@ -121,7 +121,7 @@ class AdminAuth extends BaseModel
/**
* @return string
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-06-15 11:11
*/
public static function getAuthCacheKey()

View File

@ -10,7 +10,7 @@ use think\db\exception\ModelNotFoundException;
/**
* Class Advert
* @package app\common\model
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-07-26 18:38
*/
class Advert extends BaseModel
@ -22,7 +22,7 @@ class Advert extends BaseModel
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:24
*/
public static function systemPage($where): array

View File

@ -10,7 +10,7 @@ use think\db\exception\ModelNotFoundException;
/**
* Class Comment
* @package app\common\model
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-10-17 20:33
*/
class Comment extends BaseModel
@ -22,7 +22,7 @@ class Comment extends BaseModel
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:24
*/
public static function systemPage($where): array

View File

@ -3,14 +3,18 @@
namespace app\common\model;
use app\common\model\Tag as TagModel;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\facade\Db;
use think\facade\Log;
use think\Model;
/**
* Class Document
* @package app\admin\model\system
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:22
*/
class Document extends BaseModel
@ -27,7 +31,7 @@ class Document extends BaseModel
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:24
*/
public static function systemPage($where): array
@ -47,4 +51,119 @@ class Document extends BaseModel
});
return compact('data', 'count');
}
/**
* 获取文章信息
* @param $id
* @param string $type
* @param string $status
* @return array
*/
public function getInfo($id,$type= self::DOCUMENT_TYPE_ARTICLE,$status = ''): array
{
if (empty($id)){
return [];
}
$model = self::alias('a')
->leftJoin('document_article p','a.id = p.id')
->where("a.type",Document::DOCUMENT_TYPE_PAGE);
if (is_numeric($id)){
$model->where("a.id",$id);
}else{
$model->where("a.alias",$id);
}
if ($type !=='') $model->where("a.type",$type);
if ($status !=='')$model->where("a.status",$status);
$info = $model->find();
if (!$info){
return [];
}
return $info->toArray();
}
/**
* 更新文件信息
* @param $dat
* @param string $type
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function updateInfo($data, string $type=self::DOCUMENT_TYPE_ARTICLE)
{
try {
$content = !empty($data['content'])?$data['content']:'';
//判断摘要是否为空,为空则从内容摘取
$data['abstract'] = $data['abstract'] ?: mb_substr(strip_tags($content), 0, 100);
//判断是否写了别名,没写则需要生成
if ($data['alias'] == "") $data['alias'] = get_rand_str(6);
unset($data['content']);
if ($data['is_recommend']) $data['is_recommend'] = 1;
if ($data['is_hot']) $data['is_hot'] = 1;
if ($data['display']) $data['display'] = 1;
if ($data['is_top']) $data['is_top'] = 1;
// 启动事务
Db::startTrans();
if (empty($data['id'])) {
$data['create_date'] = date("Y-m-d");
$data['create_time'] = time();
$data['update_time'] = time();
$id = Document::insertGetId($data);
if (!empty($content)) {
$updateData = [
'id' => $id,
'content' => $content
];
DocumentPage::insert($updateData);
}
if (!empty($data['tags'])) {
$tagModel = new TagModel();
$tagModel->createTags($data['tags'], $id, $data['uid']);
}
} else {
$ainfo = Document::get($data['id']);
if (!$ainfo) return app("json")->fail("数据不存在");
Document::where('id', $data['id'])->save($data);
if (!empty($content)) {
switch ($type) {
case self::DOCUMENT_TYPE_ARTICLE:
$updateData = [
'id' => $data['id'],
'content' => $content
];
$model = new DocumentArticle();
$model->save($updateData);
break;
case self::DOCUMENT_TYPE_PAGE:
$updateData = [
'id' => $data['id'],
'content' => $content
];
$model = new DocumentPage();
$model->save($updateData);
break;
case self::DOCUMENT_TYPE_CATEGORY;
break;
default:
//默认暂时不处理
break;
}
}
if (!empty($data['tags'])) {
$tagModel = new TagModel();
$tagModel->createTags($data['tags'], $data['id'], $data['uid']);
}
}
// 提交事务
Db::commit();
$res = true;
} catch (\Exception $e) {
Log::error('文章修改失败:失败原因:' . $e->getMessage());
$res = false;
self::setErrorInfo($e->getMessage());
// 回滚事务
Db::rollback();
}
return $res;
}
}

View File

@ -12,24 +12,9 @@ use think\db\exception\ModelNotFoundException;
/**
* Class DocumentArticle
* @package app\admin\model\system
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:22
*/
class DocumentArticle extends BaseModel
{
public function getInfo($id)
{
if (empty($id)){
return [];
}
$info = aModel::alias('a')
->leftJoin('document_article p','a.id = p.id')
->where("a.id",$id)
->where("a.type",Document::DOCUMENT_TYPE_PAGE)
->find();
if (!$info){
return [];
}
return $info->toArray();
}
}

View File

@ -10,7 +10,7 @@ use think\db\exception\ModelNotFoundException;
/**
* Class DocumentCategory
* @package app\admin\model\system
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:22
*/
class DocumentCategory extends BaseModel
@ -22,7 +22,7 @@ class DocumentCategory extends BaseModel
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-11-08 0:25
*/
public static function systemPage($where): array

View File

@ -1,38 +0,0 @@
<?php
namespace app\common\model;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
/**
* Class DocumentCategoryContent
* @package app\admin\model\system
* @author 李玉坤
* @date 2021-02-15 23:22
*/
class DocumentCategoryContent extends BaseModel
{
/**
* 列表
* @param $where
* @return array
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @date 2021-02-15 23:24
*/
public static function systemPage($where): array
{
$model = new self;
$count = self::counts($model);
if ($where['page'] && $where['limit']) $model = $model->page((int)$where['page'], (int)$where['limit']);
$data = $model->select();
if ($data) $data = $data->toArray();
return compact('data', 'count');
}
}

View File

@ -12,25 +12,9 @@ use think\db\exception\ModelNotFoundException;
/**
* Class DocumentPage
* @package app\admin\model\system
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:22
*/
class DocumentPage extends BaseModel
{
public function getInfo($id)
{
if (empty($id)){
return [];
}
$info = aModel::alias('a')
->leftJoin('document_page p','a.id = p.id')
->where("a.id",$id)
->where("a.type",Document::DOCUMENT_TYPE_PAGE)
->find();
if (!$info){
return [];
}
return $info->toArray();
}
}

View File

@ -11,7 +11,7 @@ use think\db\exception\ModelNotFoundException;
/**
* Class DocumentProduct
* @package app\admin\model\system
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:22
*/
class DocumentProduct extends BaseModel
@ -23,7 +23,7 @@ class DocumentProduct extends BaseModel
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:24
*/
public static function systemPage($where): array

View File

@ -11,7 +11,7 @@ use think\db\exception\ModelNotFoundException;
/**
* Class FriendLink
* @package app\admin\model\system
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:22
*/
class FriendLink extends BaseModel
@ -23,7 +23,7 @@ class FriendLink extends BaseModel
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:24
*/
public static function systemPage($where): array

View File

@ -11,7 +11,7 @@ use think\db\exception\ModelNotFoundException;
/**
* Class InvitationCode
* @package app\admin\model\system
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:22
*/
class InvitationCode extends BaseModel
@ -23,7 +23,7 @@ class InvitationCode extends BaseModel
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:24
*/
public static function systemPage($where): array

View File

@ -10,7 +10,7 @@ use think\db\exception\ModelNotFoundException;
/**
* Class Document
* @package app\admin\model\system
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:22
*/
class MessageForm extends BaseModel
@ -22,7 +22,7 @@ class MessageForm extends BaseModel
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:24
*/
public static function systemPage($where): array

View File

@ -11,7 +11,7 @@ use think\db\exception\ModelNotFoundException;
/**
* Class Document
* @package app\admin\model\system
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:22
*/
class Nav extends BaseModel
@ -57,34 +57,6 @@ class Nav extends BaseModel
return $data->toArray() ?: [];
}
/**
* 获取菜单列表缓存key
* @param $adminId
* @return string
* @author 李玉坤
* @date 2021-06-09 17:24
*/
public static function getMenuCacheKey($adminId)
{
return 'menu:List:' . $adminId;
}
/**
* @return string
* @author 李玉坤
* @date 2021-06-15 11:11
*/
public static function getAuthCacheKey()
{
return 'auth:key:list';
}
public static function clearCache($adminId)
{
cache(AdminAuth::getMenuCacheKey($adminId), null);
cache(AdminAuth::getAuthCacheKey(), null);
}
/**
* 遍历选择项
* @param array $data
@ -132,54 +104,6 @@ class Nav extends BaseModel
return $str . " ";
}
/**
* 生成treeData
* @param int $pid
* @param array $auth
* @param array $list
* @return array
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public static function selectAndBuildTree(int $pid = 0, array $auth = [], array $list = [])
{
$model = new self;
$model = $model->where("pid", $pid);
if ($auth != []) $model = $model->where("id", 'in', $auth);
$model = $model->where("status", 1);
$model = $model->field(['title', 'id']);
$model = $model->order(["sort desc", "id"]);
$data = $model->select();
foreach ($data as $k => $v) {
$list[] = self::buildTreeData($v['id'], $v['title'], self::selectAndBuildTree($v['id'], $auth));
}
return $list;
}
/**
* 获取所有权限id
* @param array $ids
* @return array
*/
public static function getIds(array $ids = []): array
{
if (empty($ids)) return self::where("status", 1)->column("id");
$pids = self::where("id", "in", $ids)->column("pid");
return array_merge($ids, $pids) ?: [];
}
/**
* 获取操作名
* @param string $module
* @param string $controller
* @param string $action
* @return string
*/
public static function getNameByAction(string $module, string $controller, string $action)
{
return self::where("module", $module)->where("controller", $controller)->where("action", $action)->value("title") ?: '未知操作';
}
/**
* 生成单个节点
* @param $id

View File

@ -17,7 +17,7 @@ class SystemConfigTab extends BaseModel
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2022-02-28 9:19
*/
public static function lst($where)

View File

@ -12,7 +12,7 @@ use think\db\exception\ModelNotFoundException;
/**
* Class Tag
* @package app\common\model
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-11-08 0:11
*/
class Tag extends BaseModel
@ -24,7 +24,7 @@ class Tag extends BaseModel
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:24
*/
public static function systemPage($where): array
@ -49,7 +49,7 @@ class Tag extends BaseModel
* @param $user_id
* @return Collection
* @throws Exception
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-11-08 0:53
*/
public function createTags($tags, $document_id, $user_id)
@ -78,7 +78,7 @@ class Tag extends BaseModel
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-15 23:24
*/
public static function getList($where): array

View File

@ -13,7 +13,7 @@ use think\facade\Session;
* 用户管理
* Class User
* @package app\admin\model
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-02-18 15:49
*/
class User extends BaseModel
@ -49,7 +49,7 @@ class User extends BaseModel
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2022-01-16 1:33
*/
public static function register(string $username, string $email, string $password): bool
@ -90,7 +90,7 @@ class User extends BaseModel
* 添加后台用户信息
* @param $data
* @return bool|int|string
* @author 李玉坤
* @author 木子的忧伤
* @date 2022-01-03 3:46
*/
public static function addAdminUser($data)
@ -114,7 +114,7 @@ class User extends BaseModel
* @param $id
* @param $data
* @return bool|int|string
* @author 李玉坤
* @author 木子的忧伤
* @date 2022-01-03 3:48
*/
public static function updateAdminUser($id, $data)

View File

@ -234,7 +234,7 @@ class Ape extends TagLib
* @param $tag
* @param $content
* @return string
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-07-26 23:22
*/
public function tagAdvert($tag, $content)
@ -302,7 +302,7 @@ class Ape extends TagLib
* @param $tag
* @param $content
* @return bool|string
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-11-27 23:44
*/
public function tagComment($tag, $content)
@ -331,7 +331,7 @@ class Ape extends TagLib
* @param $tag
* @param $content
* @return string
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-11-28 0:52
*/
public function tagRelevant($tag, $content)

View File

@ -135,7 +135,7 @@ function get_document_category_by_name($name, $field = false)
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-11-12 21:48
*/
function tpl_get_channel($type, $typeId, $row = 100, $where = '', $orderby = '')
@ -596,7 +596,7 @@ function tpl_get_friend_link($type, $row)
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-07-26 23:24
*/
function tpl_get_advert($type, $row)
@ -626,7 +626,7 @@ function tpl_get_advert($type, $row)
* @param $type
* @param $format
* @return mixed
* @author 李玉坤
* @author 木子的忧伤
* @date 2022-06-01 10:06
*/
function tpl_get_archive_list($type,$format){
@ -661,7 +661,7 @@ if (!function_exists('web_config')) {
* 获取系统配置值
* @param string $formName
* @return string
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-11-12 0:34
*/
function web_config(string $formName): string
@ -679,7 +679,7 @@ if (!function_exists('web_config')) {
* 模板-文章标签
* @param $tags
* @return array|bool
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-11-12 0:34
*/
if (!function_exists('tpl_get_tags_list')) {
@ -705,7 +705,7 @@ if (!function_exists('tpl_get_tags_list')) {
* @param array $positionList
* @return string
* @throws Exception
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-12-05 22:40
*/
function tpl_get_position($dc, $positionList = array())
@ -745,7 +745,7 @@ function get_comment_children($parentIds)
* @param string $orderBy
* @return array
* @throws DbException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-12-05 23:54
*/
function tpl_get_comment_list($id, $type, $pageSize, $orderBy)
@ -787,7 +787,7 @@ function tpl_get_comment_list($id, $type, $pageSize, $orderBy)
* @param $documentId
* @param string $type
* @return int
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-12-05 23:16
*/
function get_comment_count($documentId, $type = 'top')
@ -816,7 +816,7 @@ function get_comment_count($documentId, $type = 'top')
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-11-28 1:02
*/
function tpl_get_relevant_list($documentId, $row, $table = 'article')
@ -995,7 +995,7 @@ function is_mobile()
/**
* 加载svg
* @param $path
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-12-05 21:35
*/
function file_echo_svg($path)
@ -1008,7 +1008,7 @@ function file_echo_svg($path)
* 加载表情
* @param $path
* @return string|null
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-12-05 21:36
*/
function file_load_face($path)
@ -1056,7 +1056,7 @@ function comment_face($incoming_comment,$path)
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-11-12 21:48
*/
function tpl_get_nav($type, $typeId, $row = 100, $where = '', $orderby = '')

View File

@ -30,7 +30,7 @@ class Article extends Base
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-10-29 0:17
*/
public function lists()
@ -107,7 +107,7 @@ class Article extends Base
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-10-29 0:17
*/
public function detail()
@ -175,7 +175,7 @@ class Article extends Base
* 创建评论
* @param Request $request
* @return mixed
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-10-17 19:13
*/
public function create_comment(Request $request)
@ -220,7 +220,7 @@ class Article extends Base
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-10-29 0:19
*/
public function tag()
@ -259,7 +259,7 @@ class Article extends Base
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-10-29 0:18
*/
public function search()
@ -295,7 +295,7 @@ class Article extends Base
* 用户首页
* @return string
* @throws Exception
* @author 李玉坤
* @author 木子的忧伤
* @date 2022-01-24 1:23
*/
public function user()

View File

@ -68,7 +68,7 @@ class Base extends BaseController
/**
* url 统计
* @param $title
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-05-09 23:44
*/
protected function urlrecord($title)

View File

@ -46,7 +46,7 @@ class Index extends Base
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-10-17 1:03
*/
public function applylink(Request $request)
@ -91,7 +91,7 @@ class Index extends Base
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-10-17 1:03
*/
public function msg(Request $request)
@ -123,64 +123,4 @@ class Index extends Base
return $this->fetch();
}
}
/**
* 关于页面
* @param Request $request
* @author 李玉坤
* @date 2022-06-21 23:48
*/
public function about(Request $request)
{
$id = "about";
//获取该文章
$documentModel = new Document();
$article = $documentModel->where('status', 1)->where('id|alias', $id)->find();
if (!$article) {
$this->error('文章不存在或已删除!');
}
$article = $article->toArray();
//根据分类id找分类信息
$dc = get_document_category($article['category_id']);
if (!$dc) {
$this->error('栏目不存在或已删除!');
}
//获取该文章内容
//根据文章类型,加载不同的内容。
$articleType = $article['type'] ? $article['type'] : 'article';
$articleExt = $documentModel::name('document_' . $articleType)->where('id', $article['id'])->find();
if (!$articleExt) {
$this->error('文章不存在或已删除!');
}
$articleExt = $articleExt->toArray();
$article = array_merge($article, $articleExt);
//添加当前页面的位置信息
$article['position'] = tpl_get_position($dc);
//更新浏览次数
$documentModel->where('id', $article['id'])->inc('view')->update();
$templateFile = config('view.view_path') . 'article/' . $articleType . '.html';
if (!is_file($templateFile)) {
$this->error('模板文件不存在!');
}
$article['category_title'] = $dc['title'];
//判断SEO 为空则取系统
$article['keywords'] = $article['keywords'] ?: web_config('keywords');
$article['description'] = $article['description'] ?: web_config('description');
//输出文章内容
$this->assign('apeField', $article);
$this->assign('id', $id);
//当前页面所属分类id
$this->assign('cid', $article['category_id']);
//缓存当前页面栏目分类树ids
cache(Data::CURR_CATEGORY_PATENT_ID, $dc['pid'] ? $dc['pid'] . ',' . $article['category_id'] : $article['category_id']);
//设置文章的url
$article['link_str'] = make_detail_url($article);
//判断后台统计配置是否开启 1 开启
if (web_config("web_statistics") == 1) {
//统计url
$this->urlrecord($article['title']);
}
Log::info('详情页模板路径:' . $templateFile);
return $this->fetch('article/' . $articleType);
}
}

View File

@ -30,7 +30,7 @@ class Page extends Base
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-10-29 0:17
*/
public function lists()
@ -107,7 +107,7 @@ class Page extends Base
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-10-29 0:17
*/
public function detail()
@ -171,7 +171,7 @@ class Page extends Base
* 创建评论
* @param Request $request
* @return mixed
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-10-17 19:13
*/
public function create_comment(Request $request)
@ -216,7 +216,7 @@ class Page extends Base
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-10-29 0:19
*/
public function tag()
@ -252,7 +252,7 @@ class Page extends Base
/**
* 标签列表
* @return mixed
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-11-11 0:27
*/
public function tagList()
@ -274,7 +274,7 @@ class Page extends Base
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-10-29 0:18
*/
public function search()
@ -310,7 +310,7 @@ class Page extends Base
* 用户首页
* @return string
* @throws Exception
* @author 李玉坤
* @author 木子的忧伤
* @date 2022-01-24 1:23
*/
public function user()
@ -342,4 +342,64 @@ class Page extends Base
}
return $this->fetch();
}
/**
* 关于页面
* @param Request $request
* @author 木子的忧伤
* @date 2022-06-21 23:48
*/
public function about(Request $request)
{
$id = "about";
//获取该文章
$documentModel = new Document();
$article = $documentModel->where('status', 1)->where('id|alias', $id)->find();
if (!$article) {
$this->error('文章不存在或已删除!');
}
$article = $article->toArray();
//根据分类id找分类信息
$dc = get_document_category($article['category_id']);
if (!$dc) {
$this->error('栏目不存在或已删除!');
}
//获取该文章内容
//根据文章类型,加载不同的内容。
$articleType = Document::DOCUMENT_TYPE_PAGE;
$articleExt = $documentModel::name('document_' . $articleType)->where('id', $article['id'])->find();
if (!$articleExt) {
$this->error('文章不存在或已删除!');
}
$articleExt = $articleExt->toArray();
$article = array_merge($article, $articleExt);
//添加当前页面的位置信息
$article['position'] = tpl_get_position($dc);
//更新浏览次数
$documentModel->where('id', $article['id'])->inc('view')->update();
$templateFile = config('view.view_path') . 'article/' . $articleType . '.html';
if (!is_file($templateFile)) {
$this->error('模板文件不存在!');
}
$article['category_title'] = $dc['title'];
//判断SEO 为空则取系统
$article['keywords'] = $article['keywords'] ?: web_config('keywords');
$article['description'] = $article['description'] ?: web_config('description');
//输出文章内容
$this->assign('apeField', $article);
$this->assign('id', $id);
//当前页面所属分类id
$this->assign('cid', $article['category_id']);
//缓存当前页面栏目分类树ids
cache(Data::CURR_CATEGORY_PATENT_ID, $dc['pid'] ? $dc['pid'] . ',' . $article['category_id'] : $article['category_id']);
//设置文章的url
$article['link_str'] = make_detail_url($article);
//判断后台统计配置是否开启 1 开启
if (web_config("web_statistics") == 1) {
//统计url
$this->urlrecord($article['title']);
}
Log::info('详情页模板路径:' . $templateFile);
return $this->fetch('article/' . $articleType);
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
* @author 李玉坤
* @author 木子的忧伤
* @date 2021-12-31 1:04
*/
@ -112,7 +112,7 @@ class User extends Base
* 用户中心
* @return string
* @throws Exception
* @author 李玉坤
* @author 木子的忧伤
* @date 2022-01-16 21:04
*/
public function profile()