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";
import { CreateKweekDto } from "./create-kweek.dto";
export class UpdateKweekDto extends PartialType(CreateKweekDto) {}
export class UpdateKweekDTO {}

View file

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

View file

@ -1,7 +1,7 @@
import { Injectable } from "@nestjs/common";
import { PrismaService } from "src/prisma/prisma.service";
import { CreateKweekDTO } from "./dto/create-kweek.dto";
import { UpdateKweekDto } from "./dto/update-kweek.dto";
import { UpdateKweekDTO } from "./dto/update-kweek.dto";
@Injectable()
export class KweeksService {
@ -14,7 +14,7 @@ export class KweeksService {
return `This action returns a #${id} kweek`;
}
update(id: number, updateKweekDto: UpdateKweekDto) {
update(id: number, updateKweekDto: UpdateKweekDTO) {
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" })
@ApiBearerAuth("JWT")
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(
loggedUser: User,
id: string,
email: string,
): Promise<{ message: string }> {
const user = await this.prisma.user.findFirst({
where: { id: loggedUser.id },
where: { id },
});
if (email !== undefined && email.trim() !== user.email) {
@ -124,7 +124,7 @@ export class UserService {
await this.prisma.user.update({
where: {
id: loggedUser.id,
id,
},
data: {
email: email ?? user.email,
@ -136,12 +136,12 @@ export class UserService {
}
async updateName(
loggedUser: User,
id: string,
username: string | undefined,
displayName: string,
): Promise<Pick<User, "username" | "displayName">> {
const user = await this.prisma.user.findFirst({
where: { id: loggedUser.id },
where: { id },
});
if (username !== undefined && username.trim() !== user.username) {
@ -155,7 +155,7 @@ export class UserService {
return await this.prisma.user.update({
where: {
id: loggedUser.id,
id
},
data: {
displayName,