mirror of https://github.com/1099438829/apeblog
parent
8cd129e663
commit
8c4117153a
|
|
@ -38,63 +38,4 @@ class Index extends AuthController
|
||||||
$this->assign('cid', false);
|
$this->assign('cid', false);
|
||||||
return $this->fetch();
|
return $this->fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 留言页面
|
|
||||||
* @param Request $request
|
|
||||||
* @return string
|
|
||||||
* @throws DataNotFoundException
|
|
||||||
* @throws DbException
|
|
||||||
* @throws ModelNotFoundException
|
|
||||||
* @author 木子的忧伤
|
|
||||||
* @date 2021-10-17 1:03
|
|
||||||
*/
|
|
||||||
public function msg(Request $request)
|
|
||||||
{
|
|
||||||
if (request()->isPost()) {
|
|
||||||
$data = Util::postMore([
|
|
||||||
['author', ''],
|
|
||||||
['tel', ''],
|
|
||||||
['email', ''],
|
|
||||||
['content', ''],
|
|
||||||
]);
|
|
||||||
$data['create_time'] = time();
|
|
||||||
$messageFormValidate = new MessageFormValidate();
|
|
||||||
if (!$messageFormValidate->check($data)) {
|
|
||||||
$this->error($messageFormValidate->getError());
|
|
||||||
}
|
|
||||||
$res = MessageFormModel::create($data);
|
|
||||||
if ($res) {
|
|
||||||
$this->success('留言成功');
|
|
||||||
} else {
|
|
||||||
$this->error('留言失败');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//清除可能存在的栏目分类树id
|
|
||||||
cache(Data::CURR_CATEGORY_PATENT_ID, false);
|
|
||||||
//模板兼容性标签
|
|
||||||
$this->assign('id', false);
|
|
||||||
$this->assign('cid', false);
|
|
||||||
return $this->fetch();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 标签列表
|
|
||||||
* @return mixed
|
|
||||||
* @author 木子的忧伤
|
|
||||||
* @date 2021-11-11 0:27
|
|
||||||
*/
|
|
||||||
public function tagList()
|
|
||||||
{
|
|
||||||
$where = Util::postMore([
|
|
||||||
['name', ''],
|
|
||||||
['document_id', ''],
|
|
||||||
['start_time', ''],
|
|
||||||
['end_time', ''],
|
|
||||||
['page', 1],
|
|
||||||
['limit', 10]
|
|
||||||
]);
|
|
||||||
return app("json")->layui(TagModel::getList($where));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -3,14 +3,13 @@
|
||||||
|
|
||||||
namespace app\common\model;
|
namespace app\common\model;
|
||||||
|
|
||||||
|
use app\common\constant\Data;
|
||||||
use app\common\model\Tag as TagModel;
|
use app\common\model\Tag as TagModel;
|
||||||
use think\db\exception\DataNotFoundException;
|
use think\db\exception\DataNotFoundException;
|
||||||
use think\db\exception\DbException;
|
use think\db\exception\DbException;
|
||||||
use app\common\constant\Data;
|
|
||||||
use think\db\exception\ModelNotFoundException;
|
use think\db\exception\ModelNotFoundException;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
use think\facade\Log;
|
use think\facade\Log;
|
||||||
use think\Model;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Document
|
* Class Document
|
||||||
|
|
@ -86,6 +85,14 @@ class Document extends BaseModel
|
||||||
return $info->toArray();
|
return $info->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新文件信息
|
||||||
|
* @param $dat
|
||||||
|
* @param string $type
|
||||||
|
* @throws DataNotFoundException
|
||||||
|
* @throws DbException
|
||||||
|
* @throws ModelNotFoundException
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
* 更新文件信息
|
* 更新文件信息
|
||||||
* @param $dat
|
* @param $dat
|
||||||
|
|
@ -134,7 +141,7 @@ class Document extends BaseModel
|
||||||
} else {
|
} else {
|
||||||
$ainfo = Document::get($data['id']);
|
$ainfo = Document::get($data['id']);
|
||||||
if (!$ainfo) return app("json")->fail("数据不存在");
|
if (!$ainfo) return app("json")->fail("数据不存在");
|
||||||
Document::where('id', $data['id'])->save($data);
|
Document::where('id', $data['id'])->update($data);
|
||||||
if (!empty($content)) {
|
if (!empty($content)) {
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case Data::DOCUMENT_TYPE_ARTICLE:
|
case Data::DOCUMENT_TYPE_ARTICLE:
|
||||||
|
|
@ -143,7 +150,6 @@ class Document extends BaseModel
|
||||||
'content' => $content
|
'content' => $content
|
||||||
];
|
];
|
||||||
$model = new DocumentArticle();
|
$model = new DocumentArticle();
|
||||||
$model->save($updateData);
|
|
||||||
break;
|
break;
|
||||||
case Data::DOCUMENT_TYPE_PAGE:
|
case Data::DOCUMENT_TYPE_PAGE:
|
||||||
$updateData = [
|
$updateData = [
|
||||||
|
|
@ -151,14 +157,20 @@ class Document extends BaseModel
|
||||||
'content' => $content
|
'content' => $content
|
||||||
];
|
];
|
||||||
$model = new DocumentPage();
|
$model = new DocumentPage();
|
||||||
$model->save($updateData);
|
|
||||||
break;
|
break;
|
||||||
case Data::DOCUMENT_TYPE_PRODUCT;
|
case Data::DOCUMENT_TYPE_PRODUCT;
|
||||||
|
$mode = new DocumentProduct();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//默认暂时不处理
|
//默认暂时不处理
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
$info = $model->find($data['id']);
|
||||||
|
if (!$info) {
|
||||||
|
$model->insert($updateData);
|
||||||
|
} else {
|
||||||
|
$model->update($updateData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!empty($data['tags'])) {
|
if (!empty($data['tags'])) {
|
||||||
$tagModel = new TagModel();
|
$tagModel = new TagModel();
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,7 @@ class Tag extends BaseModel
|
||||||
if ($where['end_time'] != '') $model = $model->where("create_time", "<", strtotime($where['end_time'] . " 23:59:59"));
|
if ($where['end_time'] != '') $model = $model->where("create_time", "<", strtotime($where['end_time'] . " 23:59:59"));
|
||||||
$count = self::counts($model);
|
$count = self::counts($model);
|
||||||
if ($where['page'] && $where['limit']) $model = $model->page((int)$where['page'], (int)$where['limit']);
|
if ($where['page'] && $where['limit']) $model = $model->page((int)$where['page'], (int)$where['limit']);
|
||||||
$data = $model->select()->each(function ($item) {
|
$data = $model->select();
|
||||||
});
|
|
||||||
if ($data) $data = $data->toArray();
|
if ($data) $data = $data->toArray();
|
||||||
return compact('data', 'count');
|
return compact('data', 'count');
|
||||||
}
|
}
|
||||||
|
|
@ -84,17 +83,18 @@ class Tag extends BaseModel
|
||||||
public static function getList($where): array
|
public static function getList($where): array
|
||||||
{
|
{
|
||||||
$list = cache('index:tagList');
|
$list = cache('index:tagList');
|
||||||
|
$list = false;
|
||||||
if ($list) {
|
if ($list) {
|
||||||
return json_decode($list, true);
|
return json_decode($list, true);
|
||||||
} else {
|
} else {
|
||||||
$tagList = self::systemPage($where);
|
$model = new self();
|
||||||
$list = [];
|
if ($where['name'] != '') $model = $model->where("title|url", "like", "%$where[name]%");
|
||||||
foreach ($tagList['data'] as $tag) {
|
$model = $model->field('distinct name,count(1) as num')->order("num DESC")->group("name");
|
||||||
$list[] = [
|
if ($where['page'] && $where['limit']) $model = $model->page((int)$where['page'], (int)$where['limit']);
|
||||||
"text" => $tag['name'],
|
$list = $model->select()->each(function (&$tag) {
|
||||||
"href" => url("/index/article/tag?t=" . $tag['name'])->build()
|
$tag->text = $tag['name'];
|
||||||
];
|
$tag->href = url("/index/article/tag?t=" . $tag['name'])->build();
|
||||||
}
|
})->toArray();
|
||||||
if ($list) {
|
if ($list) {
|
||||||
cache('index:tagList', json_encode($list), 24 * 60 * 60);
|
cache('index:tagList', json_encode($list), 24 * 60 * 60);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ use app\common\constant\Data;
|
||||||
use app\common\model\Document;
|
use app\common\model\Document;
|
||||||
use app\common\model\FriendLink as friendLinkModel;
|
use app\common\model\FriendLink as friendLinkModel;
|
||||||
use app\common\model\MessageForm as MessageFormModel;
|
use app\common\model\MessageForm as MessageFormModel;
|
||||||
|
use app\common\model\Tag as TagModel;
|
||||||
use app\common\validate\MessageForm as MessageformValidate;
|
use app\common\validate\MessageForm as MessageformValidate;
|
||||||
use app\Request;
|
use app\Request;
|
||||||
use think\db\exception\DataNotFoundException;
|
use think\db\exception\DataNotFoundException;
|
||||||
|
|
@ -170,4 +171,20 @@ class Index extends Base
|
||||||
$template = substr($template, 0, strpos($template, '.'));
|
$template = substr($template, 0, strpos($template, '.'));
|
||||||
return $this->fetch($template);
|
return $this->fetch($template);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标签列表
|
||||||
|
* @return mixed
|
||||||
|
* @author 木子的忧伤
|
||||||
|
* @date 2021-11-11 0:27
|
||||||
|
*/
|
||||||
|
public function tagList()
|
||||||
|
{
|
||||||
|
$where = Util::postMore([
|
||||||
|
['name', ''],
|
||||||
|
['page', 1],
|
||||||
|
['limit', 10]
|
||||||
|
]);
|
||||||
|
return app("json")->layui(TagModel::getList($where));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -208,7 +208,7 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
$.get("{:url('/index/article/taglist')}",function(data,status){
|
$.get("{:url('/index/index/taglist')}",function(data,status){
|
||||||
TagCloud(
|
TagCloud(
|
||||||
".corepress-tag-container-tag1",
|
".corepress-tag-container-tag1",
|
||||||
data.data,
|
data.data,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue