Skip to content

Commit

Permalink
#3 feat : 프로필 보기 -> 한 줄 후기 리스트(최신순), 별점 get
Browse files Browse the repository at this point in the history
  • Loading branch information
Suanna01 committed Mar 25, 2023
1 parent 28d6a1e commit aa1a4f4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/main/java/com/zatch/zatchserver/ResponseMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ public class ResponseMessage {
public static final String CREATED_USER = "회원 가입 성공";
public static final String UPDATE_USER = "회원 정보 수정 성공";
public static final String DELETE_USER = "회원 탈퇴 성공";
public static final String USER_TOWN_SUCCESS = "회원 동네 설정 성공";
public static final String MYPAGE_SUCCESS = "마이페이지 불러오기 성공";
public static final String USER_NICKNAME_EDIT_SUCCESS ="회원 닉네임 수정 성공";
public static final String INTERNAL_SERVER_ERROR = "서버 내부 에러";
public static final String DB_ERROR = "데이터베이스 에러";
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public ResponseEntity logout(HttpServletRequest request) throws Exception{
try {
HttpSession session = request.getSession();
session.invalidate();
return new ResponseEntity(DefaultRes.res(StatusCode.OK, ResponseMessage.LOGIN_SUCCESS, "Success Logout"), HttpStatus.OK);
return new ResponseEntity(DefaultRes.res(StatusCode.OK, ResponseMessage.USER_NICKNAME_EDIT_SUCCESS, "Success Logout"), HttpStatus.OK);
} catch (Exception e){
return new ResponseEntity(DefaultRes.res(StatusCode.INTERNAL_SERVER_ERROR, ResponseMessage.INTERNAL_SERVER_ERROR, "Error Logout"), HttpStatus.INTERNAL_SERVER_ERROR);
}
Expand All @@ -85,7 +85,7 @@ public ResponseEntity patchNickname(@PathVariable("userId") Long userId
String newNickname = pathUserNicknameReqDto.getNewNickname();
Long idOfModifiedUser = userId;
userService.modifyNickname(idOfModifiedUser, newNickname);
return new ResponseEntity(DefaultRes.res(StatusCode.OK, ResponseMessage.LOGIN_SUCCESS, new PatchUserNicknameResDto(newNickname)), HttpStatus.OK);
return new ResponseEntity(DefaultRes.res(StatusCode.OK, ResponseMessage.USER_NICKNAME_EDIT_SUCCESS, new PatchUserNicknameResDto(newNickname)), HttpStatus.OK);
} catch (Exception e){
return new ResponseEntity(DefaultRes.res(StatusCode.INTERNAL_SERVER_ERROR, ResponseMessage.INTERNAL_SERVER_ERROR, "Error Modify Nickname"), HttpStatus.INTERNAL_SERVER_ERROR);
}
Expand All @@ -96,7 +96,7 @@ public ResponseEntity patchNickname(@PathVariable("userId") Long userId
public ResponseEntity getProfile(@PathVariable("userId") Long userId) {
try {
String userNickname = userService.profile(userId);
return new ResponseEntity(DefaultRes.res(StatusCode.OK, ResponseMessage.LOGIN_SUCCESS, new GetProfileResDto(userNickname)), HttpStatus.OK);
return new ResponseEntity(DefaultRes.res(StatusCode.OK, ResponseMessage.MYPAGE_SUCCESS, new GetProfileResDto(userNickname)), HttpStatus.OK);
} catch (Exception e) {
return new ResponseEntity(DefaultRes.res(StatusCode.INTERNAL_SERVER_ERROR, ResponseMessage.INTERNAL_SERVER_ERROR, "Error Profile"), HttpStatus.INTERNAL_SERVER_ERROR);
}
Expand All @@ -108,7 +108,7 @@ public ResponseEntity postTown(@PathVariable("userId") Long userId, @RequestBody
try {
String town = postUserTownReqDTO.getTown();
String userTown = userService.town(userId, town);
return new ResponseEntity(DefaultRes.res(StatusCode.OK, ResponseMessage.LOGIN_SUCCESS, new PostUserTownReqDto(userTown)), HttpStatus.OK);
return new ResponseEntity(DefaultRes.res(StatusCode.OK, ResponseMessage.USER_TOWN_SUCCESS, new PostUserTownReqDto(userTown)), HttpStatus.OK);
} catch (Exception e) {
return new ResponseEntity(DefaultRes.res(StatusCode.INTERNAL_SERVER_ERROR, ResponseMessage.INTERNAL_SERVER_ERROR, "Error User Town"), HttpStatus.INTERNAL_SERVER_ERROR);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ public Long modifyNickname(Long userId, String newNickname) {
@Override
public List<Map<String, Object>> profile(Long userId) {
try {
String sql = "SELECT user.user_id, user.nickname, zatch.zatch_id FROM zatch.zatch LEFT JOIN zatch.user on zatch.user_id = user.user_id WHERE user.user_id = ? ORDER BY user.created_at DESC;";
String sql = "SELECT user.user_id, user.nickname, zatch.zatch_id, zatch.item_name review_context, star_rating " +
"FROM zatch.review_star LEFT JOIN zatch.zatch on review_star.send_user_id = zatch.user_id LEFT JOIN zatch.user on zatch.user_id = user.user_id " +
"WHERE user.user_id = ? ORDER BY review_star.created_at DESC;";
Object[] params = {userId};
System.out.println("User's profile SQL select");
return jdbcTemplate.queryForList(sql, params);
Expand Down

0 comments on commit aa1a4f4

Please sign in to comment.