53 lines
2.2 KiB
PHP
53 lines
2.2 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
require_once APPPATH . 'controllers/api/BaseController.php';
|
|
|
|
/**
|
|
* Notes:获取用户信息
|
|
* Created on: 2022/9/05 17:15
|
|
* Created by: dengbw
|
|
*/
|
|
class User extends BaseController
|
|
{
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('market/Market_sys_role_model', 'mdSysRole');
|
|
$this->load->model('market/Market_sys_menu_model', 'mdSysMenu');
|
|
}
|
|
|
|
public function index_get()
|
|
{
|
|
$re = $_SESSION;
|
|
$user = ['userId' => $re['userId'], 'username' => $re['username'], 'nickname' => $re['nickname']
|
|
, 'avatar' => "https://qs.haodian.cn/web/images/project/H5-ShiYu/default-avatar.jpg?v=1"
|
|
, 'sex' => $re['sex'], 'phone' => $re['phone'], 'introduction' => $re['introduction'], 'email' => $re['email']
|
|
, 'enabled' => true, 'accountNonLocked' => true, 'credentialsNonExpired' => true, 'accountNonExpired' => true];
|
|
$roles = $authorities = [];
|
|
if ($re['roleId']) {
|
|
$re_ro = $this->mdSysRole->get(['roleId' => $re['roleId'], 'status' => 0]);
|
|
if ($re_ro) {
|
|
$re_ro['userId'] = $re['userId'];
|
|
$roles[] = $re_ro;
|
|
if ($re_ro['menuIds']) {
|
|
$authorities = $this->mdSysMenu->select(["menuId in({$re_ro['menuIds']})" => null, 'status' => 0]
|
|
, 'sortNumber asc,menuId desc');
|
|
foreach ($authorities as $k => $v) {
|
|
$authorities[$k]['menuId'] = intval($v['menuId']);
|
|
$authorities[$k]['parentId'] = intval($v['parentId']);
|
|
$authorities[$k]['menuType'] = intval($v['menuType']);
|
|
$authorities[$k]['openType'] = intval($v['openType']);
|
|
$authorities[$k]['sortNumber'] = intval($v['sortNumber']);
|
|
$authorities[$k]['hide'] = intval($v['hide']);
|
|
$authorities[$k]['meta'] = json_decode($v['meta'], true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$user['roles'] = $roles;
|
|
$user['authorities'] = $authorities;
|
|
$this->return_response($user);
|
|
}
|
|
|
|
} |