-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User service #38
Merged
Merged
User service #38
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
707b428
Add mappers to UserResponse and PageResponse
moustaphastar 4f165ed
Add service methods, pass granted authorities to User object.
moustaphastar 25a2358
Add new derived queries.
moustaphastar decd56c
Add UserResponse class.
moustaphastar 5f8cf74
Add request/response classes for user image actions.
moustaphastar 1f28905
Add list, user and delete endpoints with access rule.
moustaphastar d5548a0
Add User page
moustaphastar 778f36f
Add user service file for api requests
moustaphastar e04d4ed
Add user details view modal
moustaphastar b134f45
Add route link for user page.
moustaphastar ad32c63
Add route link for user page.
moustaphastar File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
49 changes: 48 additions & 1 deletion
49
petshop-be/domain/src/main/java/com/turkninja/petshop/mapper/UserMapper.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 |
---|---|---|
@@ -1,14 +1,61 @@ | ||
package com.turkninja.petshop.mapper; | ||
|
||
import com.turkninja.petshop.api.request.user.UserSignupRequest; | ||
import com.turkninja.petshop.api.response.common.PageResponse; | ||
import com.turkninja.petshop.api.response.user.UserResponse; | ||
import com.turkninja.petshop.entity.user.UserEntity; | ||
import com.turkninja.petshop.value.FullName; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
import org.mapstruct.MappingTarget; | ||
import org.springframework.data.domain.Page; | ||
|
||
@Mapper(componentModel = "spring") | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Mapper(componentModel = "spring", imports = FullName.class) | ||
public interface UserMapper { | ||
|
||
@Mapping(target = "active", constant = "true") | ||
UserEntity userSignupRequestToUserEntity(UserSignupRequest userSignupRequest); | ||
|
||
@Mapping(target = "fullName", | ||
expression = "java(entity.getFullName().getName()" + | ||
" + \" \" + entity.getFullName().getLastName())") | ||
@Mapping(target = "name", | ||
expression = "java(entity.getFullName().getName())") | ||
@Mapping(target = "lastName", | ||
expression = "java(entity.getFullName().getLastName())") | ||
@Mapping(target = "phone", | ||
expression = "java(entity.getPhone().getMobilePhone())") | ||
@Mapping(target = "city", | ||
expression = "java(entity.getAddress().getCity())") | ||
@Mapping(target = "country", | ||
expression = "java(entity.getAddress().getCountry())") | ||
@Mapping(target = "district", | ||
expression = "java(entity.getAddress().getDistrict())") | ||
@Mapping(target = "externalDoorNo", | ||
expression = "java(entity.getAddress().getExternalDoorNo())") | ||
@Mapping(target = "internalDoorNo", | ||
expression = "java(entity.getAddress().getInternalDoorNo())") | ||
@Mapping(target = "street", | ||
expression = "java(entity.getAddress().getStreet())") | ||
@Mapping(target = "town", | ||
expression = "java(entity.getAddress().getTown())") | ||
@Mapping(target = "lastLoggedIn", | ||
dateFormat = "dd-MM-yyyy HH:mm:ss") | ||
@Mapping(target = "createdAt", | ||
dateFormat = "dd-MM-yyyy HH:mm:ss") | ||
@Mapping(target = "revisedAt", | ||
dateFormat = "dd-MM-yyyy HH:mm:ss") | ||
UserResponse entityToUserResponse(UserEntity entity); | ||
|
||
default PageResponse<UserResponse> pageEntitiesToPageResponse(Page<UserEntity> pageOfUserEntity){ | ||
PageResponse<UserResponse> response = new PageResponse<UserResponse>(); | ||
List<UserEntity> content = pageOfUserEntity.getContent(); | ||
response.setContent(content.stream().map(this::entityToUserResponse).collect(Collectors.toList())); | ||
response.setTotalPages(pageOfUserEntity.getTotalPages()); | ||
response.setTotalElements(pageOfUserEntity.getTotalElements()); | ||
return response; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need target attribute for entity properties that has same name with response property