Skip to content
Snippets Groups Projects
Commit 1ce226b5 authored by Connor Brock's avatar Connor Brock
Browse files

Began integrating database classes and brief fields to access the database at a later point.

parent 9fb3f345
No related branches found
No related tags found
1 merge request!41Resolve "As a convenience enthusiast, I want a drop down menu to be able to quickly scan QR codes I find along my dragon trail so that I may continue on my adventure without disruption."
......@@ -5,6 +5,10 @@ import Team5.SmartTowns.landmarks.Landmarks;
import java.util.List;
public class DragonsTale {
Landmarks landmarks = new Landmarks();
private int landmarkID = landmarks.getLandmarkID();
private String landmarkName = landmarks.getLandmarkName();
private String landmarkDescription = landmarks.getLandmarkDescription();
public static List<Landmarks> landmarksDragonstrail = List.of(
new Landmarks( 1, "A scent of...Dragon", "The Dragon has been spotted near by, find the QR code to continue" , "Start your discovery, at the sweet shop."),
new Landmarks( 2, "They've been found!", "Don't let them escape, find the next QR code to continue!", "Location test")
......
......@@ -4,6 +4,8 @@ import Team5.SmartTowns.landmarks.Landmarks;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
......@@ -12,7 +14,8 @@ import static Team5.SmartTowns.dragonstale.DragonsTale.landmarksDragonstrail;
@Controller
@RestController
public class DragonsTaleController {
ModelAndView modelAndView;
......@@ -20,19 +23,26 @@ public class DragonsTaleController {
public ModelAndView getDragonsTale(){
List<Landmarks> landmarksList = landmarksDragonstrail;
int landmarksListSize = landmarksDragonstrail.size();
modelAndView = new ModelAndView("/dragonstale/index");
modelAndView.addObject("landmarksList", landmarksList);
modelAndView.addObject("getListSize", landmarksListSize);
modelAndView = new ModelAndView("/dragonstale/index")
.addObject("landmarksList", landmarksList)
.addObject("getListSize", landmarksListSize);
return modelAndView;
}
@RequestMapping ("/QRScan") //In here, we could use trailID as a string variable and use it to track what trail the user clicked from.
@GetMapping ("/QRScan") //In here, we could use trailID as a string variable and use it to track what trail the user clicked from.
public ModelAndView getQRScanner(){
modelAndView = new ModelAndView("fragments/qr-scanner");
//Can we extract the pathvariable in a JS function?
return modelAndView;
}
@GetMapping("/dragonstale/{landmarkID}")
public Integer getDTLandmarkID(@RequestParam(value="landmarkID") int landmark){
Integer idCounter = 0;
modelAndView = new ModelAndView("/dragonstale/{landmarkID}")
.addObject() //All your doing is retrieving the information from the database giving it to a string variable.
}
//Create another controller that directs to the given DragonsTale..Trail.. and updates the users account accordingly.
// This code is to be used
......
package Team5.SmartTowns.dragonstale;
import Team5.SmartTowns.users.User;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class DragonsTaleJDBC implements DragonsTaleRepository{
private JdbcTemplate jdbc;
private RowMapper<User> userMapper;
@Override
public Map<Long, Boolean> getDTCompletion(int landmarkID){
//Be conscious of sql injections here.
String sql = "SELECT userid, trailID, completedOrNot FROM dtprogress WHERE landmarkID = ?";
int dtQuery = jdbc.query(sql, landmarkID);
//Query it twice to extract the given parameters, then use these parameters in a loop to query the completion.
List<Map<String, Integer>> query = jdbc.query(sql, id);
Map<Long, Boolean> dtProgress = new HashMap<>();
for (Map<String, Object> result : dtQuery) {
dtProgress.put((Long)result.get("stickerID"), (boolean)result.get("hasSticker"));
}
return dtProgress;
}
}
package Team5.SmartTowns.dragonstale;
public interface DragonsTaleRepository {
}
......@@ -16,6 +16,10 @@ body{
border: none;
cursor: pointer;
}
.images{
max-width:100%;
height:auto;
}
.landmarkName{
......
......@@ -3,6 +3,7 @@
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>A Dragon's Tale</title>
<link rel="stylesheet" th:href="@{/css/dragonstaless.css}">
<link rel="stylesheet" th:href="@{/css/templatingstyle.css}">
......@@ -14,7 +15,7 @@
<!-- As this predefined trail will be accessible from multiple different towns, this thymeleaf element will display the town the user is currently trying to access and display it accordingly. <span th:text="${townName}"> -->
<div>
<h1> Welcome, to a dragon's tale! </h1>
<img th:src="@{/images/trails/dragonstalehome.png}" alt="Image of a dragon" id="homeimg">
<img th:src="@{/images/trails/dragonstalehome.png}" alt="Image of a dragon" class="images">
<h2> Discover the mystery of the dragon, track its location and follow it throughout the town of to discover a prize! </h2>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment