mirror of
https://github.com/hexastack/hexabot
synced 2025-01-22 10:35:37 +00:00
feat: implement dynamic create DTO for Role
This commit is contained in:
parent
e0e773454d
commit
1936e6a0e7
@ -9,6 +9,8 @@
|
||||
import { ApiProperty, ApiPropertyOptional, PartialType } from '@nestjs/swagger';
|
||||
import { IsBoolean, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
|
||||
import { DtoConfig } from '@/utils/types/dto.types';
|
||||
|
||||
export class RoleCreateDto {
|
||||
@ApiProperty({ description: 'Name of the role', type: String })
|
||||
@IsNotEmpty()
|
||||
@ -26,3 +28,7 @@ export class RoleCreateDto {
|
||||
}
|
||||
|
||||
export class RoleUpdateDto extends PartialType(RoleCreateDto) {}
|
||||
|
||||
export type RoleDTOMapActions = DtoConfig<{
|
||||
create: RoleCreateDto;
|
||||
}>;
|
||||
|
@ -13,6 +13,7 @@ import { Model } from 'mongoose';
|
||||
|
||||
import { BaseRepository, DeleteResult } from '@/utils/generics/base-repository';
|
||||
|
||||
import { RoleDTOMapActions } from '../dto/role.dto';
|
||||
import { Permission } from '../schemas/permission.schema';
|
||||
import {
|
||||
Role,
|
||||
@ -25,7 +26,8 @@ import {
|
||||
export class RoleRepository extends BaseRepository<
|
||||
Role,
|
||||
RolePopulate,
|
||||
RoleFull
|
||||
RoleFull,
|
||||
RoleDTOMapActions
|
||||
> {
|
||||
constructor(
|
||||
readonly eventEmitter: EventEmitter2,
|
||||
|
@ -10,11 +10,17 @@ import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { BaseService } from '@/utils/generics/base-service';
|
||||
|
||||
import { RoleDTOMapActions } from '../dto/role.dto';
|
||||
import { RoleRepository } from '../repositories/role.repository';
|
||||
import { Role, RoleFull, RolePopulate } from '../schemas/role.schema';
|
||||
|
||||
@Injectable()
|
||||
export class RoleService extends BaseService<Role, RolePopulate, RoleFull> {
|
||||
export class RoleService extends BaseService<
|
||||
Role,
|
||||
RolePopulate,
|
||||
RoleFull,
|
||||
RoleDTOMapActions
|
||||
> {
|
||||
constructor(readonly repository: RoleRepository) {
|
||||
super(repository);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user