mirror of https://github.com/1099438829/apeblog
优化代码
This commit is contained in:
parent
fd2b715e0c
commit
6baa1003bf
|
|
@ -2,22 +2,9 @@
|
||||||
|
|
||||||
namespace app\admin\controller;
|
namespace app\admin\controller;
|
||||||
|
|
||||||
use app\common\model\AdminAuth;
|
use app\common\model\{AdminAuth, Document, FriendLink, MessageForm, AdminNotify, User};
|
||||||
use app\common\model\Document;
|
|
||||||
use app\common\model\Document as DocumentModel;
|
|
||||||
use app\common\model\Tag as TagModel;
|
|
||||||
use app\common\model\DocumentCategory;
|
|
||||||
use app\common\model\DocumentCategory as DocumentCategoryModel;
|
|
||||||
use app\common\model\FriendLink;
|
|
||||||
use app\common\model\MessageForm;
|
|
||||||
use app\common\model\AdminNotify;
|
|
||||||
use app\common\model\Tag;
|
|
||||||
use app\common\model\User;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use think\db\exception\DataNotFoundException;
|
use think\db\exception\{DataNotFoundException, DbException, ModelNotFoundException};
|
||||||
use think\db\exception\DbException;
|
|
||||||
use think\db\exception\ModelNotFoundException;
|
|
||||||
use think\facade\Request;
|
|
||||||
|
|
||||||
class Index extends AuthController
|
class Index extends AuthController
|
||||||
{
|
{
|
||||||
|
|
@ -29,14 +16,8 @@ class Index extends AuthController
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$this->assign("adminInfo", $this->adminInfo);
|
$this->assign("adminInfo", $this->adminInfo);
|
||||||
$menuList = cache(AdminAuth::getMenuCacheKey($this->adminId));
|
$this->assign("menu", AdminAuth::getAuthList($this->adminId,$this->auth));
|
||||||
if ($menuList === null) {
|
$this->assign("message", AdminNotify::pageList(5));
|
||||||
$menuList = AdminAuth::getMenu(0, $this->auth);
|
|
||||||
cache(AdminAuth::getMenuCacheKey($this->adminId), $menuList, 1 * 60 * 60);
|
|
||||||
}
|
|
||||||
$this->assign("menu", $menuList);
|
|
||||||
$messageList = AdminNotify::pageList(5);
|
|
||||||
$this->assign("message", $messageList);
|
|
||||||
return $this->fetch();
|
return $this->fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -47,20 +28,11 @@ class Index extends AuthController
|
||||||
*/
|
*/
|
||||||
public function main()
|
public function main()
|
||||||
{
|
{
|
||||||
$documentCount = Document::counts(new Document());
|
$this->assign("document_count", Document::counts());
|
||||||
$this->assign("document_count", $documentCount);
|
$this->assign("user_count", User::counts(new User()));
|
||||||
$userCount = User::counts(new User());
|
$this->assign("friend_link_count", FriendLink::counts(new FriendLink()));
|
||||||
$this->assign("user_count", $userCount);
|
$this->assign("message_form_count", MessageForm::counts(new MessageForm()));
|
||||||
$FriendLinkCount = FriendLink::counts(new FriendLink());
|
$this->assign("article_list", Document::systemPage(["page"=> 0 ,"limit" => 5])['data']);
|
||||||
$this->assign("friend_link_count", $FriendLinkCount);
|
|
||||||
$messageFormCount = MessageForm::counts(new MessageForm());
|
|
||||||
$this->assign("message_form_count", $messageFormCount);
|
|
||||||
$data =[
|
|
||||||
"page"=> 0 ,
|
|
||||||
"limit" => 5
|
|
||||||
];
|
|
||||||
$articleList = Document::systemPage($data)['data'];
|
|
||||||
$this->assign("article_list", $articleList);
|
|
||||||
return $this->fetch();
|
return $this->fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,11 +44,6 @@ class Index extends AuthController
|
||||||
*/
|
*/
|
||||||
public function menu()
|
public function menu()
|
||||||
{
|
{
|
||||||
$menuList = cache(AdminAuth::getMenuCacheKey($this->adminId));
|
return app("json")->success(AdminAuth::getAuthList($this->adminId,$this->auth));
|
||||||
if ($menuList === null) {
|
|
||||||
$menuList = AdminAuth::getMenu(0, $this->auth);
|
|
||||||
cache(AdminAuth::getMenuCacheKey($this->adminId), $menuList, 1 * 60 * 60);
|
|
||||||
}
|
|
||||||
return app("json")->success($menuList);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,22 +69,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-12">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header"><h4>常用功能</h4></div>
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="row">
|
|
||||||
<div class="example-box">
|
|
||||||
<div class="col-sm-3 col-md-2">
|
|
||||||
<a class="btn btn-primary btn-w-md" href="{:url('index/sitemap')}" type="button">网站地图</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,24 @@ class AdminAuth extends BaseModel
|
||||||
return $authList[$module . '_' . $controller . '_' . $action] ?? -1;
|
return $authList[$module . '_' . $controller . '_' . $action] ?? -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户权限列表
|
||||||
|
* @param $admin_id
|
||||||
|
* @param $auth
|
||||||
|
* @return array|mixed|object|\think\App
|
||||||
|
* @throws DataNotFoundException
|
||||||
|
* @throws DbException
|
||||||
|
* @throws ModelNotFoundException
|
||||||
|
*/
|
||||||
|
public static function getAuthList($admin_id,$auth){
|
||||||
|
$menuList = cache(self::getMenuCacheKey($admin_id));
|
||||||
|
if ($menuList === null) {
|
||||||
|
$menuList = self::getMenu(0, $auth);
|
||||||
|
cache(AdminAuth::getMenuCacheKey($admin_id), $menuList, 1 * 60 * 60);
|
||||||
|
}
|
||||||
|
return $menuList;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取菜单
|
* 获取菜单
|
||||||
* @param int $pid
|
* @param int $pid
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue