Commit b3b6e9ff authored by hujun's avatar hujun

代码修改

parent 40859902
......@@ -429,6 +429,11 @@ class Auth extends Basic
}
}
public function getMenu() {
$menu_data = Session::get('user_info');
return $this->response(200, '取值', $menu_data);
}
}
\ No newline at end of file
......@@ -102,7 +102,7 @@ class Label extends Basic
if ($this->request->isPost()) {
$data = input('post.');
$data['operation_id']= Session::get("userinfo.id");//操作人id
$data['operation_id']= Session::get("user_info.id");//操作人id
if($table->repetition('name',$data['name'])&& empty($data['id'])){
return $this->response(100, 'url存在重复值');
}
......
......@@ -34,7 +34,7 @@ class Login extends Basic
/**
* 登录接口
*
* @return \think\Response
* @return \think\Response|void
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
......@@ -49,36 +49,37 @@ class Login extends Basic
return $this->response('100','用户名或密码不能为空');
}
$filed=" a.id,a.store_id,a.auth_group_id,a.district_id,a.level,a.name,a.phone,a.sex,a.img,a.status,a.admin_off,
ifnull(s.store_name,'')store_name,ifnull(d.district_name,'')district_name,g.rules,g.status as g_status";
$filed = " a.id,a.store_id,a.auth_group_id,a.district_id,a.level,a.name,a.phone,a.sex,a.img,a.status,a.admin_off,
ifNull(s.store_name,'')store_name,ifNull(d.district_name,'')district_name,g.rules,g.status as g_status";
$join=[
['a_store s', ' a.store_id=a.id','left'],
['a_district d','a.district_id=d.id','left'],
['auth_group g','a.auth_group_id=g.id','left']
$join = [
['a_store s', ' a.store_id=a.id','left'],
['a_district d','a.district_id=d.id','left'],
['auth_group g','a.auth_group_id=g.id','left']
];
$params["name"] = $name;
$password = md5($password);
$where="( phone='{$name}') and password='$password' ";
$list=$this->loginAgent->verifyUser($filed,$join,$where);
$where = "( phone='{$name}') and password='$password' ";
$list = $this->loginAgent->verifyUser($filed,$join,$where);
if(!$list) {
return $this->response('101','用户名或密码错误');
}
if($list['g_status']=='1') {
return $this->response('102','用户所在角色组已冻结');
}
if($list['admin_off']!='0'||empty($list['rules'])) {
if($list['admin_off']!= '0'|| empty($list['rules'])) {
return $this->response('103','用户无后台访问权限');
}else{
$rules = trim($list['rules'],',');
//查询后台菜单
$where ="id in({$rules})and is_menu=1 and status=0 and pid=1 ";
$nav = $this->authRule->loginRule($where);
$nav2 = array();
$url = '';//跳转页面
$where ="id in({$rules}) and is_menu=1 and status=0 and pid=1 ";
$nav = $this->authRule->loginRule($where);
$nav2 = array();
$url = '';//跳转页面
foreach ($nav as $k=> $v){
if($k == '0'){
$url = $v->name;
......@@ -91,18 +92,18 @@ class Login extends Basic
//搜索菜单功能
$where = "id in({$rules}) and is_menu=0 and status=0 ";
$r = $this->authRule->loginRule($where);
$r2 = array();
$auth_rule = $this->authRule->loginRule($where);
$auth_rule_arr = array();
foreach($r as $v) {
foreach($auth_rule as $v) {
$buttonUrl = explode('/',$v->name);
$v['bt'] = $buttonUrl[1];
$r2[$v->pid][] = $v;
$v['action_control'] = $buttonUrl[1];
$auth_rule_arr[$v->pid][] = $v;
}
foreach($nav2 as $k=> $v){
if(!empty($r2[$k])){
$nav2[$k]['cz'] = $r2[$k];
if(!empty($auth_rule_arr[$k])){
$nav2[$k]['operation'] = $auth_rule_arr[$k];
}
}
......@@ -112,19 +113,19 @@ class Login extends Basic
Session::set("userName",$list["name"]);
Session::set("userId",$list["id"]);
Session::set("userinfo",$list2);
Session::set("usertable",'agent');
Session::set("user_info",$list2);
Session::set("lastLoginTime",time());
$this->operating_records($list["id"],1,'后台登陆'); //记录操作日志
$data['url']=$url;
$data['data']=$list2;
$data['url'] = $url;
$data['data'] = $list2;
if($this->request->isAjax()) {
return $this->response('200', '登录成功', $data);
}else {
$this->redirect('/admin.php/'.$url);
}
return ;
}
/**
......
......@@ -149,7 +149,7 @@ class Member extends Basic{
if(!empty($params['content'])&&!empty($params['user_id'])){
$params['id']='';
$params['labels_id']=0;
$params['agent_id'] = Session::get("userinfo.id");
$params['agent_id'] = Session::get("user_info.id");
$params['type']=2;
$params['create_time'] =$time;
$params['update_time'] =$time;
......@@ -177,7 +177,7 @@ class Member extends Basic{
if ($this->params['id']) {
//编辑
$data['start'] = $this->user->edit($this->params, $this->params['id']);
$this->operating_records(Session::get("userinfo.id"), $type=3, $remark='用户编辑',0,$this->params['id']);
$this->operating_records(Session::get("user_info.id"), $type=3, $remark='用户编辑',0,$this->params['id']);
}
} else {
$data['list'] = $this->user->getClient($this->params['id']);
......
......@@ -72,7 +72,7 @@ class Basic extends Controller
* @return Response
*/
public function userAuth($requestPath){
$session = Session::get("userinfo.nav");
$session = Session::get("user_info.nav");
$rule = 0;
//判断当前控制器用户是否拥有进入权限
foreach ($session as $v){
......@@ -125,6 +125,12 @@ class Basic extends Controller
return Response::create($result, $type);
}
/**
* @return Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function navigation(){
$table=New AuthGroup;
$data=$table->where("pid=1")->select();
......
......@@ -17,9 +17,6 @@ class AuthRule extends BaseModel
// 'birthday' => 'timestamp',
// ];
/**
* 将格式数组转换为树
*
......@@ -47,6 +44,14 @@ class AuthRule extends BaseModel
return;
}
/**
* @param $list
* @param string $title
* @param string $pk
* @param string $pid
* @param int $root
* @return array
*/
public function toFormatTree($list,$title = 'title',$pk='id',$pid = 'pid',$root = 0){
$list = list_to_tree($list,$pk,$pid,'_child',$root);
$this->formatTree = array();
......@@ -54,8 +59,6 @@ class AuthRule extends BaseModel
return $this->formatTree;
}
/**
* 记录总数
*
......@@ -68,9 +71,9 @@ class AuthRule extends BaseModel
return $this->alias($as)->where($params)->count();
}
/**查询不带分页
/**
* 查询不带分页
*
* @param string $order
* @param string $field
* @param string $join
......@@ -81,16 +84,17 @@ class AuthRule extends BaseModel
* @throws \think\exception\DbException
*/
public function authRuleList2( $order = '', $field = '',$join='', $where = ''){
$data = $this->field($field)
return $this->field($field)
->alias('a')
->join($join)
->where($where)
->order($order)
->select();
return $data;
}
/**查询带分页
/**
* 查询带分页
*
* @param int $p
* @param int $pageSize
* @param string $order_
......@@ -103,7 +107,7 @@ class AuthRule extends BaseModel
* @throws \think\exception\DbException
*/
public function authRuleList($p = 1, $pageSize = 15, $order_ = '', $field = '',$join='', $where = ''){
$data = $this->field($field)
return $this->field($field)
->alias('a')
->join($join)
->where($where)
......@@ -111,10 +115,11 @@ class AuthRule extends BaseModel
->limit($pageSize)
->page($p)
->select();
return $data;
}
/**检查重复
/**
* 检查重复
*
* @param $name
* @param $key
* @return bool
......@@ -123,11 +128,11 @@ class AuthRule extends BaseModel
* @throws \think\exception\DbException
*/
public function repetition($name,$key){
$r=$this->field($name)
$data = $this->field($name)
->where($name,'=',$key)
->select();
//$this->getLastSql();
if($r){
if($data){
return true;
}else{
return false;
......@@ -142,21 +147,21 @@ class AuthRule extends BaseModel
* @throws \think\exception\DbException
*/
public function loginRule($where){
$r=$this->field('id,name,title,pid')
return $this->field('id,name,title,pid')
->where($where)
->select();
// $this->getLastSql();
return $r;
}
//更新数据
/**
* 更新数据
*
* @param $name
* @param $key
* @param $ids
* @return $this
*/
public function saveStatus($name,$key,$ids){
$r = $this->where("id",'in',$ids)->update([$name=>$key]);
return $r;
}
}
\ No newline at end of file
......@@ -163,6 +163,7 @@ Route::group('index', [
'select_by_phone' => ['index/remark/select_by_phone', [ 'method' => 'get|post' ] ], //后台客户详情--客方搜索
'setting_index' => ['index/Setting/index', [ 'method' => 'get' ] ], //全局参数设置页面
'getSetting' => ['index/Setting/getSetting', [ 'method' => 'get|post' ] ], //新增和修改全局参数设置
'getMenu' => ['index/Auth/getMenu', [ 'method' => 'get|post' ] ], //新增和修改全局参数设置
]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment