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
37 changes: 37 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>jaagup</groupId>
<artifactId>veeb</artifactId>
<packaging>jar</packaging>
<version>1</version>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.6.RELEASE</version>
</parent>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
9 changes: 9 additions & 0 deletions src/main/java/ksenbelo/MangudenimikiriTab.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package ksenbelo;

import org.springframework.data.repository.CrudRepository;
import javax.transaction.Transactional;

@Transactional
public interface MangudenimikiriTab extends CrudRepository<mangudenimekiri, Integer> {

}
59 changes: 59 additions & 0 deletions src/main/java/ksenbelo/Rakendus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package ksenbelo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.*;

@RestController
@SpringBootApplication
public class Rakendus{

@Autowired
private MangudenimikiriTab mangudenimikiriTab;


@RequestMapping("/helo")
String tervitusfunktsioon(){
return "hello!";
}

@RequestMapping("/mangud")
public String magnud2(){
String str = "Mängud:</br>";
for (mangudenimekiri mangudenimekiri: mangudenimikiriTab.findAll()){
str = str + mangudenimekiri.title + " " + mangudenimekiri.year + " " + mangudenimekiri.cost;
str += "</br>";
}
return str;
}
/*
Mängud:
The Sims 4 2014 40
The Sims 3 2013 30
Batlefield 1 2016 60
TheSims3 2013 30
*/

@RequestMapping("/lisa")
String lisa(String title, Integer year, Integer cost) {
mangudenimekiri mangudenimekiri = new mangudenimekiri();
mangudenimekiri.title = title;
mangudenimekiri.year = year;
mangudenimekiri.cost = cost;
mangudenimikiriTab.save(mangudenimekiri);
return "Lisatud " + title + year + cost;
}
/*
http://localhost:5246/lisa?title=TheSims3&year=2013&cost=30
*/

public static void main(String[] args) {
System.getProperties().put("server.port", 5254);
SpringApplication.run(Rakendus.class, args);
}

}

39 changes: 39 additions & 0 deletions src/main/java/ksenbelo/mangudenimekiri.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package ksenbelo;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "mangud2")
public class mangudenimekiri{
@Id
public String title;
public int year;
public int cost;
}

/*

CREATE TABLE mangud2(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(50),
year INT,
cost INT
);

INSERT INTO mangud2 VALUES ('','The Sims 4', '2014', '40');
INSERT INTO mangud2 VALUES ('','The Sims 3', '2009', '20');
INSERT INTO mangud2 VALUES ('','Batlefield 1', '2016', '60');

+----+--------------+------+------+
| id | title | year | cost |
+----+--------------+------+------+
| 1 | The Sims 4 | 2014 | 40 |
| 2 | The Sims 3 | 2009 | 20 |
| 3 | Batlefield 1 | 2016 | 60 |
+----+--------------+------+------+


mysql -uif16 -pifikad16 if16_ksenbelo_4
*/
4 changes: 4 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
spring.datasource.url = jdbc:mysql://localhost/if16_ksenbelo_4

spring.datasource.username = if16
spring.datasource.password = ifikad16
1 change: 1 addition & 0 deletions src/main/resources/public/veeb.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<html>
4 changes: 4 additions & 0 deletions target/classes/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
spring.datasource.url = jdbc:mysql://localhost/if16_ksenbelo_4

spring.datasource.username = if16
spring.datasource.password = ifikad16
Binary file added target/classes/ksenbelo/MangudenimikiriTab.class
Binary file not shown.
Binary file added target/classes/ksenbelo/Rakendus.class
Binary file not shown.
Binary file added target/classes/ksenbelo/mangudenimekiri.class
Binary file not shown.
1 change: 1 addition & 0 deletions target/classes/public/veeb.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<html>
5 changes: 5 additions & 0 deletions target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#Generated by Maven
#Tue May 09 14:41:01 EEST 2017
version=1
groupId=jaagup
artifactId=veeb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ksenbelo/mangudenimekiri.class
ksenbelo/MangudenimikiriTab.class
ksenbelo/Rakendus.class
Binary file added target/veeb-1.jar
Binary file not shown.
Binary file added target/veeb-1.jar.original
Binary file not shown.