Spring Boot (Maven)/2차 미니프로젝트
상품등록, 상품 찜 했을때 로그인한 userid를 DB에 저장
pjh8838
2024. 6. 20. 15:40
반응형
1. 상품 찜 했을때 로그인한 id값이 cart DB에 저장

로그인한 유저 id값 받는 스프링부트 시큐리티 로직
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
UserDTO xxx = (UserDTO)auth.getPrincipal();
dto.setUserid(xxx.getUserid());
2. 상품 찜하고 cart DB에 로그인한 id 저장 후 장바구니 페이지에서 로그인한 id와 일치하는 리스트만 불러오기
ModelMap 쓸때 - 위에 처럼 적용
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
UserDTO xxx = (UserDTO)auth.getPrincipal();
dto.setUserid(xxx.getUserid());
728x90
반응형