Skip to content

Commit 7dab224

Browse files
authored
Merge pull request #32 from windhoney/develop
用户信息获取修改
2 parents 3e6fe03 + a87e92f commit 7dab224

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

controllers/UserController.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,19 @@ public function actionIndex()
4545
*/
4646
public function actionView($id)
4747
{
48-
$result = $this->findModel($id);
48+
$select = [
49+
"id",
50+
"username",
51+
"realname",
52+
"email",
53+
"status",
54+
"created_at",
55+
"updated_at"
56+
];
57+
$result = $this->findModel($id, $select);
4958
$result->created_at = date('Y年m月d日', $result->created_at);
50-
unset($result->password_hash);
51-
unset($result->auth_key);
52-
unset($result->password_reset_token);
53-
unset($result->dingId);
54-
59+
$result->updated_at = date('Y年m月d日', $result->updated_at);
60+
5561
return $result;
5662
}
5763

@@ -224,9 +230,9 @@ public function actionActivate($id)
224230
* @return User the loaded model
225231
* @throws NotFoundHttpException if the model cannot be found
226232
*/
227-
protected function findModel($id)
233+
protected function findModel($id, $select = ['*'])
228234
{
229-
if (($model = User::findOne($id)) !== null) {
235+
if (($model = User::find()->andWhere(['id' => $id])->select($select)->one()) !== null) {
230236
return $model;
231237
} else {
232238
return false;

0 commit comments

Comments
 (0)