mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2024-11-01 22:20:30 +08:00
优化用户信息获取
This commit is contained in:
parent
f788685cc4
commit
0a549214a5
@ -33,7 +33,9 @@ export class BaseCommController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@Get('/person', { summary: '个人信息' })
|
@Get('/person', { summary: '个人信息' })
|
||||||
async person() {
|
async person() {
|
||||||
return this.ok(await this.baseSysUserService.person());
|
return this.ok(
|
||||||
|
await this.baseSysUserService.person(this.ctx.admin?.userId)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Inject, InjectClient, Provide } from '@midwayjs/decorator';
|
import { Inject, InjectClient, Provide } from '@midwayjs/decorator';
|
||||||
import { BaseService, CoolCommException } from '@cool-midway/core';
|
import { BaseService, CoolCommException } from '@cool-midway/core';
|
||||||
import { InjectEntityModel } from '@midwayjs/typeorm';
|
import { InjectEntityModel } from '@midwayjs/typeorm';
|
||||||
import { In, Repository } from 'typeorm';
|
import { Equal, In, Repository } from 'typeorm';
|
||||||
import { BaseSysUserEntity } from '../../entity/sys/user';
|
import { BaseSysUserEntity } from '../../entity/sys/user';
|
||||||
import { BaseSysPermsService } from './perms';
|
import { BaseSysPermsService } from './perms';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
@ -96,9 +96,9 @@ export class BaseSysUserService extends BaseService {
|
|||||||
/**
|
/**
|
||||||
* 获得个人信息
|
* 获得个人信息
|
||||||
*/
|
*/
|
||||||
async person() {
|
async person(userId) {
|
||||||
const info = await this.baseSysUserEntity.findOneBy({
|
const info = await this.baseSysUserEntity.findOneBy({
|
||||||
id: this.ctx.admin?.userId,
|
id: Equal(userId),
|
||||||
});
|
});
|
||||||
delete info?.password;
|
delete info?.password;
|
||||||
return info;
|
return info;
|
||||||
|
Loading…
Reference in New Issue
Block a user