Commit 43fd6fb9 authored by zfc's avatar zfc

对应接口增删改控制

parent 4135e7fb
......@@ -46,11 +46,21 @@ class Agent extends Basic
return view('save_agent');
}
/*********************接口******************************/
//首页显示列表
/**首页显示列表【接口】
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function AgentList(){
$table= new AAgents;
$data['status'] = 200;
$data['msg'] = '';
//获取当前模块可操作按钮start********************************
$userRule = Session::get('userRule');
$data['cz']=$userRule['cz'];
//获取当前模块可操作按钮end**********************************
$params = $this->request->param();
//获取操作权限
$userRule=Session::get('userRule');
......@@ -188,7 +198,7 @@ class Agent extends Basic
}
//
......
......@@ -11,6 +11,8 @@ namespace app\index\controller;
use app\index\extend\Basic;
use app\model\AuthGroup;
use app\model\AuthRule;
use think\Session;
class Auth extends Basic
{
protected $authGroupModel;
......@@ -47,7 +49,10 @@ class Auth extends Basic
public function getAuth() {
$data['status'] = 200;
$data['msg'] = '';
//获取当前模块可操作按钮start********************************
$userRule = Session::get('userRule');
$data['cz']=$userRule['cz'];
//获取当前模块可操作按钮end**********************************
$params = $this->request->param();
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
......@@ -300,8 +305,20 @@ class Auth extends Basic
return view('auth_rule_index');
}
//权限列表
/**权限列表【接口】
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function authRuleList(){
//获取当前模块可操作按钮start********************************
$userRule = Session::get('userRule');
$data['cz']=$userRule['cz'];
//获取当前模块可操作按钮end**********************************
$table= new authRule;
$data['status'] = 200;
$data['msg'] = '';
......@@ -329,7 +346,14 @@ class Auth extends Basic
public function AuthRuleBox(){
return view('auth_rule_box');
}
//分类列表
/**分类列表【接口】
* @param string $fu
* @return false|\PDOStatement|string|\think\Collection|\think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function AuthClass($fu='0'){
$table=new AuthRule;
$data['status'] = 200;
......@@ -347,7 +371,13 @@ class Auth extends Basic
}
}
//新增编辑权限
/**新增编辑权限【接口】
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function updateAuthRule(){
$group_id=$this->request->param('id');
$table= New AuthRule;
......
......@@ -45,28 +45,9 @@ class Login extends Basic
return view("/login/login", [ "msg" => "用户名或密码不能为空" ]);
}
// if($name=='admin'){
// $params["name"] = $name;
// $params["pswd"] = md5(md5($passwd));
// $result = $this->loginDb->verifyUser($params);
//
// if (count($result) > 0) {
// // 更新登录信息
// $this->loginDb->updateLoginTime($result[0]["id"]);
//
// Session::set("userName",$result[0]["name"]);
// Session::set("userId",$result[0]["id"]);
// Session::set("usertable",'admin');
// Session::set("lastLoginTime",time());
// $this->operating_records($result[0]["id"],1,'后台登陆'); //记录操作日志
// $this->redirect('/admin.php/index/banner');
// } else {
// return view("/login/login", [ "msg" => "用户名或密码错误" ]);
// }
// }else{
//条件
$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";
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'],
......@@ -76,18 +57,21 @@ class Login extends Basic
$password = md5($password);
$where="( phone='{$name}') and password='$password' ";
$list=$this->loginAgent->verifyUser($filed,$join,$where);
// prt($list->toArray());//转化arr
if(!$list){
return view("/login/login", [ "msg" => "用户名或密码错误" ]);
}
prt($list->toArray());//转化arr
if($list['g_status']=='1'){
return view("/login/login", [ "msg" => "用户所在角色组已冻结" ]);
}
if($list['admin_off']!='0'||empty($list['rules'])){
return view("/login/login", [ "msg" => "用户无后台访问权限" ]);
}else{
$rules=trim($list['rules'],',');
//查询后台菜单
$where ="id in({$rules})and is_menu=1 and status=0 and pid=1 ";
$nav=$this->authRule->loginRule($where);
//prt(collection($nav)->toArray());
$nav2=array();
$url='';//跳转页面
foreach ($nav as $k=> $v){
......@@ -103,9 +87,13 @@ class Login extends Basic
$r2 = array();
foreach($r as $v){
$r2[$v->pid][] = $v;
$buttonUrl=explode('/',$v->name);
$v['bt']=$buttonUrl[1];
$r2[$v->pid][] = $v;
}
foreach($nav2 as $k=> $v){
if($r2[$k]){
$nav2[$k]['cz'] = $r2[$k];
......@@ -114,6 +102,7 @@ class Login extends Basic
$list['nav'] = $nav2;
$list2 = $list->toArray();//转化arr
}
Session::set("userName",$list["name"]);
Session::set("userId",$list["id"]);
......
......@@ -14,6 +14,7 @@ use app\model\GOperatingRecords;
use think\Controller;
use think\Request;
use think\Response;
use think\Route;
use think\Session;
use think\Db;
use app\model\AuthRule;
......@@ -32,6 +33,7 @@ class Basic extends Controller
public $userId;
public $lastLoginTime;
protected $filterVerify = array(
......@@ -71,9 +73,10 @@ class Basic extends Controller
* @param $requestPath
* @return Response
*/
public function userAuth($requestPath){
$session = Session::get("userinfo.nav");
//prt($session);
$rule = 0;
if ($session != NULL) {
//判断当前控制器用户是否拥有进入权限
......@@ -88,8 +91,6 @@ class Basic extends Controller
if ($rule == 0){
if ($this->request->isAjax()){
return $this->response('300','没有权限');
} else {
// $this->error('没有当前页面权限');
}
} else {
Session::set("userRule",$rule);
......
......@@ -16,7 +16,20 @@ public function saveList(){
}
//分页列表
/**分页列表
* @param int $p
* @param int $pageSize
* @param string $order_
* @param string $field
* @param string $join
* @param string $where
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getListJoin($p = 1, $pageSize = 15, $order_ = 'id desc', $field = '',$join='', $where = '')
{
$data = $this->field($field)
......@@ -31,9 +44,14 @@ public function saveList(){
return $data;
}
/**
*检查重复
*
/**检查重复
* @param $name
* @param $key
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function repetition($name,$key){
$r=$this->field($name)
......@@ -55,7 +73,14 @@ public function saveList(){
public function delUid($name,$ids){
$this->where($name,'in',$ids)->delete();
}
//通过ids批量添加数据
/**通过ids批量添加数据
* @param $ids
* @param $data
* @return array|false|int
* @throws \Exception
*/
public function addAllAccess($ids,$data){
$idarr=explode($ids);
if(is_array($idarr)){
......@@ -108,6 +133,15 @@ public function saveList(){
return $data;
}
/**
* @param $field
* @param $join
* @param $params
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function verifyUser($field,$join,$params)
{
......
......@@ -3,7 +3,6 @@
namespace app\model;
use think\Model;
class AuthRule extends BaseModel
{
......@@ -61,6 +60,7 @@ class AuthRule extends BaseModel
* 记录总数
*
* @param $params
* @param $as
* @return int|string
*/
public function getTotal($params,$as='')
......@@ -68,7 +68,18 @@ class AuthRule extends BaseModel
return $this->alias($as)->where($params)->count();
}
//查询不带分页
/**查询不带分页
* @param string $order
* @param string $field
* @param string $join
* @param string $where
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function authRuleList2( $order = '', $field = '',$join='', $where = ''){
$data = $this->field($field)
->alias('a')
......@@ -79,7 +90,18 @@ class AuthRule extends BaseModel
return $data;
}
//查询带分页
/**查询带分页
* @param int $p
* @param int $pageSize
* @param string $order_
* @param string $field
* @param string $join
* @param string $where
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function authRuleList($p = 1, $pageSize = 15, $order_ = '', $field = '',$join='', $where = ''){
$data = $this->field($field)
->alias('a')
......@@ -91,9 +113,14 @@ class AuthRule extends BaseModel
->select();
return $data;
}
/**
*检查重复
*
/**检查重复
* @param $name
* @param $key
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function repetition($name,$key){
$r=$this->field($name)
......@@ -106,7 +133,14 @@ class AuthRule extends BaseModel
return false;
}
}
/**
* @param $where
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function loginRule($where){
$r=$this->field('id,name,title,pid')
->where($where)
......
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