修改权限
This commit is contained in:
parent
17a9c97eed
commit
82f9e4aa84
@ -90,9 +90,9 @@ class MerchantAdminDao extends BaseDao
|
||||
* @author xaboy
|
||||
* @day 2020/7/7
|
||||
*/
|
||||
public function merIdByAdmin(int $merId)
|
||||
public function merIdByAdmin(int $merId,$where=[],$level=0)
|
||||
{
|
||||
return MerchantAdmin::getDB()->where('mer_id', $merId)->where('level', 0)->find();
|
||||
return MerchantAdmin::getDB()->where('mer_id', $merId)->where('level',$level)->where($where)->find();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
namespace app\controller\admin\system\auth;
|
||||
|
||||
use app\common\model\system\Relevance;
|
||||
use crmeb\basic\BaseController;
|
||||
use app\common\repositories\system\auth\MenuRepository;
|
||||
use app\validate\admin\MenuValidate;
|
||||
@ -21,6 +22,7 @@ use think\App;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* Class Menu
|
||||
@ -193,9 +195,19 @@ class Menu extends BaseController
|
||||
{
|
||||
$pre = '/' . config('admin.merchant_prefix');
|
||||
$merchant = $this->request->merchant();
|
||||
$menus = $this->request->adminInfo()->level
|
||||
? $this->repository->ruleByMenuList($this->request->adminRule(), $this->merchant)
|
||||
: ($merchant->type_id ? $this->repository->typesByValidMenuList($merchant->type_id) : $this->repository->getValidMenuList($this->merchant));
|
||||
$level = $this->request->adminInfo()->level;
|
||||
if($level){
|
||||
if($level==2){
|
||||
|
||||
$value=Db::name('merchant_type')->where('type_code','dianpu_yunying')->value('mer_type_id');
|
||||
$column_ids=Relevance::where('left_id', $value)->where('type','mer_auth')->column('right_id');
|
||||
$menus= Db::name('system_menu')->whereIn('menu_id',$column_ids)->column('menu_name,route,params,icon,pid,menu_id');
|
||||
}else{
|
||||
$menus= $this->repository->ruleByMenuList($this->request->adminRule(), $this->merchant);
|
||||
}
|
||||
}else{
|
||||
$menus=($merchant->type_id ? $this->repository->typesByValidMenuList($merchant->type_id) : $this->repository->getValidMenuList($this->merchant));
|
||||
}
|
||||
foreach ($menus as $k => $menu) {
|
||||
$menu['route'] = $pre . $menu['route'];
|
||||
$menus[$k] = $menu;
|
||||
|
@ -243,7 +243,25 @@ class Merchant extends BaseController
|
||||
{
|
||||
if (!$this->repository->exists($id))
|
||||
return app('json')->fail('数据不存在');
|
||||
$admins=$this->request->adminInfo();
|
||||
if($admins['admin_id']!=1){
|
||||
$adminInfo = $adminRepository->merIdByAdmin($id,['account'=>'yy'.$admins['account']],2);
|
||||
if(!$adminInfo){
|
||||
$pwd =password_hash(rand(100000,999999), PASSWORD_BCRYPT);
|
||||
$data =[
|
||||
'mer_id' => $id,
|
||||
'pwd'=>$pwd,
|
||||
'account'=>'yy'.$admins['account'],
|
||||
'real_name' => $admins['real_name'],
|
||||
'phone' => $admins['phone'],
|
||||
'level' => 2
|
||||
];
|
||||
$adminRepository->create($data);
|
||||
$adminInfo = $adminRepository->merIdByAdmin($id,['account'=>'yy'.$admins['account']],2);
|
||||
}
|
||||
}else{
|
||||
$adminInfo = $adminRepository->merIdByAdmin($id);
|
||||
}
|
||||
$tokenInfo = $adminRepository->createToken($adminInfo);
|
||||
$admin = $adminInfo->toArray();
|
||||
unset($admin['pwd']);
|
||||
|
Loading…
x
Reference in New Issue
Block a user