forked from CSC207-UofT/course-project-super-turtle-hackers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into larry-matching
- Loading branch information
Showing
60 changed files
with
1,738 additions
and
1,169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.amigo.config; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.boot.context.properties.ConstructorBinding; | ||
|
||
/** | ||
* A POJO class that holds String constants for error messages. | ||
*/ | ||
@ConfigurationProperties(prefix = "error") | ||
@ConstructorBinding // specifies that config values should be injected through the constructor | ||
// such that the object can be immutable | ||
public class ErrorStringConfig { | ||
public final String PSWD_NOT_MATCH; | ||
public final String COURSE_INFO_FORMAT; | ||
|
||
public ErrorStringConfig(String pswdNotMatch, String courseInfoFormat) { | ||
this.PSWD_NOT_MATCH = pswdNotMatch; | ||
this.COURSE_INFO_FORMAT = courseInfoFormat; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
app/src/main/java/com/amigo/control/DashboardController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.amigo.control; | ||
|
||
import java.util.List; | ||
|
||
import com.amigo.match.DemoMatching; | ||
import com.amigo.match.Match; | ||
import com.amigo.present.UserPresenter; | ||
import com.amigo.user.User; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.ModelAttribute; | ||
import org.springframework.web.servlet.ModelAndView; | ||
|
||
@Controller | ||
public class DashboardController { | ||
|
||
@Autowired | ||
UserPresenter presenter; | ||
|
||
@GetMapping("/dashboard") | ||
public ModelAndView showDashboard(@ModelAttribute User user) { | ||
if (!user.isValid() && !presenter.hasUser()) { | ||
return new ModelAndView("error-page"); | ||
} | ||
if (user.isValid()) { | ||
presenter.setUser(user); | ||
} | ||
ModelAndView mav = new ModelAndView("dashboard"); | ||
presenter.populate(mav.getModel()); | ||
return mav; | ||
} | ||
|
||
@GetMapping("/matching-screen") | ||
public ModelAndView showMatchingScreen() { | ||
ModelAndView mav = new ModelAndView("matching-screen"); | ||
User currentUser = presenter.getUser(); | ||
var allMatches = DemoMatching.doMatching(currentUser); | ||
List<Match> matchList = allMatches.get(currentUser.getId()); | ||
currentUser.setCurrentMatches(matchList); | ||
|
||
int counter = 0; | ||
for (var each : currentUser.getCurrentMatches()) { | ||
UserPresenter p = new UserPresenter(); | ||
if (each.getUser1() == currentUser){ | ||
p.setUser(each.getUser2()); | ||
} | ||
else { | ||
p.setUser(each.getUser1()); | ||
} | ||
p.setSuffix(String.valueOf(++counter)); | ||
p.populate(mav.getModel()); | ||
} | ||
return mav; | ||
} | ||
|
||
@GetMapping("/*") | ||
public String showError() { | ||
return "error-page"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.