优化用户信息获取

This commit is contained in:
cool 2024-03-28 09:19:50 +08:00
parent f788685cc4
commit 0a549214a5
2 changed files with 6 additions and 4 deletions

View File

@ -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)
);
}
/**

View File

@ -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;