Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions semana17/semana17-projeto/src/endpoints/getAllProducts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ export default async function getAllProducts(
): Promise<void> {
try {
const search = req.query.search || "%";
const products: Product[] = await connection("labecommerce_products").where(
"name",
"LIKE",
`%${search}%`
);
const order = req.query.order === "ASC" ? "ASC" : "DESC";
const products: Product[] = await connection("labecommerce_products")
.select()
.orderBy("name", order)
.where("name", "LIKE", `%${search}%`);

res.send(products);
} catch (error: any) {
Expand Down
4 changes: 3 additions & 1 deletion semana17/semana17-projeto/src/endpoints/getAllUsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { User } from "../types";

export default async function getAllUsers(req: Request, res: Response) {
try {
const users: User[] = await connection("labecommerce_users");
const users: User[] = await connection.raw(`SELECT * FROM labecommerce_users
JOIN labecommerce_purchases
ON labecommerce_users.${req.body.id} = labecommerce_purchases.${req.body.user_id};`);
res.send(users);
} catch (error: any) {
res.status(400).send({ message: error.message });
Expand Down
22 changes: 22 additions & 0 deletions semana18/aula52/src/exercicio01.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
type Transaction = {
description: string;
value: number;
date: string;
};

class UserAccount {
private cpf: string;
private name: string;
private age: number;
private balance: number = 0;
private transactions: Transaction[] = [];

constructor(cpf: string, name: string, age: number) {
console.log("Chamando o construtor da classe UserAccount");
this.cpf = cpf;
this.name = name;
this.age = age;
}

user1: UserAccount = new UserAccount("123456", "Carlos Daniel", 21);
}
Loading