123 lines
1.9 KiB
TypeScript
123 lines
1.9 KiB
TypeScript
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
import {ApiProperty} from '@nestjs/swagger';
|
|
import { Document } from 'mongoose';
|
|
|
|
interface Token {
|
|
token: string;
|
|
expired_at: string;
|
|
}
|
|
|
|
export class CreateUserRequest {
|
|
@ApiProperty()
|
|
login: string;
|
|
|
|
@ApiProperty()
|
|
avatar: string;
|
|
|
|
@ApiProperty()
|
|
password: string;
|
|
}
|
|
|
|
export class UpdateUserRequest {
|
|
@ApiProperty()
|
|
login: string;
|
|
|
|
@ApiProperty()
|
|
avatar: string;
|
|
}
|
|
|
|
export class UserResponse {
|
|
@ApiProperty()
|
|
login: string;
|
|
|
|
@ApiProperty()
|
|
avatar: string;
|
|
|
|
@ApiProperty()
|
|
is_admin: boolean;
|
|
}
|
|
|
|
export class UserModel {
|
|
@ApiProperty()
|
|
login: string;
|
|
|
|
@ApiProperty()
|
|
avatar: string;
|
|
|
|
@ApiProperty()
|
|
password: string;
|
|
|
|
@ApiProperty()
|
|
is_admin: boolean;
|
|
|
|
@ApiProperty()
|
|
access_token: Token[];
|
|
|
|
@ApiProperty()
|
|
refresh_token: Token[];
|
|
}
|
|
|
|
@Schema()
|
|
export class User extends Document {
|
|
@Prop({
|
|
required: true,
|
|
unique: true,
|
|
type: String,
|
|
})
|
|
login: string;
|
|
|
|
@Prop({
|
|
required: true,
|
|
type: String,
|
|
})
|
|
password: string;
|
|
|
|
@Prop({
|
|
type: String,
|
|
})
|
|
avatar: string;
|
|
|
|
@Prop({
|
|
type: Boolean,
|
|
})
|
|
is_admin: boolean;
|
|
|
|
@Prop({
|
|
type: [{
|
|
token: String,
|
|
expired_at: String,
|
|
}]
|
|
})
|
|
access_token: Token[];
|
|
|
|
@Prop({
|
|
type: [{
|
|
token: String,
|
|
expired_at: String,
|
|
}]
|
|
})
|
|
refresh_token: Token[];
|
|
}
|
|
|
|
@Schema()
|
|
export class UserUpdate extends Document {
|
|
@Prop({
|
|
required: true,
|
|
type: String,
|
|
})
|
|
login: string;
|
|
|
|
@Prop({
|
|
type: String,
|
|
})
|
|
avatar: string;
|
|
|
|
@Prop({
|
|
type: Boolean,
|
|
})
|
|
is_admin: boolean;
|
|
}
|
|
|
|
export const UserUpdateSchema = SchemaFactory.createForClass(UserUpdate);
|
|
export const UserSchema = SchemaFactory.createForClass(User);
|