-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: merge DeletedOwnerModel and mappers
- Loading branch information
Fabien
committed
Oct 8, 2024
1 parent
1f76407
commit bfabe07
Showing
11 changed files
with
92 additions
and
162 deletions.
There are no files selected for viewing
28 changes: 0 additions & 28 deletions
28
...owner/src/main/java/fr/dossierfacile/api/dossierfacileapiowner/log/DeletedOwnerModel.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
55 changes: 0 additions & 55 deletions
55
...common-library/src/main/java/fr/dossierfacile/common/mapper/DeletedOwnerCommonMapper.java
This file was deleted.
Oops, something went wrong.
58 changes: 0 additions & 58 deletions
58
...ommon-library/src/main/java/fr/dossierfacile/common/mapper/DeletedTenantCommonMapper.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
36 changes: 36 additions & 0 deletions
36
...-common-library/src/main/java/fr/dossierfacile/common/mapper/log/DeletedTenantMapper.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,36 @@ | ||
package fr.dossierfacile.common.mapper.log; | ||
|
||
import com.google.common.hash.Hashing; | ||
import fr.dossierfacile.common.entity.Document; | ||
import fr.dossierfacile.common.entity.Tenant; | ||
import fr.dossierfacile.common.model.log.DeletedTenantModel; | ||
import fr.dossierfacile.common.model.apartment_sharing.DocumentModel; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
import org.mapstruct.Named; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
|
||
@Component | ||
@Mapper(componentModel = "spring") | ||
public interface DeletedTenantMapper { | ||
@Named("hashString") | ||
static String hash(String value) { | ||
if (value == null) { | ||
return ""; | ||
} | ||
return Hashing.sha256().hashString(value, StandardCharsets.UTF_8).toString(); | ||
} | ||
|
||
@Mapping(target = "hashedEmail", source = "email", qualifiedByName = "hashString") | ||
@Mapping(target = "hashedLastname", source = "lastName", qualifiedByName = "hashString") | ||
@Mapping(target = "hashedFirstname", source = "firstName", qualifiedByName = "hashString") | ||
@Mapping(target = "hashedPreferredName", source = "preferredName", qualifiedByName = "hashString") | ||
@Mapping(target = "applicationType", expression = "java((tenant.getApartmentSharing() != null )? tenant.getApartmentSharing().getApplicationType() : null)") | ||
@Mapping(target = "apartmentSharingId", expression = "java((tenant.getApartmentSharing() != null )? tenant.getApartmentSharing().getId() : null)") | ||
DeletedTenantModel toDeletedTenantModel(Tenant tenant); | ||
|
||
@Mapping(target = "name", expression = "java((document.getWatermarkFile() != null )? document.getWatermarkFile().getName() : null)") | ||
DocumentModel toDocumentModel(Document document); | ||
} |
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
34 changes: 34 additions & 0 deletions
34
...mon-library/src/main/resources/db/migration/202410070000-update-jsonprofile-owner_log.xml
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,34 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd"> | ||
|
||
<changeSet id="202410070000-01" author="fabien"> | ||
<sql> | ||
<![CDATA[ | ||
UPDATE owner_log | ||
SET json_profile = jsonb_set( | ||
jsonb_set( | ||
jsonb_set( | ||
jsonb_set( | ||
json_profile, | ||
'{hashedEmail}', | ||
COALESCE(json_profile->'hemail', 'null'::jsonb) -- Si 'hemail' est absent, on utilise 'null' | ||
), | ||
'{hashedLastname}', | ||
COALESCE(json_profile->'hlastName', 'null'::jsonb) -- Si 'hlastName' est absent | ||
), | ||
'{hashedFirstname}', | ||
COALESCE(json_profile->'hfirstName', 'null'::jsonb) -- Si 'hfirstName' est absent | ||
), | ||
'{hashedPreferredName}', | ||
COALESCE(json_profile->'hpreferredName', 'null'::jsonb) -- Si 'hpreferredName' est absent | ||
) | ||
- 'hemail' - 'hlastName' - 'hfirstName' - 'hpreferredName' | ||
WHERE log_type = 'ACCOUNT_DELETED'; | ||
]]> | ||
</sql> | ||
</changeSet> | ||
|
||
</databaseChangeLog> |