Commit 4776b5f4 by 杨树贤

冲突解决

parent e298fda7
...@@ -57,7 +57,9 @@ START_IFRAME_TAB=true ...@@ -57,7 +57,9 @@ START_IFRAME_TAB=true
LOGIN_DOMAIN=user.semourdev.net LOGIN_DOMAIN=user.semourdev.net
PERM_URL=http://perm.semourdev.net/api/check PERM_URL=http://perm.semourdev.net/api/check
PERM_ID=12 PERM_LIST=http://perm.semourdev.net/api/perms
PERM_ID=61
PERM_GOURL=http://perm.semourdev.net PERM_GOURL=http://perm.semourdev.net
ADMIN_GROUP=1000,20000 ADMIN_GROUP=1000,20000
MENU_ID=2 MENU_ID=2
......
...@@ -37,6 +37,10 @@ class Permission ...@@ -37,6 +37,10 @@ class Permission
return $this->view('Auth', '没有访问权限', $permData['go_url']); return $this->view('Auth', '没有访问权限', $permData['go_url']);
} }
$request->menus = $menus; $request->menus = $menus;
//获取权限放到头
$perms = $this->getPerms();
$request->perms = $perms;
} }
if (!in_array($user->userId, $permData['admin_group']) && $action != 'Dashboard') {//不是超级管理员 if (!in_array($user->userId, $permData['admin_group']) && $action != 'Dashboard') {//不是超级管理员
$perm = $this->perm($request->user->userId, $action); $perm = $this->perm($request->user->userId, $action);
...@@ -47,6 +51,9 @@ class Permission ...@@ -47,6 +51,9 @@ class Permission
return $this->view('Auth', '没有访问权限', $permData['go_url']); return $this->view('Auth', '没有访问权限', $permData['go_url']);
} }
} }
return $next($request, $action); return $next($request, $action);
} }
...@@ -129,16 +136,16 @@ class Permission ...@@ -129,16 +136,16 @@ class Permission
} }
//检查权限,仅支持验证单个权限 //检查权限,仅支持验证单个权限
function perm($userId, $perm1 = '') function perm($userId, $perm = '')
{ {
$permArr = config('perm.perm'); $permArr = config('perm.perm');
$NotAuth = $permArr['notAuth']; $notAuth = $permArr['notAuth'];
$AdminID = $permArr['adminGroup']; $AdminID = $permArr['adminGroup'];
if ((!in_array($perm1, $NotAuth)) && !in_array($userId, $AdminID)) {//过滤不用鉴权的方法与用户 if ((!in_array($perm, $notAuth)) && !in_array($userId, $AdminID)) {//过滤不用鉴权的方法与用户
$permID = $permArr['id']; $permID = $permArr['id'];
$url = $permArr['url'] . '/' . $userId . '/' . $permID . '?perms=' . $perm1; $url = $permArr['url'] . '/' . $userId . '/' . $permID . '?perms=' . $perm;
$result = json_decode(curl($url, '', 0), true); $result = json_decode(curl($url, '', 0), true);
if (!isset($result['retcode']) || $result['retcode'] !== 0 || $result['data']['perms'][$perm1] == false) { if (!isset($result['retcode']) || $result['retcode'] !== 0 || $result['data']['perms'][$perm] == false) {
return false; return false;
} else { } else {
return true; return true;
...@@ -147,4 +154,16 @@ class Permission ...@@ -147,4 +154,16 @@ class Permission
return true; return true;
} }
} }
public function getPerms()
{
$userId = request()->user->userId;
$permsUrl = config('perm.perm.list') . '/' . $userId . '/' . config('perm.perm.id') . '/';
$permsResult = json_decode(curl($permsUrl), true);
$perms = [];
if (isset($permsResult['retcode']) && $permsResult['retcode'] === 0) {
$perms = $permsResult['data']['perms'];
}
return $perms;
}
} }
...@@ -2,18 +2,17 @@ ...@@ -2,18 +2,17 @@
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
define("DIGITS_TWO",2); define("DIGITS_TWO", 2);
define("DIGITS_FOUR",4); define("DIGITS_FOUR", 4);
define("DIGITS_SIX",6); define("DIGITS_SIX", 6);
if (! function_exists('user_admin_config')) { if (!function_exists('user_admin_config')) {
function user_admin_config($key = null, $value = null) function user_admin_config($key = null, $value = null)
{ {
$session = session(); $session = session();
if (! $config = $session->get('admin.config')) { if (!$config = $session->get('admin.config')) {
$config = config('admin'); $config = config('admin');
$config['lang'] = config('app.locale'); $config['lang'] = config('app.locale');
} }
...@@ -22,9 +21,7 @@ if (! function_exists('user_admin_config')) { ...@@ -22,9 +21,7 @@ if (! function_exists('user_admin_config')) {
foreach ($key as $k => $v) { foreach ($key as $k => $v) {
Arr::set($config, $k, $v); Arr::set($config, $k, $v);
} }
$session->put('admin.config', $config); $session->put('admin.config', $config);
return; return;
} }
...@@ -90,23 +87,24 @@ function curl($url, $params = false, $ispost = 0, $https = 0, $cookie = '', $tim ...@@ -90,23 +87,24 @@ function curl($url, $params = false, $ispost = 0, $https = 0, $cookie = '', $tim
* @$thousandsSymbol 千分位字符串隔开 1,200,3.4567 * @$thousandsSymbol 千分位字符串隔开 1,200,3.4567
* *
* define("DIGITS_TWO",2); * define("DIGITS_TWO",2);
define("DIGITS_FOUR",4); * define("DIGITS_FOUR",4);
define("DIGITS_SIX",6); * define("DIGITS_SIX",6);
*/ */
if (!function_exists('decimal_number_format')) { if (!function_exists('decimal_number_format')) {
function decimal_number_format($amount,$digits=DIGITS_TWO,$currency="",$thousandsSymbol=""){ function decimal_number_format($amount, $digits = DIGITS_TWO, $currency = "", $thousandsSymbol = "")
{
$amount = floatval(strval($amount)); $amount = floatval(strval($amount));
//格式化币别 //格式化币别
if($currency){ if ($currency) {
$minus = $amount < 0 ? '-' : ''; $minus = $amount < 0 ? '-' : '';
$numerical = number_format(abs($amount),$digits,".",$thousandsSymbol); $numerical = number_format(abs($amount), $digits, ".", $thousandsSymbol);
$sign = Arr::get(config("field.currency_sign"),intval($currency),""); $sign = \Arr::get(config("field.currency_sign"), intval($currency), "");
if (!empty($sign)) { if (!empty($sign)) {
$numerical = $sign . $numerical; $numerical = $sign . $numerical;
} }
return $minus ? $minus.$numerical : $numerical; return $minus ? $minus . $numerical : $numerical;
}else{ } else {
$numerical = number_format($amount,$digits,".",""); $numerical = number_format($amount, $digits, ".", "");
return $numerical; return $numerical;
} }
} }
...@@ -125,7 +123,8 @@ if (!function_exists('drawLetter')) { ...@@ -125,7 +123,8 @@ if (!function_exists('drawLetter')) {
* 格式化型号, echo DrawLetter("LMGAGA 质量 &&*****") 输出:LMGAGA * 格式化型号, echo DrawLetter("LMGAGA 质量 &&*****") 输出:LMGAGA
* @param $g string 关键词 * @param $g string 关键词
*/ */
function drawLetter($g){ function drawLetter($g)
{
$g = preg_replace('/[\x{4e00}-\x{9fff}]+/u', '', $g); $g = preg_replace('/[\x{4e00}-\x{9fff}]+/u', '', $g);
$g = preg_replace('/[^A-Za-z0-9]+/', '', $g); $g = preg_replace('/[^A-Za-z0-9]+/', '', $g);
return strtoupper($g); return strtoupper($g);
...@@ -149,7 +148,8 @@ if (!function_exists('buildQuery')) { ...@@ -149,7 +148,8 @@ if (!function_exists('buildQuery')) {
} else { } else {
$query->where($subWhere[0], $subWhere[1]); $query->where($subWhere[0], $subWhere[1]);
} }
} else if (count($subWhere) == 3) { } else {
if (count($subWhere) == 3) {
$fiels = $subWhere[0] ?? ""; $fiels = $subWhere[0] ?? "";
$exp = $subWhere[1] ?? null; $exp = $subWhere[1] ?? null;
$value = $subWhere[2] ?? null; $value = $subWhere[2] ?? null;
...@@ -163,13 +163,15 @@ if (!function_exists('buildQuery')) { ...@@ -163,13 +163,15 @@ if (!function_exists('buildQuery')) {
} }
} }
} }
}
return $query; return $query;
} }
} }
if (!function_exists('echoToSql')) { if (!function_exists('echoToSql')) {
function echoToSql($query){ function echoToSql($query)
$tmp = str_replace('?', '"'.'%s'.'"', $query->toSql()); {
$tmp = str_replace('?', '"' . '%s' . '"', $query->toSql());
$tmp = vsprintf($tmp, $query->getBindings()); $tmp = vsprintf($tmp, $query->getBindings());
dd($tmp); dd($tmp);
} }
...@@ -184,9 +186,10 @@ if (!function_exists('echoToSql')) { ...@@ -184,9 +186,10 @@ if (!function_exists('echoToSql')) {
* @param $val * @param $val
* @return array * @return array
*/ */
function flipArrayPluck($arr,$newKey,$seachKey){ function flipArrayPluck($arr, $newKey, $seachKey)
{
$newArr = []; $newArr = [];
foreach($arr as $v){ foreach ($arr as $v) {
$newArr[$v[$newKey]][] = $v[$seachKey]; $newArr[$v[$newKey]][] = $v[$seachKey];
} }
return $newArr; return $newArr;
...@@ -194,16 +197,17 @@ function flipArrayPluck($arr,$newKey,$seachKey){ ...@@ -194,16 +197,17 @@ function flipArrayPluck($arr,$newKey,$seachKey){
if (!function_exists('checkArrayValuesNotEmpty')) { if (!function_exists('checkArrayValuesNotEmpty')) {
function checkArrayValuesNotEmpty($arr=[]){ function checkArrayValuesNotEmpty($arr = [])
{
$result = true; $result = true;
if(is_array($arr)){ if (is_array($arr)) {
foreach($arr as $val){ foreach ($arr as $val) {
if(empty($val)){ if (empty($val)) {
$result = false; $result = false;
break; break;
} }
} }
}else{ } else {
$result = false; $result = false;
} }
return $result; return $result;
...@@ -379,12 +383,12 @@ function price_format($price, $sign = 0, $num = 2, $sep = '') ...@@ -379,12 +383,12 @@ function price_format($price, $sign = 0, $num = 2, $sep = '')
$minus = $price < 0 ? '-' : ''; $minus = $price < 0 ? '-' : '';
$price = floatval(strval($price)); $price = floatval(strval($price));
$price = number_format(abs($price), $num, '.', $sep); $price = number_format(abs($price), $num, '.', $sep);
$sign = \Arr::get(config("field.currency_sign"),intval($sign),""); $sign = \Arr::get(config("field.currency_sign"), intval($sign), "");
if (!empty($sign)) { if (!empty($sign)) {
$price = $sign . $price; $price = $sign . $price;
} }
if($minus){ if ($minus) {
return $minus.$price; return $minus . $price;
} }
return $price; return $price;
} }
......
...@@ -3,6 +3,7 @@ return [ ...@@ -3,6 +3,7 @@ return [
'perm' => [ 'perm' => [
'id' => env('PERM_ID'), 'id' => env('PERM_ID'),
'url' => env('PERM_URL'), 'url' => env('PERM_URL'),
'list' => env('PERM_LIST'),
'go_url' => env('PERM_GOURL'), 'go_url' => env('PERM_GOURL'),
'admin_group' => explode(',', env('ADMIN_GROUP')),//管理员权限组,有所有权限 'admin_group' => explode(',', env('ADMIN_GROUP')),//管理员权限组,有所有权限
'menu_id' => env('MENU_ID'), 'menu_id' => env('MENU_ID'),
......
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 sign in to comment