Skip to content
Snippets Groups Projects
Commit b0250707 authored by Gabriel Copat's avatar Gabriel Copat
Browse files

New Controller for Users and Rewards

Added UserProfile HTML skeleton
Added Constructor for User Class
parent 6392b610
No related branches found
No related tags found
1 merge request!25Resolve "As a user, I would like a place to see all my earned badges, so that I can track my progress."
package Team5.SmartTowns.rewards;
import org.springframework.stereotype.Controller;
@Controller
public class RewardsController {
}
......@@ -2,17 +2,24 @@ package Team5.SmartTowns.users;
import Team5.SmartTowns.rewards.Badge;
import Team5.SmartTowns.rewards.Sticker;
import lombok.Data;
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;
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)
public User(int id, String email, String name) {
this.id = id;
this.email = email;
this.name = name;
}
}
package Team5.SmartTowns.users;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
@Controller
public class UserController {
/* TEMPORARY USER LIST --- TODO REPLACE IT WITH DATABASE LIST*/
List<User> users = List.of(
new User(1, "johndoe@gmail.com", "Chris Redfield"),
new User(2, "johndoe@gmail.com", "Claire Redfield"),
new User(3, "johndoe@gmail.com", "Leon Kennedy"),
new User(4, "johndoe@gmail.com", "Jill Valentine")
);
@GetMapping("/allTrails")
public ModelAndView getUserPage(){
ModelAndView mav = new ModelAndView("rewards/userProfile");
mav.addObject("trails", users); //Mock data for trails
return mav;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title th:text="${user.getName()}"></title>
</head>
<body>
</body>
</html>
\ No newline at end of file
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