Commit 4776b5f4 by 杨树贤

冲突解决

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