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