diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..506cf3b --- /dev/null +++ b/pom.xml @@ -0,0 +1,37 @@ + + 4.0.0 + tanel + tanel + jar + 1 + + + org.springframework.boot + spring-boot-starter-parent + 1.5.2.RELEASE + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-data-jpa + + + mysql + mysql-connector-java + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file diff --git a/src/main/java/tanel/Application.java b/src/main/java/tanel/Application.java new file mode 100644 index 0000000..bde22f3 --- /dev/null +++ b/src/main/java/tanel/Application.java @@ -0,0 +1,50 @@ +package tanel; + +import java.util.*; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@SpringBootApplication +@RestController + +//funktsiooni nimed ja muutujad on väikese algustähega +//klassinimed camelcase + +public class Application{ + + @Autowired + private ManageTable manager; + + @RequestMapping("/create") + String create(String kauplus, String tooteNimi, Integer hind){ + manager.save(new Tooted(kauplus, tooteNimi, hind)); + return "Toode "+ tooteNimi +" lisatud"; + } + + @RequestMapping("/search") + String Search(String tooteNimi){ + if(tooteNimi.isEmpty()){return "no info";} + List tooted=manager.findBytooteNimi(tooteNimi); + if(tooted.isEmpty()){return tooteNimi+" not found";} + StringBuffer sb = new StringBuffer(); + for(Tooted toode: tooted){ + sb.append("

"); + sb.append("Toode " + tooteNimi + " on kaupluses nimega " + toode.kauplus + " ja see maksab: "+ toode.hind.toString()); + sb.append("

"); + } + return sb.toString(); + + } + + public static void main(String[] args){ + SpringApplication.run(Application.class, args); + } + + +} + + + diff --git a/src/main/java/tanel/ManageTable.java b/src/main/java/tanel/ManageTable.java new file mode 100644 index 0000000..a936609 --- /dev/null +++ b/src/main/java/tanel/ManageTable.java @@ -0,0 +1,10 @@ +package tanel; + +import java.util.*; +import javax.transaction.Transactional; +import org.springframework.data.repository.CrudRepository; + +@Transactional +public interface ManageTable extends CrudRepository { + List findBytooteNimi(String tooteNimi); +} \ No newline at end of file diff --git a/src/main/java/tanel/Tooted.java b/src/main/java/tanel/Tooted.java new file mode 100644 index 0000000..722a24a --- /dev/null +++ b/src/main/java/tanel/Tooted.java @@ -0,0 +1,26 @@ +package tanel; + +import javax.persistence.*; + +@Table(name="tooted") +@Entity +public class Tooted{ + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + public Long id; + public String kauplus; + public String tooteNimi; + public Integer hind; + + + public Tooted(){ + + } + + public Tooted(String kauplus, String tooteNimi, Integer hind){ + this.kauplus = kauplus; + this.tooteNimi = tooteNimi; + this.hind = hind; + } + +} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..9c34a48 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,7 @@ +spring.jpa.database=MYSQL +spring.jpa.show-sql=true +spring.jpa.hibernate.ddl-auto=create +spring.datasource.url = jdbc:mysql://localhost/if16_Tanelmaas_1 +spring.datasource.username = if16 +spring.datasource.password = ifikad16 +server.port = 8548 diff --git a/src/main/resources/public/background.gif b/src/main/resources/public/background.gif new file mode 100644 index 0000000..935b644 Binary files /dev/null and b/src/main/resources/public/background.gif differ diff --git a/src/main/resources/public/form.html b/src/main/resources/public/form.html new file mode 100644 index 0000000..f6f0865 --- /dev/null +++ b/src/main/resources/public/form.html @@ -0,0 +1,50 @@ + + + + Tooted + + + +
+

Lisa toode

+
+ + +
+
+ + +
+
+ + +
+
+
+ +
+
+
+ + + +
+ \ No newline at end of file diff --git a/target/classes/application.properties b/target/classes/application.properties new file mode 100644 index 0000000..9c34a48 --- /dev/null +++ b/target/classes/application.properties @@ -0,0 +1,7 @@ +spring.jpa.database=MYSQL +spring.jpa.show-sql=true +spring.jpa.hibernate.ddl-auto=create +spring.datasource.url = jdbc:mysql://localhost/if16_Tanelmaas_1 +spring.datasource.username = if16 +spring.datasource.password = ifikad16 +server.port = 8548 diff --git a/target/classes/public/background.gif b/target/classes/public/background.gif new file mode 100644 index 0000000..935b644 Binary files /dev/null and b/target/classes/public/background.gif differ diff --git a/target/classes/public/form.html b/target/classes/public/form.html new file mode 100644 index 0000000..abb186b --- /dev/null +++ b/target/classes/public/form.html @@ -0,0 +1,102 @@ + + + + + Tooted + + + +
+
+

Lisa toode

+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ +
+

+
+ + + +
+ \ No newline at end of file diff --git a/target/classes/tanel/Application.class b/target/classes/tanel/Application.class new file mode 100644 index 0000000..9d8c519 Binary files /dev/null and b/target/classes/tanel/Application.class differ diff --git a/target/classes/tanel/ManageTable.class b/target/classes/tanel/ManageTable.class new file mode 100644 index 0000000..e090ed4 Binary files /dev/null and b/target/classes/tanel/ManageTable.class differ diff --git a/target/classes/tanel/Tooted.class b/target/classes/tanel/Tooted.class new file mode 100644 index 0000000..8bc85c3 Binary files /dev/null and b/target/classes/tanel/Tooted.class differ diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties new file mode 100644 index 0000000..dc75bd5 --- /dev/null +++ b/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Fri Apr 07 14:28:07 EEST 2017 +version=1 +groupId=tanel +artifactId=tanel diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..d5caaba --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,3 @@ +tanel/Application.class +tanel/ManageTable.class +tanel/Tooted.class diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..41024c0 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,3 @@ +/home/tanelmaas/public_html/t05veebirakendus/src/main/java/tanel/ManageTable.java +/home/tanelmaas/public_html/t05veebirakendus/src/main/java/tanel/Application.java +/home/tanelmaas/public_html/t05veebirakendus/src/main/java/tanel/Tooted.java diff --git a/target/tanel-1.jar.original b/target/tanel-1.jar.original new file mode 100644 index 0000000..7fb6104 Binary files /dev/null and b/target/tanel-1.jar.original differ diff --git a/target/tanel-1.original b/target/tanel-1.original new file mode 100644 index 0000000..7057d87 Binary files /dev/null and b/target/tanel-1.original differ