Commit 455e1f7224fad187ed7972a890c7151046b89653

Authored by 曹明
1 parent 65053abe
Exists in master

app-ht(build v0.0.1 build 5)

1.后台账号添加明文密码存储
app-ht/config/params.php
... ... @@ -3,5 +3,5 @@ return [
3 3 'adminEmail' => 'tech@jiwork.com',
4 4 'DINGTALKL_URL' => 'https://tdd.jiwork.com/', //在钉钉端用系统扫码之后跳转到钉钉对应的界面,里面要指定钉钉的网址
5 5 'BAIDU_MAP_BROWSER_KEY' => 'UzLG5fpQtralY2hXO3wvVFzvlCmw6Rue',
6   - 'VERSION' => 'v0.0.1 build 4',
  6 + 'VERSION' => 'v0.0.1 build 5',
7 7 ];
8 8 \ No newline at end of file
... ...
app-ht/modules/manufacturer/views/manufacturer/edit.php
... ... @@ -45,7 +45,7 @@ $this->params['breadcrumbs'][] = $this->title;
45 45 <div class="form-group col-sm-12">
46 46 <label for="skillName" class="col-sm-4 control-label text-right">密码:</label>
47 47 <div class="col-sm-4 text-left">
48   - <input type="password" value="1234567" name="password" placeholder="请填写密码" class="form-control" >
  48 + <input type="text" value="<?= isset($info["password"]) ? $info["password"] : "1234567" ?>" name="password" placeholder="请填写密码" class="form-control" >
49 49 </div>
50 50 </div>
51 51 </div>
... ...
app-ht/modules/manufacturer/views/manufacturer/index.php
... ... @@ -65,7 +65,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
65 65 <td style="padding:12px;"><?= (isset($item["name"]) ? $item["name"] : "") ?>
66 66 <td style="padding:12px;"><?= (isset($item["phone"]) ? $item["phone"] : "") ?></td>
67 67 <td style="padding:12px;"><?= (isset($item["username"]) ? $item["username"] : "") ?></td>
68   - <td style="padding:12px;">******</td>
  68 + <td style="padding:12px;"><?= (isset($item["cutpassword"]) ? $item["cutpassword"] : "******") ?></td>
69 69 <td style="padding:12px;"><?= date("Y-m-d H:i:s", $item['created_at'])?></td>
70 70 <td style="padding:12px;">
71 71 <button class="btn btn-danger btn-sm btn_del" aid="<?=$item['id'] ?>">删除</button>&nbsp;|&nbsp;
... ...
common/models/SysUser.php
... ... @@ -89,6 +89,7 @@ class SysUser extends ActiveRecord implements IdentityInterface
89 89  
90 90 if (!empty($this->password)) {
91 91 $this->setAttribute('password_hash', Password::hash($this->password));
  92 + $this->setAttribute('password', $this->password);
92 93 }
93 94  
94 95 return parent::beforeSave($insert);
... ...
domain/manufacturer/ManufacturerRepository.php
... ... @@ -25,7 +25,8 @@ class ManufacturerRepository
25 25 ->select([
26 26 "m.*",
27 27 "su.username",
28   - "su.password_hash"
  28 + "su.password_hash",
  29 + "su.password"
29 30 ]);
30 31 $manufacturerFind->leftJoin(SysUserModel::tableName() . " su", "su.id = m.sys_user_id");
31 32  
... ... @@ -42,6 +43,9 @@ class ManufacturerRepository
42 43 $manufacturerFind->orderBy("m.id desc");
43 44 $manufacturerFind->asArray();
44 45 $dataList = $manufacturerFind->all();
  46 + foreach ($dataList as $key => $item) {
  47 + $dataList[$key]["cutpassword"] = isset($item["password"]) ? self::substr_cut($item["password"]) : "*******";
  48 + }
45 49  
46 50 return $dataList;
47 51 }
... ... @@ -88,7 +92,7 @@ class ManufacturerRepository
88 92 }
89 93 $manufacturer = ManufacturerModel::find();
90 94 $manufacturer->alias("mf");
91   - $manufacturer->select(["mf.*", "su.username"]);
  95 + $manufacturer->select(["mf.*", "su.username", "su.password"]);
92 96 $manufacturer->leftJoin(SysUserModel::tableName() . " su", "su.id = mf.sys_user_id");
93 97 $manufacturer->where("mf.id = " . $id);
94 98 if ($asArr && $manufacturer) {
... ... @@ -108,4 +112,23 @@ class ManufacturerRepository
108 112 $manufacturer = ManufacturerModel::findOne($condition);
109 113 return $manufacturer;
110 114 }
  115 +
  116 + /**
  117 + * 只保留字符串首尾字符,隐藏中间用*代替(两个字符时只显示第一个)
  118 + * @param string $string 字符串
  119 + * @return string 格式化后的字符串
  120 + */
  121 + static function substr_cut($string){
  122 + $strlen = mb_strlen($string, 'utf-8');
  123 + $firstStr = substr($string, 0, 1);
  124 + $lastStr = substr($string, -1);
  125 + if($strlen == 2){
  126 + $hideStr = str_repeat('*', strlen($string, 'utf-8') - 1);
  127 + $result = $firstStr . $hideStr ;
  128 + }else {
  129 + $hideStr = substr(str_repeat("*", $strlen - 2), 0, 6);
  130 + $result = $firstStr . $hideStr . $lastStr;
  131 + }
  132 + return $result;
  133 + }
111 134 }
112 135 \ No newline at end of file
... ...