diff --git a/api/src/user/dto/user.dto.ts b/api/src/user/dto/user.dto.ts index 2b082b6e..c4d3c437 100644 --- a/api/src/user/dto/user.dto.ts +++ b/api/src/user/dto/user.dto.ts @@ -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; +}>; diff --git a/api/src/user/schemas/user.schema.ts b/api/src/user/schemas/user.schema.ts index a97d2057..5d5755f0 100644 --- a/api/src/user/schemas/user.schema.ts +++ b/api/src/user/schemas/user.schema.ts @@ -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, diff --git a/api/src/user/services/user.service.ts b/api/src/user/services/user.service.ts index 39c2e57a..a9387c19 100644 --- a/api/src/user/services/user.service.ts +++ b/api/src/user/services/user.service.ts @@ -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 { +export class UserService extends BaseService< + User, + UserPopulate, + UserFull, + TUserCrudsDto +> { constructor(readonly repository: UserRepository) { super(repository); }