From 0a549214a5c7e6028b09f8884654d20bb3b0db95 Mon Sep 17 00:00:00 2001 From: cool Date: Thu, 28 Mar 2024 09:19:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=94=A8=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/base/controller/admin/comm.ts | 4 +++- src/modules/base/service/sys/user.ts | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/modules/base/controller/admin/comm.ts b/src/modules/base/controller/admin/comm.ts index ca0c43d..3c41276 100644 --- a/src/modules/base/controller/admin/comm.ts +++ b/src/modules/base/controller/admin/comm.ts @@ -33,7 +33,9 @@ export class BaseCommController extends BaseController { */ @Get('/person', { summary: '个人信息' }) async person() { - return this.ok(await this.baseSysUserService.person()); + return this.ok( + await this.baseSysUserService.person(this.ctx.admin?.userId) + ); } /** diff --git a/src/modules/base/service/sys/user.ts b/src/modules/base/service/sys/user.ts index 09932ce..96c3bc8 100644 --- a/src/modules/base/service/sys/user.ts +++ b/src/modules/base/service/sys/user.ts @@ -1,7 +1,7 @@ import { Inject, InjectClient, Provide } from '@midwayjs/decorator'; import { BaseService, CoolCommException } from '@cool-midway/core'; import { InjectEntityModel } from '@midwayjs/typeorm'; -import { In, Repository } from 'typeorm'; +import { Equal, In, Repository } from 'typeorm'; import { BaseSysUserEntity } from '../../entity/sys/user'; import { BaseSysPermsService } from './perms'; import * as _ from 'lodash'; @@ -96,9 +96,9 @@ export class BaseSysUserService extends BaseService { /** * 获得个人信息 */ - async person() { + async person(userId) { const info = await this.baseSysUserEntity.findOneBy({ - id: this.ctx.admin?.userId, + id: Equal(userId), }); delete info?.password; return info;