Skip to content

Commit

Permalink
#15 refactor: user insert 시 default image 들어가도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
chunghye98 committed Aug 3, 2023
1 parent ae4e563 commit ab11265
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ public class SignUpRequestDto {
@Size(min = 6, max = 16, message = "아이디는 최소 6자리에서 16자리까지 입력할 수 있다.")
private final String name;

public static User toEntity(SignUpRequestDto signUpRequestDto, String encodedPassword) {
public static User toEntity(SignUpRequestDto signUpRequestDto, String encodedPassword, String profileImg) {
return User.builder()
.email(signUpRequestDto.getEmail())
.password(encodedPassword)
.name(signUpRequestDto.getName())
.loginType(LoginType.LOCAL)
.profileImg(profileImg)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ public UserRepository(JdbcTemplate jdbcTemplate) {
}

public Long insert(User user) {
String sql = "INSERT INTO users (email,password,name, login_type) VALUES (:email,:password,:name,:loginType)";
String sql = "INSERT INTO users (email,password,name, login_type, profile_img) VALUES (:email,:password,:name,:loginType,:profileImg)";
KeyHolder keyHolder = new GeneratedKeyHolder();

MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("email", user.getEmail());
params.addValue("password", user.getPassword());
params.addValue("name", user.getName());
params.addValue("loginType", user.getLoginType().getType());
params.addValue("profileImg", user.getProfileImg());

jdbcTemplate.update(sql, params, keyHolder);
return keyHolder.getKey().longValue();
Expand Down

0 comments on commit ab11265

Please sign in to comment.