From 464938086722bdde4231bc11bb0ae9af716861fd Mon Sep 17 00:00:00 2001 From: Gabriel Torelo <57268681+GabrielTorelo@users.noreply.github.com> Date: Tue, 11 Jul 2023 03:24:59 -0300 Subject: [PATCH 1/3] cria arquivos '.properties' (application e application-test) do projeto --- src/main/resources/application-test.properties | 12 ++++++++++++ src/main/resources/application.properties | 3 +++ 2 files changed, 15 insertions(+) create mode 100644 src/main/resources/application-test.properties diff --git a/src/main/resources/application-test.properties b/src/main/resources/application-test.properties new file mode 100644 index 0000000..9e61b4b --- /dev/null +++ b/src/main/resources/application-test.properties @@ -0,0 +1,12 @@ +# H2 Connection +spring.datasource.url=jdbc:h2:mem:testdb +spring.datasource.username=sa +spring.datasource.password= + +# H2 Client +spring.h2.console.enabled=true +spring.h2.console.path=/h2-console + +# Show SQL +spring.jpa.show-sql=true +spring.jpa.properties.hibernate.format_sql=true diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 8b13789..e560631 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1 +1,4 @@ +spring.profiles.active=${APP_PROFILE:test} +spring.jpa.open-in-view=false +cors.origins=${CORS_ORIGINS:http://localhost:5173,http://localhost:3000} From 94625661d7bc178f13b572b0eb69b0a208817a96 Mon Sep 17 00:00:00 2001 From: Gabriel Torelo <57268681+GabrielTorelo@users.noreply.github.com> Date: Thu, 13 Jul 2023 09:15:32 -0300 Subject: [PATCH 2/3] cria classe 'Game' com ORM 'jakarta' --- .../game_list/entities/Game.java | 140 ++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 src/main/java/com/gabriel_torelo/game_list/entities/Game.java diff --git a/src/main/java/com/gabriel_torelo/game_list/entities/Game.java b/src/main/java/com/gabriel_torelo/game_list/entities/Game.java new file mode 100644 index 0000000..e9d58b7 --- /dev/null +++ b/src/main/java/com/gabriel_torelo/game_list/entities/Game.java @@ -0,0 +1,140 @@ +package com.gabriel_torelo.game_list.entities; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +@Entity +@Table(name = "tb_game") +public class Game { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + private String title; + + @Column(name = "game_year") + private Integer year; + private String gender; + private String platforms; + private Double score; + private String imgUrl; + private String shortDescription; + private String longDescription; + + public Game() { + } + + public Game(Long id, String title, Integer year, String gender, String platforms, Double score, String imgUrl, + String shortDescription, String longDescription) { + this.id = id; + this.title = title; + this.year = year; + this.gender = gender; + this.platforms = platforms; + this.score = score; + this.imgUrl = imgUrl; + this.shortDescription = shortDescription; + this.longDescription = longDescription; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Integer getYear() { + return year; + } + + public void setYear(Integer year) { + this.year = year; + } + + public String getGender() { + return gender; + } + + public void setGender(String gender) { + this.gender = gender; + } + + public String getPlatforms() { + return platforms; + } + + public void setPlatforms(String platforms) { + this.platforms = platforms; + } + + public Double getScore() { + return score; + } + + public void setScore(Double score) { + this.score = score; + } + + public String getImgUrl() { + return imgUrl; + } + + public void setImgUrl(String imgUrl) { + this.imgUrl = imgUrl; + } + + public String getShortDescription() { + return shortDescription; + } + + public void setShortDescription(String shortDescription) { + this.shortDescription = shortDescription; + } + + public String getLongDescription() { + return longDescription; + } + + public void setLongDescription(String longDescription) { + this.longDescription = longDescription; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Game other = (Game) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } +} From 0ca3bea6c8dbd19c5bcec948173327ec570387c1 Mon Sep 17 00:00:00 2001 From: Gabriel Torelo <57268681+GabrielTorelo@users.noreply.github.com> Date: Fri, 14 Jul 2023 00:26:28 -0300 Subject: [PATCH 3/3] altera o tipo da coluna 'longDescription' para aceitar mais de 255 caracteres --- src/main/java/com/gabriel_torelo/game_list/entities/Game.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gabriel_torelo/game_list/entities/Game.java b/src/main/java/com/gabriel_torelo/game_list/entities/Game.java index e9d58b7..96cf8d2 100644 --- a/src/main/java/com/gabriel_torelo/game_list/entities/Game.java +++ b/src/main/java/com/gabriel_torelo/game_list/entities/Game.java @@ -23,6 +23,8 @@ public class Game { private Double score; private String imgUrl; private String shortDescription; + + @Column(columnDefinition = "LONGTEXT") private String longDescription; public Game() {