/
PeopleController.java
64 lines (55 loc) · 2.16 KB
/
PeopleController.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package edu.rit.taskers.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import edu.rit.taskers.persistence.ContactDao;
/**
* Handles requests within a space related to people (contact cards).
*/
@Controller
@RequestMapping("/people")
public class PeopleController {
private static final Logger logger = LoggerFactory.getLogger(PeopleController.class);
@Autowired
private ContactDao contactDao;
/**
* Fetch all contact cards that belong to session space id
* @return Collection of contact cards
*/
@RequestMapping(method = RequestMethod.GET)
public ModelAndView getAllContacts(@CookieValue("SPACE") int id) {
ModelAndView peopleJspAndContactsPage = new ModelAndView("people", "allcontacts", contactDao.findBySpace(id));
return peopleJspAndContactsPage;
}
/**
* Retrieve the contact card from a selected person in the list
*/
@RequestMapping(value="/{id}", method=RequestMethod.GET)
public ModelAndView getContactDetails(@PathVariable int id) {
ModelAndView contactDetailsPage = new ModelAndView("viewcontact", "contact", contactDao.findById(id));
return contactDetailsPage;
}
/**
* Invite Contact page requested
*/
@RequestMapping(value="/invite", method=RequestMethod.GET)
public ModelAndView getInvitePage() {
ModelAndView inviteContactPage = new ModelAndView("invite");
return inviteContactPage;
}
/**
* Search contacts for with email address specified by client
*/
// @RequestMapping(value="/invite/{email}", method=RequestMethod.POST)
// public @ResponseBody boolean searchForContact(@RequestParam String email) {
// //TODO figure out email format validation location (probably client side)
// logger.info("Searching contacts with inputted email address [email:" + email + "]");
// return true;
// }
}