diff --git a/ClubIndex/src/main/java/com/skilldistillery/jpaclubindex/controllers/UserController.java b/ClubIndex/src/main/java/com/skilldistillery/jpaclubindex/controllers/UserController.java index 4a6c4ed..d5f48f5 100644 --- a/ClubIndex/src/main/java/com/skilldistillery/jpaclubindex/controllers/UserController.java +++ b/ClubIndex/src/main/java/com/skilldistillery/jpaclubindex/controllers/UserController.java @@ -106,4 +106,38 @@ public String userDeleted(HttpSession session) { session.invalidate(); return "redirect:home.do"; } + +// @RequestMapping(path="getUser.do", params = {"userSearch", "searchType" }) +// public String switchSearchMethods(String userSearch, int searchType, HttpSession session) { +// switch (searchType) { +// case 1: +// return getUserByUserName(session, userSearch); +// case 2: +// return getUserByFirstName(session, userSearch); +// case 3: +// return getUserByLastName(session, userSearch); +// default: +// return userListsPage(session); +// } +// } +// +// @RequestMapping(path="userSearch.do") +// public String userListsPage(HttpSession session) { +// return "user/userListsPage"; +// } +// +// private String getUserByUserName(HttpSession session, String username) { +// session.setAttribute("user", userDao.findUserByUsername(username)); +// return "user/userProfile"; +// } +// +// private String getUserByFirstName(HttpSession session, String firstName) { +// session.setAttribute("user", userDao.findUserByFirstName(firstName)); +// return "user/userProfile"; +// } +// +// private String getUserByLastName(HttpSession session, String lastName) { +// session.setAttribute("user", userDao.findUserByLastName(lastName)); +// return "user/userProfile"; +// } } diff --git a/ClubIndex/src/main/java/com/skilldistillery/jpaclubindex/data/UserDAO.java b/ClubIndex/src/main/java/com/skilldistillery/jpaclubindex/data/UserDAO.java index ef6e450..dc5e881 100644 --- a/ClubIndex/src/main/java/com/skilldistillery/jpaclubindex/data/UserDAO.java +++ b/ClubIndex/src/main/java/com/skilldistillery/jpaclubindex/data/UserDAO.java @@ -1,5 +1,7 @@ package com.skilldistillery.jpaclubindex.data; +import java.util.List; + import com.skilldistillery.jpaclubindex.entities.User; public interface UserDAO { @@ -40,16 +42,16 @@ public interface UserDAO { User findUserByUsername(String username); /** - * Given a first name will find the associated User - * @return User + * Given a first name will find the associated Users + * @return List * @author ashleyosburn */ - User findUserByFirstName(String firstName); + List findUserByFirstName(String firstName); /** * Given a last name will find the associated User - * @return User + * @return List * @author ashleyosburn */ - User findUserByLastName(String lastName); + List findUserByLastName(String lastName); } diff --git a/ClubIndex/src/main/java/com/skilldistillery/jpaclubindex/data/UserDaoImpl.java b/ClubIndex/src/main/java/com/skilldistillery/jpaclubindex/data/UserDaoImpl.java index b9c6966..74cfbcb 100644 --- a/ClubIndex/src/main/java/com/skilldistillery/jpaclubindex/data/UserDaoImpl.java +++ b/ClubIndex/src/main/java/com/skilldistillery/jpaclubindex/data/UserDaoImpl.java @@ -1,5 +1,7 @@ package com.skilldistillery.jpaclubindex.data; +import java.util.List; + import javax.persistence.EntityManager; import javax.persistence.NoResultException; import javax.persistence.PersistenceContext; @@ -78,4 +80,16 @@ public User findUserByUsername(String username) { return null; } } + + @Override + public List findUserByFirstName(String firstName) { + String query = "SELECT u FROM User u WHERE u.firstName = :firstName"; + return em.createQuery(query, User.class).setParameter("firstName", firstName).getResultList(); + } + + @Override + public List findUserByLastName(String lastName) { + String query = "SELECT u FROM User u WHERE u.lastName = :lastName"; + return em.createQuery(query, User.class).setParameter("lastName", lastName).getResultList(); + } } diff --git a/ClubIndex/src/main/webapp/WEB-INF/author/author.jsp b/ClubIndex/src/main/webapp/WEB-INF/author/author.jsp index 3d48bcb..eb550a4 100644 --- a/ClubIndex/src/main/webapp/WEB-INF/author/author.jsp +++ b/ClubIndex/src/main/webapp/WEB-INF/author/author.jsp @@ -55,7 +55,7 @@ - ${aList.firstName} ${aList.lastName} + ${aList.firstName} ${aList.lastName} ${aList.firstName} ${aList.lastName} ${aList.biography} diff --git a/ClubIndex/src/main/webapp/WEB-INF/bookclub/bookClubLists.jsp b/ClubIndex/src/main/webapp/WEB-INF/bookclub/bookClubLists.jsp index ad494a6..d4b5382 100644 --- a/ClubIndex/src/main/webapp/WEB-INF/bookclub/bookClubLists.jsp +++ b/ClubIndex/src/main/webapp/WEB-INF/bookclub/bookClubLists.jsp @@ -21,7 +21,7 @@ ${bookClub.name} - ${bookClub.name} + ${bookClub.name} ${bookClub.aboutClub} ${bookClub.owner.username} ${bookClub.maxMembers} diff --git a/ClubIndex/src/main/webapp/WEB-INF/includes/nav.jsp b/ClubIndex/src/main/webapp/WEB-INF/includes/nav.jsp index 8d574d6..b5e48ea 100644 --- a/ClubIndex/src/main/webapp/WEB-INF/includes/nav.jsp +++ b/ClubIndex/src/main/webapp/WEB-INF/includes/nav.jsp @@ -9,6 +9,7 @@ Authors ReadingList Book Club Search + Account view diff --git a/ClubIndex/src/main/webapp/WEB-INF/user/userLists.jsp b/ClubIndex/src/main/webapp/WEB-INF/user/userLists.jsp new file mode 100644 index 0000000..422ab7e --- /dev/null +++ b/ClubIndex/src/main/webapp/WEB-INF/user/userLists.jsp @@ -0,0 +1,30 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + + + + + + + + + + + + + + + + + + + + + +
Profile PicNameAbout MeFirst Name
${user.username}${user.username}${user.aboutMe}${user.firstName}
+ Not what you're looking for? + + + \ No newline at end of file diff --git a/ClubIndex/src/main/webapp/WEB-INF/user/userProfile.jsp b/ClubIndex/src/main/webapp/WEB-INF/user/userProfile.jsp index 4eed315..aefc3b7 100644 --- a/ClubIndex/src/main/webapp/WEB-INF/user/userProfile.jsp +++ b/ClubIndex/src/main/webapp/WEB-INF/user/userProfile.jsp @@ -9,8 +9,12 @@
+
+
-
+
@@ -39,10 +43,10 @@
- ImageNotFound + ImageNotFound
-

${user.username}

-

${user.aboutMe}

+ <%--

${user.username}

+

${user.aboutMe}

--%>
diff --git a/ClubIndex/src/main/webapp/WEB-INF/user/userSearch.jsp b/ClubIndex/src/main/webapp/WEB-INF/user/userSearch.jsp new file mode 100644 index 0000000..3f4d9a7 --- /dev/null +++ b/ClubIndex/src/main/webapp/WEB-INF/user/userSearch.jsp @@ -0,0 +1,31 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + + + + + + + +
+
+
+
+ + + + + + + + + +
+
+
+ + + \ No newline at end of file