修正词云

修正文章编辑
This commit is contained in:
muzi_ys 2022-07-14 00:13:21 +08:00
parent 8cd129e663
commit 8c4117153a
6 changed files with 95 additions and 114 deletions

View File

@ -38,63 +38,4 @@ class Index extends AuthController
$this->assign('cid', false);
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));
}
}

View File

@ -3,14 +3,13 @@
namespace app\common\model;
use app\common\constant\Data;
use app\common\model\Tag as TagModel;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use app\common\constant\Data;
use think\db\exception\ModelNotFoundException;
use think\facade\Db;
use think\facade\Log;
use think\Model;
/**
* Class Document
@ -86,6 +85,14 @@ class Document extends BaseModel
return $info->toArray();
}
/**
* 更新文件信息
* @param $dat
* @param string $type
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
/**
* 更新文件信息
* @param $dat
@ -134,7 +141,7 @@ class Document extends BaseModel
} else {
$ainfo = Document::get($data['id']);
if (!$ainfo) return app("json")->fail("数据不存在");
Document::where('id', $data['id'])->save($data);
Document::where('id', $data['id'])->update($data);
if (!empty($content)) {
switch ($type) {
case Data::DOCUMENT_TYPE_ARTICLE:
@ -143,7 +150,6 @@ class Document extends BaseModel
'content' => $content
];
$model = new DocumentArticle();
$model->save($updateData);
break;
case Data::DOCUMENT_TYPE_PAGE:
$updateData = [
@ -151,14 +157,20 @@ class Document extends BaseModel
'content' => $content
];
$model = new DocumentPage();
$model->save($updateData);
break;
case Data::DOCUMENT_TYPE_PRODUCT;
$mode = new DocumentProduct();
break;
default:
//默认暂时不处理
break;
}
$info = $model->find($data['id']);
if (!$info) {
$model->insert($updateData);
} else {
$model->update($updateData);
}
}
if (!empty($data['tags'])) {
$tagModel = new TagModel();

View File

@ -36,8 +36,7 @@ class Tag extends BaseModel
if ($where['end_time'] != '') $model = $model->where("create_time", "<", strtotime($where['end_time'] . " 23:59:59"));
$count = self::counts($model);
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();
return compact('data', 'count');
}
@ -84,17 +83,18 @@ class Tag extends BaseModel
public static function getList($where): array
{
$list = cache('index:tagList');
$list = false;
if ($list) {
return json_decode($list, true);
} else {
$tagList = self::systemPage($where);
$list = [];
foreach ($tagList['data'] as $tag) {
$list[] = [
"text" => $tag['name'],
"href" => url("/index/article/tag?t=" . $tag['name'])->build()
];
}
$model = new self();
if ($where['name'] != '') $model = $model->where("title|url", "like", "%$where[name]%");
$model = $model->field('distinct name,count(1) as num')->order("num DESC")->group("name");
if ($where['page'] && $where['limit']) $model = $model->page((int)$where['page'], (int)$where['limit']);
$list = $model->select()->each(function (&$tag) {
$tag->text = $tag['name'];
$tag->href = url("/index/article/tag?t=" . $tag['name'])->build();
})->toArray();
if ($list) {
cache('index:tagList', json_encode($list), 24 * 60 * 60);
}

View File

@ -7,6 +7,7 @@ use app\common\constant\Data;
use app\common\model\Document;
use app\common\model\FriendLink as friendLinkModel;
use app\common\model\MessageForm as MessageFormModel;
use app\common\model\Tag as TagModel;
use app\common\validate\MessageForm as MessageformValidate;
use app\Request;
use think\db\exception\DataNotFoundException;
@ -170,4 +171,20 @@ class Index extends Base
$template = substr($template, 0, strpos($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

View File

@ -208,7 +208,7 @@
}
</style>
<script>
$.get("{:url('/index/article/taglist')}",function(data,status){
$.get("{:url('/index/index/taglist')}",function(data,status){
TagCloud(
".corepress-tag-container-tag1",
data.data,