Commit cb9961d87d29adff72df0cedc3a24252a1e12498

Authored by 曹明
1 parent dbf4fbf4
Exists in master

app-ht(v1.8.6 build 13)

1.区分后台账号和厂商账号登录,返回不同的菜单。
app-ht/config/params.php
1 <?php 1 <?php
2 return [ 2 return [
3 - 'VERSION' => 'v1.8.6 build 12', 3 + 'VERSION' => 'v1.8.6 build 13',
  4 + 'MANUFACTURE_ROLE_ID' => 1
4 ]; 5 ];
5 \ No newline at end of file 6 \ No newline at end of file
app-ht/modules/my/controllers/DefaultController.php
@@ -28,6 +28,18 @@ class DefaultController extends BaseController @@ -28,6 +28,18 @@ class DefaultController extends BaseController
28 } 28 }
29 29
30 /** 30 /**
  31 + * 账号设置
  32 + */
  33 + public function actionMyIndex()
  34 + {
  35 + $model = $this->getUser();
  36 +
  37 + return $this->render('my-index', [
  38 + 'model' => $model,
  39 + ]);
  40 + }
  41 +
  42 + /**
31 * 更新执行动作 43 * 更新执行动作
32 */ 44 */
33 public function actionDoUpdate() 45 public function actionDoUpdate()
app-ht/modules/my/views/default/my-index.php 0 → 100644
@@ -0,0 +1,62 @@ @@ -0,0 +1,62 @@
  1 +<?php
  2 +
  3 +use yii\helpers\Url;
  4 +use domain\manufacturer\ManufacturerRepository;
  5 +
  6 +$this->title = '修改资料';
  7 +$this->params['breadcrumbs'][] = '账号设置';
  8 +$this->params['breadcrumbs'][] = $this->title;
  9 +
  10 +
  11 +
  12 +?>
  13 +
  14 +<form action="<?php echo Url::toRoute(['/my/default/do-update']); ?>" name="userForm" id="userForm" method="post">
  15 + <div class="panel panel-default">
  16 + <div class="panel-body">
  17 + <table class="panel-box-tb">
  18 + <thead>
  19 + <tr>
  20 + <th width="150"></th>
  21 + <th></th>
  22 + </tr>
  23 + </thead>
  24 + <tbody>
  25 + <tr>
  26 + <td class="text-right">
  27 + <b>厂商名称:</b>
  28 + </td>
  29 + <td>
  30 + <?= $model->profile ? $model->profile->realname : '' ?>
  31 + </td>
  32 + </tr>
  33 + <tr>
  34 + <td class="text-right">
  35 + <b>账号:</b>
  36 + </td>
  37 + <td>
  38 + <?= $model->username ?>
  39 + </td>
  40 + </tr>
  41 + <tr>
  42 + <td class="text-right">
  43 + <b>密码:</b>
  44 + </td>
  45 + <td>
  46 + <?= $model->password ? ManufacturerRepository::substr_cut($model->password) : '' ?>
  47 + </td>
  48 + </tr>
  49 +
  50 + <tr>
  51 + <td></td>
  52 + <td>
  53 + <a class="btn btn-primary" href="<?php echo Url::toRoute(['/my/default/password']); ?>">修改密码</a>
  54 + </td>
  55 + </tr>
  56 + </tbody>
  57 + </table>
  58 + </div>
  59 +
  60 + </div>
  61 +
  62 +</form>
0 \ No newline at end of file 63 \ No newline at end of file
app-ht/views/layouts/_main-content.php
@@ -26,6 +26,7 @@ class Router @@ -26,6 +26,7 @@ class Router
26 '系统' => 'glyphicon glyphicon-hdd', 26 '系统' => 'glyphicon glyphicon-hdd',
27 '设置' => 'glyphicon glyphicon-cog', 27 '设置' => 'glyphicon glyphicon-cog',
28 '自动化' => 'glyphicon glyphicon-time', 28 '自动化' => 'glyphicon glyphicon-time',
  29 + '账号' => 'glyphicon glyphicon-user',
29 ]; 30 ];
30 31
31 /** 32 /**
app-ht/views/layouts/routes.php
1 <?php 1 <?php
2 use domain\upgrade\UpgradeStatus; 2 use domain\upgrade\UpgradeStatus;
3 -return [  
4 - [  
5 - 'path' => '/dashboard',  
6 - 'label' => '欢迎',  
7 - ],  
8 - [  
9 - 'path' => '/manufacturer',  
10 - 'label' => '厂商',  
11 - 'routes' => [  
12 - [  
13 - 'path' => '/manufacturer',  
14 - 'redirect' => '/manufacturer/manufacturer/index'  
15 - ],  
16 - ['label' => '厂商管理', 'path' => '/manufacturer/manufacturer/index'], 3 +$user = Yii::$app->user->identity;
  4 +if (isset($user->is_manufacture) && $user->is_manufacture == 1) {
  5 + return [
  6 + [
  7 + 'path' => '/dashboard',
  8 + 'label' => '欢迎',
  9 + ],
  10 + [
  11 + 'path' => '/upgrade',
  12 + 'label' => '版本',
  13 + 'routes' => [
  14 + [
  15 + 'path' => '/upgrade',
  16 + 'redirect' => '/upgrade/upgrade/index'
  17 + ],
  18 + ['label' => '版本管理', 'path'=> '/upgrade/upgrade/index'],
  19 + ]
  20 + ],
  21 + [
  22 + 'path' => '/myself',
  23 + 'label' => '账号',
  24 + 'routes' => [
  25 + [
  26 + 'path' => '/myself',
  27 + 'redirect' => '/my/default/my-index'
  28 + ],
  29 + ['label' => '账号管理', 'path'=> '/my/default/my-index'],
  30 + ['label' => '修改密码', 'path'=> '/my/default/password'],
  31 + ]
17 ] 32 ]
18 - ],  
19 - [  
20 - 'path' => '/device',  
21 - 'label' => '序列号',  
22 - 'routes' => [  
23 - [  
24 - 'path' => '/device',  
25 - 'redirect' => '/device/device/index'  
26 - ],  
27 - ['label' => '序列号管理', 'path' => '/device/device/index'],  
28 - ['label' => '创建序列号', 'path' => '/device/device/create-device'], 33 + ];
  34 +} else {
  35 + return [
  36 + [
  37 + 'path' => '/dashboard',
  38 + 'label' => '欢迎',
  39 + ],
  40 + [
  41 + 'path' => '/manufacturer',
  42 + 'label' => '厂商',
  43 + 'routes' => [
  44 + [
  45 + 'path' => '/manufacturer',
  46 + 'redirect' => '/manufacturer/manufacturer/index'
  47 + ],
  48 + ['label' => '厂商管理', 'path' => '/manufacturer/manufacturer/index'],
  49 + ]
  50 + ],
  51 + [
  52 + 'path' => '/device',
  53 + 'label' => '序列号',
  54 + 'routes' => [
  55 + [
  56 + 'path' => '/device',
  57 + 'redirect' => '/device/device/index'
  58 + ],
  59 + ['label' => '序列号管理', 'path' => '/device/device/index'],
  60 + ['label' => '创建序列号', 'path' => '/device/device/create-device'],
  61 + ]
  62 + ],
  63 + [
  64 + 'path' => '/upgrade',
  65 + 'label' => '版本',
  66 + 'routes' => [
  67 + [
  68 + 'path' => '/upgrade',
  69 + 'redirect' => '/upgrade/upgrade/index'
  70 + ],
  71 + ['label' => '版本管理', 'path'=> '/upgrade/upgrade/index'],
  72 + ]
  73 + ],
  74 + [
  75 + 'path' => '/project',
  76 + 'label' => '项目',
  77 + 'routes' => [
  78 + [
  79 + 'path' => '/project',
  80 + 'redirect' => '/project/project/index'
  81 + ],
  82 + ['label' => '项目管理', 'path'=> '/project/project/index'],
  83 + ]
  84 + ],
  85 + [
  86 + 'path' => '/model',
  87 + 'label' => '机器型号',
  88 + 'routes' => [
  89 + [
  90 + 'path' => '/model',
  91 + 'redirect' => '/model/model/index'
  92 + ],
  93 + ['label' => '机器型号管理', 'path'=> '/model/model/index'],
  94 + ]
  95 + ],
  96 + [
  97 + 'path' => '/production',
  98 + 'label' => '生产日期',
  99 + 'routes' => [
  100 + [
  101 + 'path' => '/production',
  102 + 'redirect' => '/production/production/index'
  103 + ],
  104 + ['label' => '生产日期管理', 'path' => '/production/production/index'],
  105 + ]
  106 + ],
  107 + [
  108 + 'path' => '/datas',
  109 + 'label' => '数据统计',
  110 + 'routes' => [
  111 + [
  112 + 'path' => '/datas',
  113 + 'redirect' => '/datas/datas/index'
  114 + ],
  115 + ['label' => '序列号统计', 'path' => '/datas/datas/index'],
  116 + ['label' => 'OTA升级统计', 'path' => '/datas/upgrade-log/index?type=' . UpgradeStatus::TYPE_OTA],
  117 + ['label' => 'APP升级统计', 'path' => '/datas/upgrade-log/index?type=' . UpgradeStatus::TYPE_APP],
  118 + ['label' => '机器状态统计', 'path' => '/datas/datas-setting/default'],
  119 + ]
  120 + ],
  121 + [
  122 + 'path' => '/system',
  123 + 'label' => '系统',
  124 + 'routes' => [
  125 + [
  126 + 'path' => '/system',
  127 + 'redirect' => '/system/role/index'
  128 + ],
  129 + ['label' => '角色管理', 'path' => '/system/role/index'],
  130 + ['label' => '账号管理', 'path' => '/system/account/index'],
  131 + ]
29 ] 132 ]
30 - ],  
31 - [  
32 - 'path' => '/upgrade',  
33 - 'label' => '版本',  
34 - 'routes' => [  
35 - [  
36 - 'path' => '/upgrade',  
37 - 'redirect' => '/upgrade/upgrade/index'  
38 - ],  
39 - ['label' => '版本管理', 'path'=> '/upgrade/upgrade/index'],  
40 - ]  
41 - ],  
42 - [  
43 - 'path' => '/project',  
44 - 'label' => '项目',  
45 - 'routes' => [  
46 - [  
47 - 'path' => '/project',  
48 - 'redirect' => '/project/project/index'  
49 - ],  
50 - ['label' => '项目管理', 'path'=> '/project/project/index'],  
51 - ]  
52 - ],  
53 - [  
54 - 'path' => '/model',  
55 - 'label' => '机器型号',  
56 - 'routes' => [  
57 - [  
58 - 'path' => '/model',  
59 - 'redirect' => '/model/model/index'  
60 - ],  
61 - ['label' => '机器型号管理', 'path'=> '/model/model/index'],  
62 - ]  
63 - ],  
64 - [  
65 - 'path' => '/production',  
66 - 'label' => '生产日期',  
67 - 'routes' => [  
68 - [  
69 - 'path' => '/production',  
70 - 'redirect' => '/production/production/index'  
71 - ],  
72 - ['label' => '生产日期管理', 'path' => '/production/production/index'],  
73 - ]  
74 - ],  
75 - [  
76 - 'path' => '/datas',  
77 - 'label' => '数据统计',  
78 - 'routes' => [  
79 - [  
80 - 'path' => '/datas',  
81 - 'redirect' => '/datas/datas/index'  
82 - ],  
83 - ['label' => '序列号统计', 'path' => '/datas/datas/index'],  
84 - ['label' => 'OTA升级统计', 'path' => '/datas/upgrade-log/index?type=' . UpgradeStatus::TYPE_OTA],  
85 - ['label' => 'APP升级统计', 'path' => '/datas/upgrade-log/index?type=' . UpgradeStatus::TYPE_APP],  
86 - ['label' => '机器状态统计', 'path' => '/datas/datas-setting/default'],  
87 - ]  
88 - ],  
89 - [  
90 - 'path' => '/system',  
91 - 'label' => '系统',  
92 - 'routes' => [  
93 - [  
94 - 'path' => '/system',  
95 - 'redirect' => '/system/role/index'  
96 - ],  
97 - ['label' => '角色管理', 'path' => '/system/role/index'],  
98 - ['label' => '账号管理', 'path' => '/system/account/index'],  
99 - ]  
100 - ]  
101 -];  
102 \ No newline at end of file 133 \ No newline at end of file
  134 + ];
  135 +}
common/models/AdminLog.php
@@ -13,14 +13,6 @@ use yii\behaviors\TimestampBehavior; @@ -13,14 +13,6 @@ use yii\behaviors\TimestampBehavior;
13 class AdminLog extends ActiveRecord 13 class AdminLog extends ActiveRecord
14 { 14 {
15 /** 15 /**
16 - * 使用日志数据库  
17 - */  
18 - public static function getDb()  
19 - {  
20 - return Yii::$app->get('dbLog');  
21 - }  
22 -  
23 - /**  
24 * @inheritdoc 16 * @inheritdoc
25 */ 17 */
26 public static function tableName() 18 public static function tableName()
domain/admin/models/AuthUsersRoles.php 0 → 100644
@@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
  1 +<?php
  2 +
  3 +namespace domain\admin\models;
  4 +
  5 +use yii\db\ActiveRecord;
  6 +
  7 +class AuthUsersRoles extends ActiveRecord
  8 +{
  9 + /**
  10 + * @inheritdoc
  11 + */
  12 + public static function tableName()
  13 + {
  14 + return '{{%auth_users_roles}}';
  15 + }
  16 +}
0 \ No newline at end of file 17 \ No newline at end of file
domain/manufacturer/Manufacturer.php
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 namespace domain\manufacturer; 3 namespace domain\manufacturer;
4 4
  5 +use domain\admin\models\AuthUsersRoles;
5 use Yii; 6 use Yii;
6 use common\models\SysUser as SysUserModel; 7 use common\models\SysUser as SysUserModel;
7 use common\models\SysUserProfile as SysUserProfileModel; 8 use common\models\SysUserProfile as SysUserProfileModel;
@@ -34,16 +35,27 @@ class Manufacturer @@ -34,16 +35,27 @@ class Manufacturer
34 $model->username = self::getSysUserName(); 35 $model->username = self::getSysUserName();
35 $model->password = "1234567"; 36 $model->password = "1234567";
36 $model->is_enable = 1; 37 $model->is_enable = 1;
  38 + $model->is_manufacture = 1; // 厂商用户
37 $model->save(); 39 $model->save();
38 40
39 $manufacturerModel->sys_user_id = $model->id; 41 $manufacturerModel->sys_user_id = $model->id;
40 $manufacturerModel->save(); 42 $manufacturerModel->save();
41 43
  44 + // 绑定管理员角色
  45 + $roleId = isset(Yii::$app->params['MANUFACTURE_ROLE_ID']) ? Yii::$app->params['MANUFACTURE_ROLE_ID'] : "";
  46 + if ($roleId) {
  47 + $authUsersRole = new AuthUsersRoles();
  48 + $authUsersRole->role_id = $roleId;
  49 + $authUsersRole->sys_user_id = $model->id;
  50 + $authUsersRole->save();
  51 + }
  52 +
  53 +
42 $profile = Yii::createObject(SysUserProfileModel::className()); 54 $profile = Yii::createObject(SysUserProfileModel::className());
43 $profile->sys_user_id = $model->id; 55 $profile->sys_user_id = $model->id;
44 $profile->realname = $item["name"]; 56 $profile->realname = $item["name"];
45 $profile->email = ""; 57 $profile->email = "";
46 - $profile->mobile = ""; 58 + $profile->mobile = $item['phone'];
47 59
48 $saveResult = $profile->save(); 60 $saveResult = $profile->save();
49 } 61 }
@@ -83,7 +95,16 @@ class Manufacturer @@ -83,7 +95,16 @@ class Manufacturer
83 } 95 }
84 96
85 $manufacturerModel->save(); 97 $manufacturerModel->save();
86 - 98 + if (isset($item['name']) && !empty($item['name'])) {
  99 + $sysUserProfileModel = SysUserProfileModel::findOne(["sys_user_id" => $manufacturerModel->sys_user_id]);
  100 + if ($sysUserProfileModel) {
  101 + $sysUserProfileModel->realname = $item['name'];
  102 + if (isset($item['phone'])) {
  103 + $sysUserProfileModel->mobile = $item["phone"]; // 厂商电话
  104 + }
  105 + $sysUserProfileModel->save();
  106 + }
  107 + }
87 $sysUserModel->username = $item['username']; 108 $sysUserModel->username = $item['username'];
88 $sysUserModel->password = $item['password']; 109 $sysUserModel->password = $item['password'];
89 $resultSave = $sysUserModel->save(); 110 $resultSave = $sysUserModel->save();