44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
import { ChangeEmailInput } from '@/src/module/auth/account/inputs/change-email.input'
|
|
import { ChangePasswordInput } from '@/src/module/auth/account/inputs/change-password.input'
|
|
import { Authorization } from '@/src/shared/decorators/auth.decorator'
|
|
import { Authorized } from '@/src/shared/decorators/authorized.decorator'
|
|
import { User } from '@prisma/generated'
|
|
import { CreateUserInput } from './inputs/create-user.input'
|
|
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql'
|
|
import { AccountService } from './account.service'
|
|
import { UserModel } from './models/user.model'
|
|
|
|
@Resolver('Account')
|
|
export class AccountResolver {
|
|
constructor(private readonly accountService: AccountService) {}
|
|
|
|
@Query(() => UserModel, { name: 'findProfile' })
|
|
@Authorization()
|
|
public me(@Authorized('id') id: UserModel['id']) {
|
|
return this.accountService.me(id)
|
|
}
|
|
|
|
@Mutation(() => UserModel, { name: 'createUser' })
|
|
public async create(@Args('data') input: CreateUserInput) {
|
|
return this.accountService.create(input)
|
|
}
|
|
|
|
@Authorization()
|
|
@Mutation(() => UserModel, { name: 'changeEmail' })
|
|
public async changeEmail(
|
|
@Args('data') input: ChangeEmailInput,
|
|
@Authorized() user: User,
|
|
) {
|
|
return this.accountService.changeEmail(user, input)
|
|
}
|
|
|
|
@Authorization()
|
|
@Mutation(() => UserModel, { name: 'changePassword' })
|
|
public async changePassword(
|
|
@Args('data') input: ChangePasswordInput,
|
|
@Authorized() user: User,
|
|
) {
|
|
return this.accountService.changePassword(user, input)
|
|
}
|
|
}
|