mirror of
https://github.com/hexastack/hexabot
synced 2025-01-22 10:35:37 +00:00
feat: implement dynamic create DTO for User
This commit is contained in:
parent
382bdd4ef1
commit
7f59f593c5
@ -22,6 +22,7 @@ import {
|
||||
IsString,
|
||||
} from 'class-validator';
|
||||
|
||||
import { DtoConfig } from '@/utils/types/dto.types';
|
||||
import { IsObjectId } from '@/utils/validation-rules/is-object-id';
|
||||
|
||||
export class UserCreateDto {
|
||||
@ -98,3 +99,7 @@ export class UserResetPasswordDto extends PickType(UserCreateDto, [
|
||||
]) {}
|
||||
|
||||
export class UserRequestResetDto extends PickType(UserCreateDto, ['email']) {}
|
||||
|
||||
export type TUserCrudsDto = DtoConfig<{
|
||||
create: UserCreateDto;
|
||||
}>;
|
||||
|
@ -50,6 +50,16 @@ export class UserStub extends BaseSchema {
|
||||
})
|
||||
password: string;
|
||||
|
||||
@Prop([{ type: MongooseSchema.Types.ObjectId, ref: 'Role' }])
|
||||
roles: unknown;
|
||||
|
||||
@Prop({
|
||||
type: MongooseSchema.Types.ObjectId,
|
||||
ref: 'Attachment',
|
||||
default: null,
|
||||
})
|
||||
avatar: unknown;
|
||||
|
||||
@Prop({
|
||||
type: Boolean,
|
||||
default: false,
|
||||
@ -83,16 +93,6 @@ export class UserStub extends BaseSchema {
|
||||
})
|
||||
resetCount?: number;
|
||||
|
||||
@Prop([{ type: MongooseSchema.Types.ObjectId, ref: 'Role' }])
|
||||
roles: unknown;
|
||||
|
||||
@Prop({
|
||||
type: MongooseSchema.Types.ObjectId,
|
||||
ref: 'Attachment',
|
||||
default: null,
|
||||
})
|
||||
avatar: unknown;
|
||||
|
||||
@Prop({
|
||||
type: String,
|
||||
default: null,
|
||||
|
@ -10,11 +10,17 @@ import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { BaseService } from '@/utils/generics/base-service';
|
||||
|
||||
import { TUserCrudsDto } from '../dto/user.dto';
|
||||
import { UserRepository } from '../repositories/user.repository';
|
||||
import { User, UserFull, UserPopulate } from '../schemas/user.schema';
|
||||
|
||||
@Injectable()
|
||||
export class UserService extends BaseService<User, UserPopulate, UserFull> {
|
||||
export class UserService extends BaseService<
|
||||
User,
|
||||
UserPopulate,
|
||||
UserFull,
|
||||
TUserCrudsDto
|
||||
> {
|
||||
constructor(readonly repository: UserRepository) {
|
||||
super(repository);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user