From cb9961d87d29adff72df0cedc3a24252a1e12498 Mon Sep 17 00:00:00 2001 From: caoming <604844710@qq.com> Date: Wed, 30 Oct 2019 12:33:16 +0800 Subject: [PATCH] app-ht(v1.8.6 build 13) 1.区分后台账号和厂商账号登录,返回不同的菜单。 --- app-ht/config/params.php | 3 ++- app-ht/modules/my/controllers/DefaultController.php | 12 ++++++++++++ app-ht/modules/my/views/default/my-index.php | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ app-ht/views/layouts/_main-content.php | 1 + app-ht/views/layouts/routes.php | 227 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------- common/models/AdminLog.php | 8 -------- domain/admin/models/AuthUsersRoles.php | 16 ++++++++++++++++ domain/manufacturer/Manufacturer.php | 25 +++++++++++++++++++++++-- 8 files changed, 246 insertions(+), 108 deletions(-) create mode 100644 app-ht/modules/my/views/default/my-index.php create mode 100644 domain/admin/models/AuthUsersRoles.php diff --git a/app-ht/config/params.php b/app-ht/config/params.php index 2d23b29..dd36d7a 100644 --- a/app-ht/config/params.php +++ b/app-ht/config/params.php @@ -1,4 +1,5 @@ 'v1.8.6 build 12', + 'VERSION' => 'v1.8.6 build 13', + 'MANUFACTURE_ROLE_ID' => 1 ]; \ No newline at end of file diff --git a/app-ht/modules/my/controllers/DefaultController.php b/app-ht/modules/my/controllers/DefaultController.php index a337056..1915716 100644 --- a/app-ht/modules/my/controllers/DefaultController.php +++ b/app-ht/modules/my/controllers/DefaultController.php @@ -28,6 +28,18 @@ class DefaultController extends BaseController } /** + * 账号设置 + */ + public function actionMyIndex() + { + $model = $this->getUser(); + + return $this->render('my-index', [ + 'model' => $model, + ]); + } + + /** * 更新执行动作 */ public function actionDoUpdate() diff --git a/app-ht/modules/my/views/default/my-index.php b/app-ht/modules/my/views/default/my-index.php new file mode 100644 index 0000000..7f87032 --- /dev/null +++ b/app-ht/modules/my/views/default/my-index.php @@ -0,0 +1,62 @@ +title = '修改资料'; +$this->params['breadcrumbs'][] = '账号设置'; +$this->params['breadcrumbs'][] = $this->title; + + + +?> + +
\ No newline at end of file diff --git a/app-ht/views/layouts/_main-content.php b/app-ht/views/layouts/_main-content.php index 1b0dd2e..1d3cfc6 100644 --- a/app-ht/views/layouts/_main-content.php +++ b/app-ht/views/layouts/_main-content.php @@ -26,6 +26,7 @@ class Router '系统' => 'glyphicon glyphicon-hdd', '设置' => 'glyphicon glyphicon-cog', '自动化' => 'glyphicon glyphicon-time', + '账号' => 'glyphicon glyphicon-user', ]; /** diff --git a/app-ht/views/layouts/routes.php b/app-ht/views/layouts/routes.php index ebcb91a..06fb75c 100644 --- a/app-ht/views/layouts/routes.php +++ b/app-ht/views/layouts/routes.php @@ -1,101 +1,134 @@ '/dashboard', - 'label' => '欢迎', - ], - [ - 'path' => '/manufacturer', - 'label' => '厂商', - 'routes' => [ - [ - 'path' => '/manufacturer', - 'redirect' => '/manufacturer/manufacturer/index' - ], - ['label' => '厂商管理', 'path' => '/manufacturer/manufacturer/index'], +$user = Yii::$app->user->identity; +if (isset($user->is_manufacture) && $user->is_manufacture == 1) { + return [ + [ + 'path' => '/dashboard', + 'label' => '欢迎', + ], + [ + 'path' => '/upgrade', + 'label' => '版本', + 'routes' => [ + [ + 'path' => '/upgrade', + 'redirect' => '/upgrade/upgrade/index' + ], + ['label' => '版本管理', 'path'=> '/upgrade/upgrade/index'], + ] + ], + [ + 'path' => '/myself', + 'label' => '账号', + 'routes' => [ + [ + 'path' => '/myself', + 'redirect' => '/my/default/my-index' + ], + ['label' => '账号管理', 'path'=> '/my/default/my-index'], + ['label' => '修改密码', 'path'=> '/my/default/password'], + ] ] - ], - [ - 'path' => '/device', - 'label' => '序列号', - 'routes' => [ - [ - 'path' => '/device', - 'redirect' => '/device/device/index' - ], - ['label' => '序列号管理', 'path' => '/device/device/index'], - ['label' => '创建序列号', 'path' => '/device/device/create-device'], + ]; +} else { + return [ + [ + 'path' => '/dashboard', + 'label' => '欢迎', + ], + [ + 'path' => '/manufacturer', + 'label' => '厂商', + 'routes' => [ + [ + 'path' => '/manufacturer', + 'redirect' => '/manufacturer/manufacturer/index' + ], + ['label' => '厂商管理', 'path' => '/manufacturer/manufacturer/index'], + ] + ], + [ + 'path' => '/device', + 'label' => '序列号', + 'routes' => [ + [ + 'path' => '/device', + 'redirect' => '/device/device/index' + ], + ['label' => '序列号管理', 'path' => '/device/device/index'], + ['label' => '创建序列号', 'path' => '/device/device/create-device'], + ] + ], + [ + 'path' => '/upgrade', + 'label' => '版本', + 'routes' => [ + [ + 'path' => '/upgrade', + 'redirect' => '/upgrade/upgrade/index' + ], + ['label' => '版本管理', 'path'=> '/upgrade/upgrade/index'], + ] + ], + [ + 'path' => '/project', + 'label' => '项目', + 'routes' => [ + [ + 'path' => '/project', + 'redirect' => '/project/project/index' + ], + ['label' => '项目管理', 'path'=> '/project/project/index'], + ] + ], + [ + 'path' => '/model', + 'label' => '机器型号', + 'routes' => [ + [ + 'path' => '/model', + 'redirect' => '/model/model/index' + ], + ['label' => '机器型号管理', 'path'=> '/model/model/index'], + ] + ], + [ + 'path' => '/production', + 'label' => '生产日期', + 'routes' => [ + [ + 'path' => '/production', + 'redirect' => '/production/production/index' + ], + ['label' => '生产日期管理', 'path' => '/production/production/index'], + ] + ], + [ + 'path' => '/datas', + 'label' => '数据统计', + 'routes' => [ + [ + 'path' => '/datas', + 'redirect' => '/datas/datas/index' + ], + ['label' => '序列号统计', 'path' => '/datas/datas/index'], + ['label' => 'OTA升级统计', 'path' => '/datas/upgrade-log/index?type=' . UpgradeStatus::TYPE_OTA], + ['label' => 'APP升级统计', 'path' => '/datas/upgrade-log/index?type=' . UpgradeStatus::TYPE_APP], + ['label' => '机器状态统计', 'path' => '/datas/datas-setting/default'], + ] + ], + [ + 'path' => '/system', + 'label' => '系统', + 'routes' => [ + [ + 'path' => '/system', + 'redirect' => '/system/role/index' + ], + ['label' => '角色管理', 'path' => '/system/role/index'], + ['label' => '账号管理', 'path' => '/system/account/index'], + ] ] - ], - [ - 'path' => '/upgrade', - 'label' => '版本', - 'routes' => [ - [ - 'path' => '/upgrade', - 'redirect' => '/upgrade/upgrade/index' - ], - ['label' => '版本管理', 'path'=> '/upgrade/upgrade/index'], - ] - ], - [ - 'path' => '/project', - 'label' => '项目', - 'routes' => [ - [ - 'path' => '/project', - 'redirect' => '/project/project/index' - ], - ['label' => '项目管理', 'path'=> '/project/project/index'], - ] - ], - [ - 'path' => '/model', - 'label' => '机器型号', - 'routes' => [ - [ - 'path' => '/model', - 'redirect' => '/model/model/index' - ], - ['label' => '机器型号管理', 'path'=> '/model/model/index'], - ] - ], - [ - 'path' => '/production', - 'label' => '生产日期', - 'routes' => [ - [ - 'path' => '/production', - 'redirect' => '/production/production/index' - ], - ['label' => '生产日期管理', 'path' => '/production/production/index'], - ] - ], - [ - 'path' => '/datas', - 'label' => '数据统计', - 'routes' => [ - [ - 'path' => '/datas', - 'redirect' => '/datas/datas/index' - ], - ['label' => '序列号统计', 'path' => '/datas/datas/index'], - ['label' => 'OTA升级统计', 'path' => '/datas/upgrade-log/index?type=' . UpgradeStatus::TYPE_OTA], - ['label' => 'APP升级统计', 'path' => '/datas/upgrade-log/index?type=' . UpgradeStatus::TYPE_APP], - ['label' => '机器状态统计', 'path' => '/datas/datas-setting/default'], - ] - ], - [ - 'path' => '/system', - 'label' => '系统', - 'routes' => [ - [ - 'path' => '/system', - 'redirect' => '/system/role/index' - ], - ['label' => '角色管理', 'path' => '/system/role/index'], - ['label' => '账号管理', 'path' => '/system/account/index'], - ] - ] -]; \ No newline at end of file + ]; +} diff --git a/common/models/AdminLog.php b/common/models/AdminLog.php index 2ea7c02..5d01741 100644 --- a/common/models/AdminLog.php +++ b/common/models/AdminLog.php @@ -13,14 +13,6 @@ use yii\behaviors\TimestampBehavior; class AdminLog extends ActiveRecord { /** - * 使用日志数据库 - */ - public static function getDb() - { - return Yii::$app->get('dbLog'); - } - - /** * @inheritdoc */ public static function tableName() diff --git a/domain/admin/models/AuthUsersRoles.php b/domain/admin/models/AuthUsersRoles.php new file mode 100644 index 0000000..cc69592 --- /dev/null +++ b/domain/admin/models/AuthUsersRoles.php @@ -0,0 +1,16 @@ +username = self::getSysUserName(); $model->password = "1234567"; $model->is_enable = 1; + $model->is_manufacture = 1; // 厂商用户 $model->save(); $manufacturerModel->sys_user_id = $model->id; $manufacturerModel->save(); + // 绑定管理员角色 + $roleId = isset(Yii::$app->params['MANUFACTURE_ROLE_ID']) ? Yii::$app->params['MANUFACTURE_ROLE_ID'] : ""; + if ($roleId) { + $authUsersRole = new AuthUsersRoles(); + $authUsersRole->role_id = $roleId; + $authUsersRole->sys_user_id = $model->id; + $authUsersRole->save(); + } + + $profile = Yii::createObject(SysUserProfileModel::className()); $profile->sys_user_id = $model->id; $profile->realname = $item["name"]; $profile->email = ""; - $profile->mobile = ""; + $profile->mobile = $item['phone']; $saveResult = $profile->save(); } @@ -83,7 +95,16 @@ class Manufacturer } $manufacturerModel->save(); - + if (isset($item['name']) && !empty($item['name'])) { + $sysUserProfileModel = SysUserProfileModel::findOne(["sys_user_id" => $manufacturerModel->sys_user_id]); + if ($sysUserProfileModel) { + $sysUserProfileModel->realname = $item['name']; + if (isset($item['phone'])) { + $sysUserProfileModel->mobile = $item["phone"]; // 厂商电话 + } + $sysUserProfileModel->save(); + } + } $sysUserModel->username = $item['username']; $sysUserModel->password = $item['password']; $resultSave = $sysUserModel->save(); -- libgit2 0.21.0