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

Commented out code for URL query string integration to get a functioning QR...

Commented out code for URL query string integration to get a functioning QR code scanner for presentation
parent bedbd7bd
Branches QRCodes
No related tags found
1 merge request!27Qr codes
......@@ -7,17 +7,17 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.*;
@Controller
public class DatabaseController {
@Autowired
private locationRepository locationRepository;
@Autowired
private trailsRepository trailsRepository;
@GetMapping("/trailList")
public ModelAndView trailList() {
ModelAndView mav1 = new ModelAndView("towns/trailsData");
......
......@@ -9,7 +9,6 @@ public class MockUser {
private JdbcTemplate jdbc;
private RowMapper<trail> trailMapper;
public List<trail> getAllTrails(){
String sql= "SELECT * FROM trails";
return jdbc.query(sql, trailMapper);
......
......@@ -18,7 +18,7 @@ public class Landmarks {
// Initialized object to getID from trail.
//Predefined Landmark for Dragons Tale.
private static List<Landmarks> landmarksDragonstrail = List.of(
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")
);
......
......@@ -13,6 +13,8 @@ import java.util.Optional;
import static Team5.SmartTowns.Landmarks.Landmarks.landmarksDragonstrail;
//import static Team5.SmartTowns.Landmarks.Landmarks.landmarksDragonstrail;
@Controller
public class TrailsController {
@GetMapping("/allTrails")
......@@ -46,14 +48,14 @@ public class TrailsController {
//
@GetMapping("dragonstale/{qrCode}/{id}")
public String qrCodeCheck(@PathVariable Optional<String> qrCode, @PathVariable Optional<Integer> id){
if (qrCode.isPresent()){
//Check if ID is present, if do this, if not dfo that.
}
}
// @GetMapping("dragonstale/{qrCode}/{id}")
// public String qrCodeCheck(@PathVariable Optional<String> qrCode, @PathVariable Optional<Integer> id){
// if (qrCode.isPresent()){
//
// //Check if ID is present, if do this, if not dfo that.
//
// }
// }
}
......@@ -5,12 +5,13 @@ import Team5.SmartTowns.rewards.Sticker;
import lombok.Data;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.HashMap;
import java.util.Map;
@Data
public class User {
int id;
String email; //Validation would be done by email, since they will have that
String name;
......@@ -18,18 +19,17 @@ public class User {
int dragonProgress;
Map<Badge, Integer> badgeProgress = new HashMap<>(); // Demonstrates the progress towards a specific badge (0-100)
Map<Sticker, Boolean> hasStickers = new HashMap<>(); // True if User has sticker (key)
Map<Integer, Boolean> dragonstaleLandmarkIDs = new HashMap<>(); // Storing the IDs of the landmarks associated with Dragonstale, as well as if the user has visited it before (boolean)
Map<Integer, Boolean> dragonstaleLandmarkIDs = new HashMap<>(); // Storing the IDs of the landmarks associated with Dragonstale, as well as if the user has visited it before (boolean)
public User(int id, String email, String name, int dragonProgress, HashMap<Integer, Boolean> dragonstaleLandmarkIDs) {
public User(int id, String email, String name, int dragonProgress) {
this.id = id;
this.email = email;
this.name = name;
this.dragonProgress = dragonProgress;
this.dragonstaleLandmarkIDs = dragonstaleLandmarkIDs;
// this.dragonstaleLandmarkIDs = dragonstaleLandmarkIDs;
imgPath = findImagePath();
}
private String findImagePath(){
/* Finds the image in the Path folder, if image is not found assigns default image */
String imgPath = "images/users/" + id + ".jpg";
......
......@@ -8,6 +8,7 @@ public interface UserRepository {
List<User> getAllUsers();
// Map<Long, Integer> getBadgeProgress(int id);
Map<Long, Boolean> getStickers(int id);
Map<Integer, Boolean> getTest(int id);
// Map<Integer, Boolean> getTest(int id);
// Map<Long, Boolean> getDTCompletion(int id);
User getUser(int id);
}
......@@ -5,7 +5,6 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -14,7 +13,6 @@ import java.util.Map;
public class UserRepositoryJDBC implements UserRepository{
private JdbcTemplate jdbc;
private RowMapper<User> userMapper;
private
public UserRepositoryJDBC(JdbcTemplate aJdbc){
this.jdbc = aJdbc;
......@@ -26,8 +24,7 @@ public class UserRepositoryJDBC implements UserRepository{
rs.getInt("userID"),
rs.getString("email"),
rs.getString("name"),
rs.getInt("dragonProgress"),
rs.getObject("dragonstaleLandmarkIDs", getTest())
rs.getInt("dragonProgress")
);
}
......@@ -56,11 +53,17 @@ public class UserRepositoryJDBC implements UserRepository{
return progress;
}
@Override
public Map<Integer, Boolean> getDTCompletion(int id){
//Loop over multiple different key-value pairs to find the one that's needed.
String sql = "SELECT "
}
// @Override
// public Map<Long, Boolean> getDTCompletion(int id){
// //Using prepared statement to prevent SQL injections
// String sql = "SELECT userid, qrCodeSCAN FROM testuser WHERE userID= ?";
// List<Map<String, Object>> dtQuery = jdbc.queryForList(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;
// }
// @Override
......
......@@ -54,5 +54,4 @@ insert into badgeprogress (userID, badgeID, progress) value ('2', '2', '70');
delete from stickerprogress;
insert into stickerprogress (userID, stickerID, hasSticker) value ('1', '1', true);
insert into stickerprogress (userID, stickerID, hasSticker) value ('1', '3', true);
<<<<<<< HEAD
insert into stickerprogress (userID, stickerID, hasSticker) value ('2', '2', true);
\ No newline at end of file
insert into stickerprogress (userID, stickerID, hasSticker) value ('2', '2', true);
......@@ -23,7 +23,8 @@ create table if not exists users
userID bigint auto_increment primary key,
email varchar(128),
name varchar(128),
dragonProgress int
dragonProgress int,
dragonsLandmarkIDs longtext
) engine=InnoDB;
drop table if exists badges;
......
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