-
Notifications
You must be signed in to change notification settings - Fork 0
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 #146 from Tech-Harbor/Bezsmertnyi
Bezsmertnyi: mapstruct
- Loading branch information
Showing
46 changed files
with
176 additions
and
724 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 was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
src/main/java/com/example/backend/utils/general/BaseMapper.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,58 @@ | ||
package com.example.backend.utils.general; | ||
|
||
import com.example.backend.utils.enums.RegisterAuthStatus; | ||
import com.example.backend.utils.enums.Role; | ||
import com.example.backend.web.Advertisement.store.AdvertisementEntity; | ||
import com.example.backend.web.Advertisement.store.dto.AdvertisementDTO; | ||
import com.example.backend.web.Advertisement.store.mapper.AdvertisementMapper; | ||
import com.example.backend.web.Category.store.CategoryEntity; | ||
import com.example.backend.web.File.ImageRepository; | ||
import com.example.backend.web.File.store.ImageEntity; | ||
import lombok.RequiredArgsConstructor; | ||
import org.mapstruct.Named; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
@Named("BaseMapper") | ||
@Component | ||
@RequiredArgsConstructor | ||
public class BaseMapper { | ||
|
||
private final AdvertisementMapper advertisementMapper; | ||
private final ImageRepository imageRepository; | ||
|
||
@Named("getAllAdvertisements") | ||
public List<AdvertisementDTO> getAllAdvertisements(final List<AdvertisementEntity> advertisement) { | ||
return Collections.singletonList(advertisementMapper | ||
.advertisementMapperDTO((AdvertisementEntity) advertisement) | ||
); | ||
} | ||
|
||
@Named("getAllImages") | ||
public List<ImageEntity> getAllImages(final List<ImageEntity> image) { | ||
return imageRepository.findAll(); | ||
} | ||
|
||
@Named("getCategoryName") | ||
public String getCategoryName(final CategoryEntity category) { | ||
return category.getName(); | ||
} | ||
|
||
@Named("getImageUrl") | ||
public String getImageUrl(final ImageEntity image) { | ||
return image.getImageUrl(); | ||
} | ||
|
||
@Named("getEnumRole") | ||
public Set<Role> getEnumRole(final Set<Role> roles) { | ||
return roles; | ||
} | ||
|
||
@Named("getEnumRegisterAuthStatus") | ||
public RegisterAuthStatus getEnumRegisterAuthStatus(final RegisterAuthStatus registerAuthStatus) { | ||
return registerAuthStatus; | ||
} | ||
} |
37 changes: 0 additions & 37 deletions
37
src/main/java/com/example/backend/utils/general/WebIsNullFactory.java
This file was deleted.
Oops, something went wrong.
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
25 changes: 0 additions & 25 deletions
25
.../java/com/example/backend/web/Advertisement/store/factory/AdvertisementCreateFactory.java
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
src/main/java/com/example/backend/web/Advertisement/store/factory/AdvertisementFactory.java
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
.../java/com/example/backend/web/Advertisement/store/factory/AdvertisementUpdateFactory.java
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
src/main/java/com/example/backend/web/Advertisement/store/mapper/AdvertisementMapper.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,21 @@ | ||
package com.example.backend.web.Advertisement.store.mapper; | ||
|
||
import com.example.backend.web.Advertisement.store.AdvertisementEntity; | ||
import com.example.backend.web.Advertisement.store.dto.AdvertisementCreateDTO; | ||
import com.example.backend.web.Advertisement.store.dto.AdvertisementDTO; | ||
import com.example.backend.web.Advertisement.store.dto.AdvertisementUpdateDTO; | ||
import com.example.backend.utils.general.BaseMapper; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
|
||
@Mapper(componentModel = "spring", uses = {BaseMapper.class}) | ||
public interface AdvertisementMapper { | ||
@Mapping(target = "images", qualifiedByName = {"BaseMapper", "getAllImages"}) | ||
@Mapping(target = "category", qualifiedByName = {"BaseMapper", "getCategoryName"}) | ||
AdvertisementCreateDTO advertisementMapperCreateDTO(AdvertisementEntity entity); | ||
@Mapping(target = "category", qualifiedByName = {"BaseMapper", "getCategoryName"}) | ||
AdvertisementUpdateDTO advertisementMapperUpdateDTO(AdvertisementEntity entity); | ||
@Mapping(target = "images", qualifiedByName = {"BaseMapper", "getAllImages"}) | ||
@Mapping(target = "category", qualifiedByName = {"BaseMapper", "getCategoryName"}) | ||
AdvertisementDTO advertisementMapperDTO(AdvertisementEntity entity); | ||
} |
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
18 changes: 0 additions & 18 deletions
18
src/main/java/com/example/backend/web/Category/store/factory/CategoryCreateFactory.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.