fix: rename DTO name

This commit is contained in:
Hackntosh 2024-02-03 17:00:10 +00:00
parent 2f33a05eab
commit ac9026aea6
6 changed files with 86 additions and 88 deletions

View file

@ -1,4 +1 @@
import { PartialType } from "@nestjs/swagger"; export class UpdateKweekDTO {}
import { CreateKweekDto } from "./create-kweek.dto";
export class UpdateKweekDto extends PartialType(CreateKweekDto) {}

View file

@ -1,18 +1,16 @@
import { FilesInterceptor } from "@nest-lab/fastify-multer";
import { import {
Controller,
Get,
Post,
Body, Body,
Patch, Controller,
Param,
Delete, Delete,
UseInterceptors, Get,
UploadedFiles, Param,
Patch,
Post,
Request, Request,
UploadedFiles,
UseInterceptors,
} from "@nestjs/common"; } from "@nestjs/common";
import { KweeksService } from "./kweeks.service";
import { CreateKweekDTO } from "./dto/create-kweek.dto";
import { UpdateKweekDto } from "./dto/update-kweek.dto";
import { import {
ApiBearerAuth, ApiBearerAuth,
ApiConsumes, ApiConsumes,
@ -20,7 +18,9 @@ import {
ApiTags, ApiTags,
} from "@nestjs/swagger"; } from "@nestjs/swagger";
import { Public } from "src/public.decorator"; import { Public } from "src/public.decorator";
import { FilesInterceptor } from "@nest-lab/fastify-multer"; import { CreateKweekDTO } from "./dto/create-kweek.dto";
import { UpdateKweekDTO } from "./dto/update-kweek.dto";
import { KweeksService } from "./kweeks.service";
@ApiTags("Kweeks") @ApiTags("Kweeks")
@Controller("kweeks") @Controller("kweeks")
@ -37,6 +37,7 @@ export class KweeksController {
@UploadedFiles() attachments: File, @UploadedFiles() attachments: File,
@Request() req, @Request() req,
) { ) {
// TODO: Find a way to handle multiple files with Swagger
return this.kweeksService.create(createKweekDto); return this.kweeksService.create(createKweekDto);
} }
@ -50,7 +51,7 @@ export class KweeksController {
@Patch(":id") @Patch(":id")
@ApiOperation({ summary: "Updates a kweek content" }) @ApiOperation({ summary: "Updates a kweek content" })
@ApiBearerAuth("JWT") @ApiBearerAuth("JWT")
update(@Param("id") id: string, @Body() updateKweekDto: UpdateKweekDto) { update(@Param("id") id: string, @Body() updateKweekDto: UpdateKweekDTO ) {
return this.kweeksService.update(+id, updateKweekDto); return this.kweeksService.update(+id, updateKweekDto);
} }

View file

@ -1,7 +1,7 @@
import { Injectable } from "@nestjs/common"; import { Injectable } from "@nestjs/common";
import { PrismaService } from "src/prisma/prisma.service"; import { PrismaService } from "src/prisma/prisma.service";
import { CreateKweekDTO } from "./dto/create-kweek.dto"; import { CreateKweekDTO } from "./dto/create-kweek.dto";
import { UpdateKweekDto } from "./dto/update-kweek.dto"; import { UpdateKweekDTO } from "./dto/update-kweek.dto";
@Injectable() @Injectable()
export class KweeksService { export class KweeksService {
@ -14,7 +14,7 @@ export class KweeksService {
return `This action returns a #${id} kweek`; return `This action returns a #${id} kweek`;
} }
update(id: number, updateKweekDto: UpdateKweekDto) { update(id: number, updateKweekDto: UpdateKweekDTO) {
return `This action updates a #${id} kweek`; return `This action updates a #${id} kweek`;
} }

View file

@ -125,6 +125,6 @@ export class UserController {
@ApiOperation({ summary: "Deletes the account of a logged user" }) @ApiOperation({ summary: "Deletes the account of a logged user" })
@ApiBearerAuth("JWT") @ApiBearerAuth("JWT")
delete(@Request() req) { delete(@Request() req) {
return this.userService.delete(req.user.id) return this.userService.delete(req.user.id);
} }
} }

View file

@ -107,11 +107,11 @@ export class UserService {
} }
async updateEmail( async updateEmail(
loggedUser: User, id: string,
email: string, email: string,
): Promise<{ message: string }> { ): Promise<{ message: string }> {
const user = await this.prisma.user.findFirst({ const user = await this.prisma.user.findFirst({
where: { id: loggedUser.id }, where: { id },
}); });
if (email !== undefined && email.trim() !== user.email) { if (email !== undefined && email.trim() !== user.email) {
@ -124,7 +124,7 @@ export class UserService {
await this.prisma.user.update({ await this.prisma.user.update({
where: { where: {
id: loggedUser.id, id,
}, },
data: { data: {
email: email ?? user.email, email: email ?? user.email,
@ -136,12 +136,12 @@ export class UserService {
} }
async updateName( async updateName(
loggedUser: User, id: string,
username: string | undefined, username: string | undefined,
displayName: string, displayName: string,
): Promise<Pick<User, "username" | "displayName">> { ): Promise<Pick<User, "username" | "displayName">> {
const user = await this.prisma.user.findFirst({ const user = await this.prisma.user.findFirst({
where: { id: loggedUser.id }, where: { id },
}); });
if (username !== undefined && username.trim() !== user.username) { if (username !== undefined && username.trim() !== user.username) {
@ -155,7 +155,7 @@ export class UserService {
return await this.prisma.user.update({ return await this.prisma.user.update({
where: { where: {
id: loggedUser.id, id
}, },
data: { data: {
displayName, displayName,