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

Adding integration into the current Users class to pull dragonstale QR code information out.

parent 6ebdb676
No related branches found
No related tags found
1 merge request!27Qr codes
package Team5.SmartTowns.Data;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import java.util.List;
public class MockUser {
private JdbcTemplate jdbc;
private RowMapper<trail> trailMapper;
public List<trail> getAllTrails(){
String sql= "SELECT * FROM trails";
return jdbc.query(sql, trailMapper);
}
}
package Team5.SmartTowns.Data;
public class QRCodes {
}
......@@ -45,14 +45,15 @@ public class TrailsController {
}
// //
// @GetMapping("dragonstale/{qrCode}/{id}")
// public String qrCodeCheck(@PathVariable Optional<String> qrCode, @PathVariable Optional<Integer> id){
// if (qrCode.isPresent() && id.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.
}
}
}
......@@ -16,15 +16,16 @@ public class User {
String name;
String imgPath;
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)
public User(int id, String email, String name, int dragonProgress) {
public User(int id, String email, String name, int dragonProgress, HashMap<Integer, Boolean> dragonstaleLandmarkIDs) {
this.id = id;
this.email = email;
this.name = name;
this.dragonProgress = dragonProgress;
this.dragonstaleLandmarkIDs = dragonstaleLandmarkIDs;
imgPath = findImagePath();
}
......
......@@ -8,5 +8,6 @@ public interface UserRepository {
List<User> getAllUsers();
// Map<Long, Integer> getBadgeProgress(int id);
Map<Long, Boolean> getStickers(int id);
Map<Integer, Boolean> getTest(int id);
User getUser(int id);
}
......@@ -12,22 +12,22 @@ import java.util.Map;
@Repository
public class UserRepositoryJDBC implements UserRepository{
private JdbcTemplate jdbc;
private RowMapper<User> userMapper;
private
public UserRepositoryJDBC(JdbcTemplate aJdbc){
this.jdbc = aJdbc;
setUserMapper();
}
private void setUserMapper(){
userMapper = (rs, i) -> new User(
rs.getInt("userID"),
rs.getString("email"),
rs.getString("name"),
rs.getInt("dragonProgress")
rs.getInt("dragonProgress"),
rs.getObject("dragonstaleLandmarkIDs", getTest())
);
}
......@@ -37,6 +37,7 @@ public class UserRepositoryJDBC implements UserRepository{
return jdbc.query(sql, userMapper);
}
@Override
public User getUser(int id){
String sql= "SELECT * FROM users WHERE userID="+id;
......@@ -55,6 +56,12 @@ 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, Integer> getBadgeProgress(int id){
......
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