-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from AhmedYahia74/get-and-update-user-profile
Get and update user profile
- Loading branch information
Showing
17 changed files
with
329 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/java/com/activecourses/upwork/dto/user/UserProfileDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.activecourses.upwork.dto.user; | ||
|
||
import jakarta.persistence.Id; | ||
import jakarta.validation.constraints.NotBlank; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
import java.math.BigDecimal; | ||
|
||
@Data | ||
@Builder | ||
public class UserProfileDto { | ||
@Id | ||
private int id; | ||
@NotBlank(message = "First Name is required") | ||
private String firstName; | ||
@NotBlank(message = "Last Name is required") | ||
private String lastName; | ||
|
||
private String title; | ||
|
||
private String description; | ||
|
||
private BigDecimal hourlyRate; | ||
|
||
private String location; | ||
} |
2 changes: 2 additions & 0 deletions
2
src/main/java/com/activecourses/upwork/dto/user/UserResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/com/activecourses/upwork/mapper/user/UserProfileDtoMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.activecourses.upwork.mapper.user; | ||
|
||
import com.activecourses.upwork.dto.user.UserProfileDto; | ||
import com.activecourses.upwork.mapper.Mapper; | ||
import com.activecourses.upwork.model.User; | ||
import lombok.AllArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@AllArgsConstructor | ||
public class UserProfileDtoMapper implements Mapper<User, UserProfileDto> { | ||
@Override | ||
public UserProfileDto mapTo(User user) { | ||
return UserProfileDto.builder() | ||
.id(user.getId()) | ||
.title(user.getUserProfile().getTitle()) | ||
.description(user.getUserProfile().getDescription()) | ||
.hourlyRate(user.getUserProfile().getHourlyRate()) | ||
.location(user.getUserProfile().getLocation()) | ||
.firstName(user.getFirstName()) | ||
.lastName(user.getLastName()) | ||
.build(); | ||
} | ||
|
||
@Override | ||
public User mapFrom(UserProfileDto userProfileDto) { | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/com/activecourses/upwork/model/UserProfile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.activecourses.upwork.model; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
import java.math.BigDecimal; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Entity | ||
@Builder | ||
@EntityListeners(AuditingEntityListener.class) | ||
@Table(name = "user_profiles") | ||
public class UserProfile { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Integer profileId; | ||
|
||
private String title; | ||
|
||
private String description; | ||
|
||
@Column(precision = 19, scale = 2) // Example precision and scale | ||
private BigDecimal hourlyRate; | ||
|
||
|
||
private String location; | ||
|
||
@OneToOne(cascade = CascadeType.ALL) | ||
@JoinColumn(name = "user_id", unique = true) | ||
private User user; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.