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;