mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
feat: implement dynamic create DTO for Permission
This commit is contained in:
parent
b6102b3843
commit
e0e773454d
@ -47,10 +47,10 @@ export class PermissionController extends BaseController<
|
|||||||
PermissionFull
|
PermissionFull
|
||||||
> {
|
> {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly permissionService: PermissionService,
|
protected readonly permissionService: PermissionService,
|
||||||
private readonly logger: LoggerService,
|
protected readonly logger: LoggerService,
|
||||||
private readonly roleService: RoleService,
|
protected readonly roleService: RoleService,
|
||||||
private readonly modelService: ModelService,
|
protected readonly modelService: ModelService,
|
||||||
) {
|
) {
|
||||||
super(permissionService);
|
super(permissionService);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,8 +7,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
import { IsEnum, IsNotEmpty, IsString, IsOptional } from 'class-validator';
|
import { IsEnum, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||||
|
|
||||||
|
import { DtoConfig } from '@/utils/types/dto.types';
|
||||||
import { IsObjectId } from '@/utils/validation-rules/is-object-id';
|
import { IsObjectId } from '@/utils/validation-rules/is-object-id';
|
||||||
|
|
||||||
import { Action } from '../types/action.type';
|
import { Action } from '../types/action.type';
|
||||||
@ -40,3 +41,7 @@ export class PermissionCreateDto {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
relation?: TRelation;
|
relation?: TRelation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type PermissionDTOMapActions = DtoConfig<{
|
||||||
|
create: PermissionCreateDto;
|
||||||
|
}>;
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import { Model } from 'mongoose';
|
|||||||
|
|
||||||
import { BaseRepository } from '@/utils/generics/base-repository';
|
import { BaseRepository } from '@/utils/generics/base-repository';
|
||||||
|
|
||||||
|
import { PermissionDTOMapActions } from '../dto/permission.dto';
|
||||||
import {
|
import {
|
||||||
Permission,
|
Permission,
|
||||||
PERMISSION_POPULATE,
|
PERMISSION_POPULATE,
|
||||||
@ -24,7 +25,8 @@ import {
|
|||||||
export class PermissionRepository extends BaseRepository<
|
export class PermissionRepository extends BaseRepository<
|
||||||
Permission,
|
Permission,
|
||||||
PermissionPopulate,
|
PermissionPopulate,
|
||||||
PermissionFull
|
PermissionFull,
|
||||||
|
PermissionDTOMapActions
|
||||||
> {
|
> {
|
||||||
constructor(
|
constructor(
|
||||||
readonly eventEmitter: EventEmitter2,
|
readonly eventEmitter: EventEmitter2,
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import {
|
|||||||
} from '@/utils/types/filter.types';
|
} from '@/utils/types/filter.types';
|
||||||
|
|
||||||
import { Action } from '../types/action.type';
|
import { Action } from '../types/action.type';
|
||||||
|
import { TRelation } from '../types/index.type';
|
||||||
|
|
||||||
import { Model } from './model.schema';
|
import { Model } from './model.schema';
|
||||||
import { Role } from './role.schema';
|
import { Role } from './role.schema';
|
||||||
@ -41,7 +42,7 @@ export class PermissionStub extends BaseSchema {
|
|||||||
type: String,
|
type: String,
|
||||||
default: 'role',
|
default: 'role',
|
||||||
})
|
})
|
||||||
relation?: string;
|
relation: TRelation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Schema({ timestamps: true })
|
@Schema({ timestamps: true })
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import { Injectable } from '@nestjs/common';
|
|||||||
|
|
||||||
import { BaseSeeder } from '@/utils/generics/base-seeder';
|
import { BaseSeeder } from '@/utils/generics/base-seeder';
|
||||||
|
|
||||||
|
import { PermissionDTOMapActions } from '../dto/permission.dto';
|
||||||
import { PermissionRepository } from '../repositories/permission.repository';
|
import { PermissionRepository } from '../repositories/permission.repository';
|
||||||
import {
|
import {
|
||||||
Permission,
|
Permission,
|
||||||
@ -21,7 +22,8 @@ import {
|
|||||||
export class PermissionSeeder extends BaseSeeder<
|
export class PermissionSeeder extends BaseSeeder<
|
||||||
Permission,
|
Permission,
|
||||||
PermissionPopulate,
|
PermissionPopulate,
|
||||||
PermissionFull
|
PermissionFull,
|
||||||
|
PermissionDTOMapActions
|
||||||
> {
|
> {
|
||||||
constructor(private readonly permissionRepository: PermissionRepository) {
|
constructor(private readonly permissionRepository: PermissionRepository) {
|
||||||
super(permissionRepository);
|
super(permissionRepository);
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import { PERMISSION_CACHE_KEY } from '@/utils/constants/cache';
|
|||||||
import { Cacheable } from '@/utils/decorators/cacheable.decorator';
|
import { Cacheable } from '@/utils/decorators/cacheable.decorator';
|
||||||
import { BaseService } from '@/utils/generics/base-service';
|
import { BaseService } from '@/utils/generics/base-service';
|
||||||
|
|
||||||
|
import { PermissionDTOMapActions } from '../dto/permission.dto';
|
||||||
import { PermissionRepository } from '../repositories/permission.repository';
|
import { PermissionRepository } from '../repositories/permission.repository';
|
||||||
import {
|
import {
|
||||||
Permission,
|
Permission,
|
||||||
@ -27,7 +28,8 @@ import { PermissionsTree } from '../types/permission.type';
|
|||||||
export class PermissionService extends BaseService<
|
export class PermissionService extends BaseService<
|
||||||
Permission,
|
Permission,
|
||||||
PermissionPopulate,
|
PermissionPopulate,
|
||||||
PermissionFull
|
PermissionFull,
|
||||||
|
PermissionDTOMapActions
|
||||||
> {
|
> {
|
||||||
constructor(
|
constructor(
|
||||||
readonly repository: PermissionRepository,
|
readonly repository: PermissionRepository,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user