Skip to content

Commit

Permalink
userInfoByNickname 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
HeeSung98 committed Dec 7, 2023
1 parent 30cb62e commit 0dca6fe
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
10 changes: 10 additions & 0 deletions user/src/main/java/com/weather/user/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,14 @@ public ResponseEntity<JSONObject> remove(@PathVariable String email) {

return new ResponseEntity(result, HttpStatus.OK);
}

@PostMapping("/api/userinfo")
public ResponseEntity<UserDTO> userInfoByNickname(@RequestBody UserDTO userDTO) {
log.info(" ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ userInfoByNickname controller ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ");
log.info("nickname: " + userDTO.getNickname());

UserDTO result = userService.userInfoByNickname(userDTO.getNickname());

return new ResponseEntity(result, HttpStatus.OK);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public void doFilterInternal(HttpServletRequest request, HttpServletResponse res

if(headerCheck) {
log.info("ApiCheckFilter..............................................");
log.info("ApiCheckFilter..............................................");
log.info("ApiCheckFilter..............................................");

// boolean checkHeader = checkAuthHeader(request);
//
Expand All @@ -57,7 +55,6 @@ public void doFilterInternal(HttpServletRequest request, HttpServletResponse res
// return;
}

log.info("?");
filterChain.doFilter(request, response);
}

Expand Down
4 changes: 4 additions & 0 deletions user/src/main/java/com/weather/user/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.weather.user.entity.User;
import org.springframework.web.multipart.MultipartFile;

import java.util.Optional;


public interface UserService {

Expand All @@ -29,6 +31,8 @@ public interface UserService {

void remove(String email);

public UserDTO userInfoByNickname(String nickname);

default User dtoToEntity(UserDTO userDTO) {
User user = User.builder()
.email(userDTO.getEmail())
Expand Down
18 changes: 18 additions & 0 deletions user/src/main/java/com/weather/user/service/UserServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,22 @@ public void remove(String email) {
throw new Error("이미 탈퇴 처리중인 유저입니다.");
}
}

@Override
public UserDTO userInfoByNickname(String nickname) {
Optional<User> optionalUser = userRepository.findByNickname(nickname);
log.info("optionalUser: " + optionalUser);

if(optionalUser.isEmpty()) {
throw new Error("존재하지 않는 유저입니다.");
}
User user = optionalUser.get();

if(!user.isStatus()) {
throw new Error("탈퇴 대기중인 유저입니다.");
}

UserDTO result = entityToDTO(user);
return result;
}
}
14 changes: 14 additions & 0 deletions user/src/test/java/com/weather/user/repository/UserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,18 @@ void insertUser() {
userRepository.save(user);
});
}

@Test
void insertTestUser() {
User user = User.builder()
.email("[email protected]")
.password(passwordEncoder.encode("1234"))
.name("류준열")
.nickname("류준열")
.fromSocial(false)
.status(true)
.build();

userRepository.save(user);
}
}

0 comments on commit 0dca6fe

Please sign in to comment.