Skip to content

Commit

Permalink
Merge pull request #176 from in27sung/dash-04
Browse files Browse the repository at this point in the history
메인페이지 수정
  • Loading branch information
in27sung authored Dec 17, 2024
2 parents ed65298 + 68a40e9 commit 5a29360
Show file tree
Hide file tree
Showing 11 changed files with 361 additions and 238 deletions.
14 changes: 14 additions & 0 deletions stockMate/src/main/java/com/stockm8/controller/HomeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ public String howtouseGET(Model model, HttpSession session) throws Exception {
return "howtouse";
}

// 창고위치 - /location (GET)
@RequestMapping(value = "/location", method = RequestMethod.GET)
public String locationGET(Model model, HttpSession session) throws Exception {
Long userId = (Long) session.getAttribute("userId");
// if (id == null) {
// // 세션에 id가 없으면 에러 처리
// return "redirect:/user/main";
// }
// UserVO resultVO = userService.getUser(userId);
// model.addAttribute("resultVO", resultVO);
return "location";
}


// 상담하기 - /user/consultation (GET)
@RequestMapping(value = "/consultation", method = RequestMethod.GET)
public String consultationGET(Model model, HttpSession session) throws Exception {
Expand Down
80 changes: 38 additions & 42 deletions stockMate/src/main/java/com/stockm8/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,22 +142,6 @@ public String userLoginPOST(UserVO user, RedirectAttributes rttr, HttpSession se
return "redirect:/user/signin"; // 로그인 페이지 이동
}

// 메인페이지 - GET
@RequestMapping(value = "/main", method = RequestMethod.GET)
public void mainGET(HttpServletRequest request, Model model) throws Exception {
logger.info(" mainGET() 호출 ");

// FlashMap에서 에러 메시지 확인
Map<String, ?> flashMap = RequestContextUtils.getInputFlashMap(request);
if (flashMap != null) {
String errorMessage = (String) flashMap.get("errorMessage");
if (errorMessage != null) {
model.addAttribute("errorMessage", errorMessage);
}
}

logger.info(" /user/main -> /user/main.jsp 연결 ");
}

// 대시보드 페이지 - GET
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
Expand Down Expand Up @@ -269,31 +253,6 @@ public void userUpdatePOST(@ModelAttribute UserVO user, HttpSession session, Htt
}


// 비밀번호 찾기 - get
@RequestMapping(value = "/findPassword", method = RequestMethod.GET)
public String findPasswordGet() {

return "/user/findPassword";
}

// // 회원정보 수정 - GET
// // (기존정보를 가져와서 보여주고, 수정할 정보를 입력)
// @RequestMapping(value = "/editinfo1", method = RequestMethod.GET)
// public void userUpdateGET(@SessionAttribute("userId") Long userId, Model model) throws Exception {
// logger.info(" userUpdateGET() 호출 ");
//
// // 사용자의 ID정보를 가져오기(세션)
// logger.info("userId : " + userId);
//
// // 서비스 -> DAO 회원정보 가져오는 동작 호출
// UserVO resultVO = userService.getUser(userId);
//
// // 연결된 뷰페이지에 출력
// // => model 객체에 정보 저장
// model.addAttribute("resultVO", resultVO);
// // /user/update.jsp 뷰페이지 연결
// }
//

// 회원정보 수정
@RequestMapping(value = "/changepassword1", method = RequestMethod.GET)
Expand Down Expand Up @@ -392,7 +351,7 @@ public void changePasswordPOST(
}
}


// 상담하기 email - GET
@RequestMapping(value = "/sendConsultation", method = RequestMethod.POST)
public String sendConsultation(
@RequestParam("company") String company,
Expand Down Expand Up @@ -474,6 +433,43 @@ protected PasswordAuthentication getPasswordAuthentication() {
}


// 비밀번호 찾기 - GET
@RequestMapping(value = "/findPassword", method = RequestMethod.GET)
public String findPasswordGet() {
return "/user/findPassword"; // 비밀번호 찾기 페이지로 이동
}

// 비밀번호 찾기 - POST
@RequestMapping(value = "/findPassword", method = RequestMethod.POST)
public String findPasswordPost(@RequestParam("email") String email,
@RequestParam("name") String name,
Model model) {
try {
// 이메일과 이름으로 비밀번호 찾기
String password = userService.findPassword(email, name); // 비밀번호를 String으로 받음

if (password != null) {
// 비밀번호가 일치하면 얼럿창을 통해 비밀번호를 사용자에게 전달
model.addAttribute("password", password); // 비밀번호를 model에 추가
model.addAttribute("alertMessage", "입력한 정보에 해당하는 비밀번호는: " + password);
return "/user/showpassword"; // 비밀번호를 보여주는 페이지로 이동
} else {
// 비밀번호가 일치하지 않으면 오류 메시지 추가
logger.info("비밀번호 찾기 실패: 이메일 또는 이름이 일치하지 않음"); // 실패 로그
model.addAttribute("errorMessage", "이메일 또는 이름이 일치하지 않습니다.");
return "/user/findPassword"; // 비밀번호 찾기 페이지로 다시 이동
}
} catch (Exception e) {
e.printStackTrace();
logger.error("비밀번호 찾기 처리 중 오류 발생", e); // 예외 로그 추가
model.addAttribute("errorMessage", "비밀번호 찾기 처리 중 오류가 발생했습니다.");
return "/user/findPassword"; // 오류 발생 시 비밀번호 찾기 페이지로 돌아감
}
}




// 대시보드사용법 - /howtouse2 (GET)
@RequestMapping(value = "/howtouse2", method = RequestMethod.GET)
public String howtouseGET2(Model model, HttpSession session) throws Exception {
Expand Down
4 changes: 4 additions & 0 deletions stockMate/src/main/java/com/stockm8/persistence/UserDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public interface UserDAO {
int updateUserBusinessId(@Param("userId") Long userId, @Param("businessId") int businessId);


// 비밀번호 찾기 동작
public String findPassword(String email,String name) throws Exception;


// 회원정보 삭제동작
public int deleteUser (UserVO user);

Expand Down
14 changes: 13 additions & 1 deletion stockMate/src/main/java/com/stockm8/persistence/UserDAOImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,19 @@ public int updateUserBusinessId(Long userId, int businessId) {
return sqlSession.update(NAMESPACE + "updateUserBusinessId", params);
}


@Override
public String findPassword(String email, String name) throws Exception {
logger.info("findPassword 실행: 이메일 = " + email + ", 이름 = " + name);

// 이메일과 이름을 조건으로 사용자 조회
Map<String, Object> params = new HashMap<>();
params.put("email", email);
params.put("name", name);

// DB에서 사용자를 조회
return sqlSession.selectOne(NAMESPACE + "findPassword", Map.of("email", email, "name", name));
}




Expand Down
3 changes: 3 additions & 0 deletions stockMate/src/main/java/com/stockm8/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public interface UserService {
// 회원정보에서 비밀번호 수정
public void updateUserBusinessId(Long userId, int businessId) throws Exception;

// 비밀번호 찾기
public String findPassword (String email, String name) throws Exception;

// 회원정보 삭제
public int deleteUser(UserVO user) throws Exception;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ public void updateUserBusinessId(Long userId, int businessId) throws Exception {
userDAO.updateUserBusinessId(userId, businessId);
}

@Override
public String findPassword(String email, String name) throws Exception {
logger.info("findPassword 실행: 이메일 = " + email + ", 이름 = " + name);
// userDAO에서 비밀번호를 찾아 반환
return userDAO.findPassword(email, name);
}


@Override
public int deleteUser(UserVO user) throws Exception {
logger.info(" deleteuser(UserVO dvo) 실행 ");
Expand Down
8 changes: 8 additions & 0 deletions stockMate/src/main/resources/mappers/userMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@
AND business_id IS NULL
</update>

<!-- 이메일과 이름으로 비밀번호 찾기 -->
<select id="findPassword" resultType="java.lang.String">
SELECT password
FROM test_users
WHERE email = #{email} AND name = #{name}
</select>


<!-- 회원정보 삭제 -->
<delete id="deleteUser">
DELETE FROM users
Expand Down
17 changes: 11 additions & 6 deletions stockMate/src/main/webapp/WEB-INF/views/howtouse.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
text-align: center;
}
.header {
background-color: #007BFF;
color: #fff;
padding: 20px;
border-radius: 15px 15px 0 0;
margin-bottom: 20px;
.header {
position: relative;
height: 400px;
background: url(resources/css/9950253.jpg) no-repeat center center / cover;
display: flex
;
justify-content: center;
align-items: center;
text-align: center;
color: white;
}
.header h1 {
font-size: 36px;
Expand Down
Loading

0 comments on commit 5a29360

Please sign in to comment.