Skip to content

Commit

Permalink
remove id from userDto
Browse files Browse the repository at this point in the history
  • Loading branch information
bobivk committed Jun 23, 2024
1 parent e894eb5 commit 44983e3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static void main(String[] args) {
CommandLineRunner runner(PlaygroundRepository playgroundRepository, UserRepository userRepository) {
return args -> {
playgroundRepository.deleteAll();
User user = new User(1L, "testUser", "randomPass", "user@test.com");
User user = new User("testUser", "randomPass", "user@test.com");
userRepository.save(user);
Playground playground = new Playground();
playground.setName("Ploshtadka");
Expand Down
5 changes: 2 additions & 3 deletions backend/src/main/java/bg/kidsground/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@Data
public class User {
@Id
@Column(name = "user_id", length = 45)
@Column(name = "id", length = 45)
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

Expand All @@ -31,8 +31,7 @@ public class User {
public User() {
}

public User(Long id, String username, String password, String email) {
this.id = id;
public User(String username, String password, String email) {
this.username = username;
this.password = password;
this.email = email;
Expand Down
13 changes: 1 addition & 12 deletions backend/src/main/java/bg/kidsground/domain/dto/UserDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,16 @@

public class UserDto {

private Long id;
private String username;
private String password;
private String email;

public UserDto(Long id, String username, String password, String email) {
super();
this.id = id;
public UserDto(String username, String password, String email) {
this.username = username;
this.password = password;
this.email = email;
}

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getUsername() {
return username;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public UserDetails loadUserDetails(String username) throws UsernameNotFoundExcep

@Override
public User save(UserDto userDto) {
User user = new User(userDto.getId(),
userDto.getUsername(),
User user = new User(userDto.getUsername(),
passwordEncoder.encode(userDto.getPassword()),
userDto.getEmail());

Expand Down

0 comments on commit 44983e3

Please sign in to comment.