Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Commit

Permalink
feat: update userInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
YanceyOfficial committed Apr 10, 2020
1 parent bdbb34b commit fef273b
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 16 deletions.
5 changes: 5 additions & 0 deletions schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,11 @@ type UserModel {
email: String!
password: String!
role: Float!
name: String!
location: String!
organization: String!
website: String!
bio: String!
avaterUrl: String!
phoneNumber: String!
isTOTP: Boolean!
Expand Down
11 changes: 0 additions & 11 deletions src/users/dtos/create-user.input.ts

This file was deleted.

18 changes: 18 additions & 0 deletions src/users/dtos/update-user.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,22 @@ export class UpdateUserInput {

@Field({ nullable: true })
public readonly loginStatistics?: IPModel[]

@Field({ nullable: true })
public readonly name?: string

@Field({ nullable: true })
public readonly location?: string

@Field({ nullable: true })
public readonly organization?: string

@Field({ nullable: true })
public readonly website?: string

@Field({ nullable: true })
public readonly bio?: string

@Field({ nullable: true })
public readonly avaterUrl?: string
}
5 changes: 5 additions & 0 deletions src/users/interfaces/user.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export interface User extends Document {
email: string
password: string
role: Roles
name: string
location: string
organization: string
website: string
bio: string
avaterUrl: string
phoneNumber: string
isTOTP: boolean
Expand Down
15 changes: 15 additions & 0 deletions src/users/models/user.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ export class UserModel {
@Field()
public readonly role: number

@Field()
public readonly name: string

@Field()
public readonly location: string

@Field()
public readonly organization: string

@Field()
public readonly website: string

@Field()
public readonly bio: string

@Field()
public readonly avaterUrl: string

Expand Down
29 changes: 27 additions & 2 deletions src/users/schemas/users.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export const UserSchema = new mongoose.Schema(
type: String,
required: true,
},
username: {
default: '',
type: String,
required: true,
},
password: {
type: String,
required: true,
Expand All @@ -23,12 +28,32 @@ export const UserSchema = new mongoose.Schema(
type: Number,
required: true,
},
avaterUrl: {
name: {
default: '',
type: String,
required: false,
},
username: {
location: {
default: '',
type: String,
required: false,
},
organization: {
default: '',
type: String,
required: false,
},
website: {
default: '',
type: String,
required: false,
},
bio: {
default: '',
type: String,
required: false,
},
avaterUrl: {
default: '',
type: String,
required: false,
Expand Down
6 changes: 3 additions & 3 deletions src/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Injectable } from '@nestjs/common'
import { InjectModel } from '@nestjs/mongoose'
import { Model } from 'mongoose'
import { User } from './interfaces/user.interface'
import { CreateUserInput } from './dtos/create-user.input'
import { UpdateUserInput } from './dtos/update-user.input'
import { RegisterInput } from '../auth/dtos/register.input'

@Injectable()
export class UsersService {
Expand All @@ -26,8 +26,8 @@ export class UsersService {
return this.UserModel.findOne({ email })
}

public async create(createUserInput: CreateUserInput): Promise<User> {
return this.UserModel.create(createUserInput)
public async create(input: RegisterInput): Promise<User> {
return this.UserModel.create(input)
}

public async updateUser(input: UpdateUserInput): Promise<User> {
Expand Down

0 comments on commit fef273b

Please sign in to comment.