初始化代码
This commit is contained in:
10
application/anchor/model/Capital.php
Normal file
10
application/anchor/model/Capital.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace app\anchor\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class Capital extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
63
application/anchor/model/SystemMenu.php
Normal file
63
application/anchor/model/SystemMenu.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace app\anchor\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class SystemMenu extends Model
|
||||
{
|
||||
|
||||
// 获取初始化数据
|
||||
public function getSystemInit($aid = 0)
|
||||
{
|
||||
$homeInfo = [
|
||||
'title' => '首页',
|
||||
'href' => '',
|
||||
];
|
||||
$logoInfo = [
|
||||
'title' => '系统 管理',
|
||||
'image' => 'images/logo.png',
|
||||
];
|
||||
$menuInfo = $this->getMenuList($aid);
|
||||
$systemInit = [
|
||||
'homeInfo' => $homeInfo,
|
||||
'logoInfo' => $logoInfo,
|
||||
'menuInfo' => $menuInfo,
|
||||
];
|
||||
return $systemInit;
|
||||
}
|
||||
|
||||
// 获取菜单列表
|
||||
private function getMenuList($aid)
|
||||
{
|
||||
$menuList = Db::name('system_menu_anchor')
|
||||
->field('id,pid,title,icon,href,target')
|
||||
->where('status', 1)
|
||||
->where('type', 'in', [1, 2])
|
||||
->order('sort', 'desc')
|
||||
->select();
|
||||
|
||||
$menuList = $this->buildMenuChild(0, $menuList);
|
||||
return $menuList;
|
||||
}
|
||||
|
||||
//递归获取子菜单
|
||||
private function buildMenuChild($pid, $menuList)
|
||||
{
|
||||
$treeList = [];
|
||||
foreach ($menuList as &$v) {
|
||||
|
||||
if ($pid == $v['pid']) {
|
||||
$node = $v;
|
||||
$child = $this->buildMenuChild($v['id'], $menuList);
|
||||
if (!empty($child)) {
|
||||
$node['child'] = $child;
|
||||
}
|
||||
// todo 后续此处加上用户的权限判断
|
||||
$treeList[] = $node;
|
||||
}
|
||||
}
|
||||
return $treeList;
|
||||
}
|
||||
}
|
||||
24
application/anchor/model/User.php
Normal file
24
application/anchor/model/User.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace app\anchor\model;
|
||||
|
||||
use think\Model;
|
||||
use think\DB;
|
||||
|
||||
class User extends Model
|
||||
{
|
||||
public function check_login_token($login_token)
|
||||
{
|
||||
if (empty($login_token)) {
|
||||
return ['code' => 201, 'msg' => '登录失效', 'data' => ''];
|
||||
}
|
||||
$map = [];
|
||||
$map[] = ['login_token', '=', $login_token];
|
||||
$user_info = db::name('user')->where($map)->find();
|
||||
if (empty($user_info)) {
|
||||
return ['code' => 201, 'msg' => '登录失效', 'data' => ''];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '登录成功', 'data' => $user_info['uid']];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user