Kirin 2 months ago
parent
commit
b152ce68bc

+ 8 - 4
app/common/AdminBaseController.php

@@ -101,16 +101,20 @@ abstract class AdminBaseController extends BaseController
         }
         $data = $this->request->postMore($this->createParams, false, $this->saveDeal);
         if ($this->validate) {
-            $this->validate($data, $this->validate);
+            $this->validate($data, $this->validate, 'save');
         }
         $res = $this->service->create($data);
         if ($res) return $this->success('添加成功');
         return $this->error('添加失败');
     }
 
-    public function validate($data, $validate)
+    public function validate($data, $validate, $s)
     {
-        $res = $validate->check($data);
+        $scene = $validate->allScene() ?? [];
+        if (in_array($s, $scene))
+            $res = $validate->scene($s)->check($data);
+        else
+            $res = $validate->check($data);
         if (!$res) throw new AdminException($validate->getError());
     }
 
@@ -125,7 +129,7 @@ abstract class AdminBaseController extends BaseController
             return $this->error('数据不存在');
         $data = $this->request->postMore($this->createParams, false, $this->updateDeal);
         if ($this->validate) {
-            $this->validate($data, $this->validate);
+            $this->validate($data, $this->validate, 'update');
         }
         $res = $this->service->update($id, $data);
         if ($res) return $this->success('修改成功');

+ 1 - 0
app/controller/admin/Common.php

@@ -32,6 +32,7 @@ class Common extends AdminBaseController
             'user_info' => [
                 'id' => $adminInfo['id'],
                 'account' => $adminInfo['account'],
+                'real_name' => $adminInfo['real_name'],
                 'head_pic' => $adminInfo['head_pic'],
             ]
         ]);

+ 2 - 1
app/controller/admin/Login.php

@@ -51,12 +51,13 @@ class Login extends AdminBaseController
      */
     public function info()
     {
-        $data = SystemConfigService::more(['admin_login_slide', 'site_logo_square', 'site_logo', 'login_logo'],true);
+        $data = SystemConfigService::more(['site_name','admin_login_slide', 'site_logo_square', 'site_logo', 'login_logo'],true);
         return $this->success([
             'slide' => sys_config('admin_login_slide') ?? [],
             'logo_square' => $data['site_logo_square'] ?? '',//透明
             'logo_rectangle' => $data['site_logo'] ?? '',//方形
             'login_logo' => $data['login_logo'] ?? '',//登陆
+            'site_name' => $data['site_name'],
             'upload_file_size_max' => config('upload.filesize'),//文件上传大小kb
         ]);
     }

+ 4 - 2
app/services/system/admin/SystemAdminServices.php

@@ -95,7 +95,7 @@ class SystemAdminServices extends BaseServices
         /** @var SystemMenusServices $services */
         $services = app()->make(SystemMenusServices::class);
         [$menus, $uniqueAuth] = $services->getMenusList($adminInfo['roles'], (int)$adminInfo['level']);
-        $data = SystemConfigService::more(['site_logo', 'site_logo_square']);
+        $data = SystemConfigService::more(['site_logo', 'site_logo_square','site_name']);
         return [
             'token' => $tokenInfo['token'],
             'expires_time' => $tokenInfo['params']['exp'],
@@ -104,9 +104,11 @@ class SystemAdminServices extends BaseServices
             'user_info' => [
                 'id' => $adminInfo['id'],
                 'account' => $adminInfo['account'],
+                'real_name' => $adminInfo['real_name'],
                 'head_pic' => $adminInfo['head_pic'],
             ],
             'logo' => $data['site_logo'],
+            'site_name' => $data['site_name'],
             'logo_square' => $data['site_logo_square'],
             'prefix' => config('admin.admin_prefix')
         ];
@@ -189,7 +191,7 @@ class SystemAdminServices extends BaseServices
     {
         [$page, $limit] = $this->getPageValue();
         $list = $this->getList($where,'*', $page, $limit);
-        $count = $this->count($where);
+        $count = $this->getCount($where);
 
         /** @var SystemRoleServices $service */
         $service = app()->make(SystemRoleServices::class);

+ 7 - 7
app/services/system/config/SystemStorageServices.php

@@ -46,7 +46,7 @@ class SystemStorageServices extends BaseServices
         [$page, $limit] = $this->getPageValue();
         $config = $this->getStorageConfig((int)$where['type']);
         $where['access_key'] = $config['accessKey'];
-        $list = $this->getList($where,'*', $page, $limit);
+        $list = $this->getList($where, '*', $page, $limit);
         foreach ($list as &$item) {
             $item['_add_time'] = date('Y-m-d H:i:s', $item['add_time']);
             $item['_update_time'] = date('Y-m-d H:i:s', $item['update_time']);
@@ -194,7 +194,7 @@ class SystemStorageServices extends BaseServices
                 break;
         }
 
-        if ($this->dao->count(['type' => $type, 'name' => $name])) {
+        if ($this->getCount(['type' => $type, 'name' => $name])) {
             throw new ValidateException('云空间名称不能重复');
         }
         //保存云存储
@@ -239,7 +239,7 @@ class SystemStorageServices extends BaseServices
                     throw new ValidateException('同步失败,失败原因:' . $upload->getError());
                 }
                 foreach ($list as $item) {
-                    if (!$this->dao->count(['name' => $item['id'], 'is_delete' => 0, 'access_key' => $config['accessKey']])) {
+                    if (!$this->getCount(['name' => $item['id'], 'is_delete' => 0, 'access_key' => $config['accessKey']])) {
                         $data[] = [
                             'type' => $type,
                             'access_key' => $config['accessKey'],
@@ -259,7 +259,7 @@ class SystemStorageServices extends BaseServices
                 $list = $upload->listbuckets();
                 $config = $this->getStorageConfig($type);
                 foreach ($list as $item) {
-                    if (!$this->dao->count(['name' => $item['name'], 'is_delete' => 0, 'access_key' => $config['accessKey']])) {
+                    if (!$this->getCount(['name' => $item['name'], 'is_delete' => 0, 'access_key' => $config['accessKey']])) {
                         $region = $this->getReagionHost($type, $item['location']);
                         $data[] = [
                             'type' => $type,
@@ -281,8 +281,8 @@ class SystemStorageServices extends BaseServices
                 $list = $upload->listbuckets();
                 $config = $this->getStorageConfig($type);
                 foreach ($list as $item) {
-                    if (($id = $this->dao->value(['name' => $item['Name'], 'is_delete' => 0, 'access_key' => $config['accessKey']], 'id'))) {
-                        $this->dao->update($id, [
+                    if (($id = $this->getOneValue(['name' => $item['Name'], 'is_delete' => 0, 'access_key' => $config['accessKey']], 'id'))) {
+                        $this->update($id, [
                             'update_time' => time(),
                             'region' => $item['Location'],
                             'name' => $item['Name'],
@@ -360,7 +360,7 @@ class SystemStorageServices extends BaseServices
     {
         $res = ['name' => '', 'region' => '', 'domain' => ''];
         try {
-            $config = $this->dao->get(['type' => $type, 'status' => 1, 'is_delete' => 0]);
+            $config = $this->get(['type' => $type, 'status' => 1, 'is_delete' => 0]);
             if ($config) {
                 return ['name' => $config->name, 'region' => $config->region, 'domain' => $config->domain];
             }

+ 5 - 5
app/services/user/UserLevelServices.php

@@ -242,11 +242,11 @@ class UserLevelServices extends BaseServices
             }
 
             $this->setUserLevel($uid, $vipinfo['id']);
-            $spread_uid = $userServices->where('uid', $uid)->value('spread_uid');
-            if ($spread_uid && !in_array($spread_uid, $pass)) {
-                $pass[] = $spread_uid;
-                $this->detection($spread_uid, $pass);
-            }
+        }
+        $spread_uid = $userServices->where('uid', $uid)->value('spread_uid');
+        if ($spread_uid && !in_array($spread_uid, $pass)) {
+            $pass[] = $spread_uid;
+            $this->detection($spread_uid, $pass);
         }
         return true;
     }

+ 7 - 2
app/validate/admin/SystemAdminValidate.php

@@ -39,10 +39,10 @@ class SystemAdminValidate extends Validate
     protected $message = [
         'account.require' => '请填写管理员账号',
         'account.alphaDash' => '管理员账号应为数字和字母',
-		'account.length' => '管理员账号长度4-64位字符',
+        'account.length' => '管理员账号长度4-64位字符',
         'conf_pwd.require' => '请输入确认密码',
         'pwd.require' => '请输入密码',
-		'pwd.length' => '密码长度4-64位字符',
+        'pwd.length' => '密码长度4-64位字符',
         'real_name.require' => '请输管理员姓名',
         'roles.require' => '请选择管理员身份',
         'roles.array' => '身份必须为数组',
@@ -59,5 +59,10 @@ class SystemAdminValidate extends Validate
         'supplier_update' => ['account', 'real_name', 'phone', 'head_pic'],
     ];
 
+    public function allScene()
+    {
+        return array_keys($this->scene);
+    }
+
 
 }

+ 7 - 0
qiniu/command/stubs/validate.stub

@@ -28,4 +28,11 @@ class {%validateName%} extends Validate
     ];
 
     protected $scene = [];
+
+
+
+    public function allScene()
+    {
+        return array_keys($this->scene);
+    }
 }