This commit is contained in:
xiaojunnuo
2024-10-03 01:29:12 +08:00
parent aeed24e87d
commit c9d18f6d8a
17 changed files with 100 additions and 34 deletions
@@ -49,6 +49,9 @@ export class RoleController extends CrudController<RoleService> {
@Query('id')
id: number
) {
if (id === 1) {
throw new Error('不能删除默认的管理员角色');
}
return await super.delete(id);
}
@@ -73,8 +73,11 @@ export class UserController extends CrudController<UserService> {
@Post('/delete', { summary: 'sys:auth:user:remove' })
async delete(
@Query('id')
id : number
id: number
) {
if (id === 1) {
throw new Error('不能删除默认的管理员用户');
}
return await super.delete(id);
}
@@ -66,4 +66,6 @@ export class UserEntity {
static of(user: Partial<UserEntity>) {
return Object.assign(new UserEntity(), user);
}
roleIds: number[];
}
@@ -3,6 +3,7 @@ import { BaseController } from '../../../basic/base-controller.js';
import { Constants } from '../../../basic/constants.js';
import { UserService } from '../../authority/service/user-service.js';
import { getPlusInfo } from '@certd/pipeline';
import { RoleService } from '../../authority/service/role-service.js';
/**
*/
@@ -11,10 +12,13 @@ import { getPlusInfo } from '@certd/pipeline';
export class MineController extends BaseController {
@Inject()
userService: UserService;
@Inject()
roleService: RoleService;
@Post('/info', { summary: Constants.per.authOnly })
public async info() {
const userId = this.getUserId();
const user = await this.userService.info(userId);
user.roleIds = await this.roleService.getRoleIdsByUserId(userId);
delete user.password;
return this.ok(user);
}
@@ -27,4 +27,5 @@ export class UserSettingsEntity {
default: () => 'CURRENT_TIMESTAMP',
})
updateTime: Date;
}