Merge branch 'develop' into frontend/timo
# Conflicts: # .idea/modules.xml
This commit is contained in:
commit
77d6a849a6
2
.gitignore
vendored
2
.gitignore
vendored
@ -24,6 +24,8 @@ labswp_2019_sose_geocaching.iml
|
|||||||
# public folder
|
# public folder
|
||||||
src/main/resources/public/
|
src/main/resources/public/
|
||||||
|
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
|
||||||
# Gradle
|
# Gradle
|
||||||
.idea/**/gradle.xml
|
.idea/**/gradle.xml
|
||||||
|
|||||||
2
.idea/compiler.xml
generated
2
.idea/compiler.xml
generated
@ -6,6 +6,8 @@
|
|||||||
<module name="de.hhn.labsw.BuGaGeocaching.test" target="1.8" />
|
<module name="de.hhn.labsw.BuGaGeocaching.test" target="1.8" />
|
||||||
<module name="de.hhn.labsw.labswp_2019_sose_geocaching.main" target="1.8" />
|
<module name="de.hhn.labsw.labswp_2019_sose_geocaching.main" target="1.8" />
|
||||||
<module name="de.hhn.labsw.labswp_2019_sose_geocaching.test" target="1.8" />
|
<module name="de.hhn.labsw.labswp_2019_sose_geocaching.test" target="1.8" />
|
||||||
|
<module name="labswp_2019_sose_geocaching.de.hhn.labsw.labswp_2019_sose_geocaching.main" target="1.8" />
|
||||||
|
<module name="labswp_2019_sose_geocaching.de.hhn.labsw.labswp_2019_sose_geocaching.test" target="1.8" />
|
||||||
</bytecodeTargetLevel>
|
</bytecodeTargetLevel>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@ -27,6 +27,12 @@ dependencies {
|
|||||||
|
|
||||||
//MariaDB
|
//MariaDB
|
||||||
implementation 'org.mariadb.jdbc:mariadb-java-client'
|
implementation 'org.mariadb.jdbc:mariadb-java-client'
|
||||||
|
|
||||||
|
//Thymeleaf
|
||||||
|
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
|
||||||
|
|
||||||
|
//JSON Parser
|
||||||
|
implementation 'com.google.code.gson:gson:2.8.5'
|
||||||
}
|
}
|
||||||
|
|
||||||
node {
|
node {
|
||||||
|
|||||||
@ -0,0 +1,31 @@
|
|||||||
|
package hhn.labsw.bugageocaching.controller;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import hhn.labsw.bugageocaching.entities.Cache;
|
||||||
|
import hhn.labsw.bugageocaching.repositories.CacheRepository;
|
||||||
|
import hhn.labsw.bugageocaching.repositories.RewardRepository;
|
||||||
|
import hhn.labsw.bugageocaching.repositories.StationRepository;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class Controller {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CacheRepository cacheRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
RewardRepository rewardRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
StationRepository stationRepository;
|
||||||
|
|
||||||
|
@RequestMapping("/allCaches")
|
||||||
|
@ResponseBody
|
||||||
|
public String getAllCaches(){
|
||||||
|
return new Gson().toJson(cacheRepository.findAll());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
58
src/main/java/hhn/labsw/bugageocaching/db/DBConnector.java
Normal file
58
src/main/java/hhn/labsw/bugageocaching/db/DBConnector.java
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
package hhn.labsw.bugageocaching.db;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class DBConnector {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Installation of the web service
|
||||||
|
*
|
||||||
|
* The following parameters have to be changed for setting up the web service in another environment.
|
||||||
|
* DB_HOST = Address of the database. Examples: localhost, 192.168.12.7, mydomain.com
|
||||||
|
* DB_USER = Username for the database connection
|
||||||
|
* DB_PASSWORD = Password for the database connection
|
||||||
|
* DATABASE = Name of the database that shall be used
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final String DB_HOST = "www.se.hs-heilbronn.de:3406/buga19Geocaching";
|
||||||
|
private static final String DB_USER = "BuGa19GeocachingUser";
|
||||||
|
private static final String DB_PASSWORD = "GeocachingPw";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For setting up the Webservice no changes are needed from here!
|
||||||
|
*/
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(DBConnector.class);
|
||||||
|
|
||||||
|
public static Connection connect() {
|
||||||
|
|
||||||
|
logger.debug("Trying to establish connection to database");
|
||||||
|
|
||||||
|
try {
|
||||||
|
Class.forName("org.mariadb.jdbc.Driver");
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Connect to database
|
||||||
|
*/
|
||||||
|
Connection connection = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
connection = DriverManager.getConnection("jdbc:mariadb://" + DB_HOST + "?user=" + DB_USER + "&password=" + DB_PASSWORD);
|
||||||
|
logger.debug("Connected");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user