8
8
import it .gov .pagopa .message .core .model .CitizenConsent ;
9
9
import it .gov .pagopa .message .core .model .mapper .CitizenConsentMapperDTOToObject ;
10
10
import it .gov .pagopa .message .core .repository .CitizenRepository ;
11
- import lombok .extern .slf4j .Slf4j ;
12
11
import org .springframework .stereotype .Service ;
13
12
14
13
import java .time .LocalDateTime ;
15
14
15
+ import static it .gov .pagopa .common .utils .Utils .logInfo ;
16
+
16
17
17
18
@ Service
18
- @ Slf4j
19
19
public class CitizenServiceImpl implements CitizenService {
20
20
21
21
private final CitizenRepository citizenRepository ;
@@ -31,47 +31,47 @@ public CitizenServiceImpl(CitizenRepository citizenRepository, CitizenConsentMap
31
31
32
32
@ Override
33
33
public CitizenConsentDTO createCitizenConsent (CitizenConsentDTO citizenConsentDTO ) {
34
- log . info ("[EMD][CREATE-CITIZEN-CONSENT] Received message: {}" , citizenConsentDTO .toString ());
34
+ logInfo ("[EMD][CREATE-CITIZEN-CONSENT] Received message: %s" . formatted ( citizenConsentDTO .toString () ));
35
35
CitizenConsent citizenConsent = mapperToObject .citizenConsentDTOMapper (citizenConsentDTO );
36
36
String hashedFiscalCode = Utils .createSHA256 (citizenConsent .getHashedFiscalCode ());
37
37
citizenConsent .setHashedFiscalCode (hashedFiscalCode );
38
38
citizenConsent .setCreationDate (LocalDateTime .now ());
39
39
citizenConsent .setLastUpdateDate (LocalDateTime .now ());
40
40
citizenConsent = citizenRepository .save (citizenConsent );
41
- log . info ("[EMD][CREATE-CITIZEN-CONSENT] Created" );
41
+ logInfo ("[EMD][CREATE-CITIZEN-CONSENT] Created" );
42
42
return mapperToDTO .citizenConsentMapper (citizenConsent );
43
43
}
44
44
45
45
46
46
@ Override
47
47
public CitizenConsentDTO deleteCitizenConsent (String fiscalCode , String channelId ) {
48
- log . info ("[EMD][DELETE-CITIZEN-CONSENT] Received hashedFiscalCode: {} and channelId {} " , fiscalCode , channelId );
48
+ logInfo ("[EMD][DELETE-CITIZEN-CONSENT] Received hashedFiscalCode: %s and channelId %s " . formatted ( fiscalCode , channelId ) );
49
49
String hashedFiscalCode = Utils .createSHA256 (fiscalCode );
50
50
CitizenConsent citizenConsent = citizenRepository .findByHashedFiscalCodeAndChannelId (hashedFiscalCode ,channelId );
51
51
if (citizenConsent == null ) {
52
- log . error ("[EMD][DELETE-CITIZEN-CONSENT] User not onboarded" );
52
+ logInfo ("[EMD][DELETE-CITIZEN-CONSENT] User not onboarded" );
53
53
throw new UserNotOnboardedException ("User not onboarded" , true , null );
54
54
}
55
55
citizenConsent .setChannelState (false );
56
56
citizenConsent .setLastUpdateDate (LocalDateTime .now ());
57
57
citizenRepository .save (citizenConsent );
58
- log . info ("[EMD][DELETE-CITIZEN-CONSENT] Deleted" );
58
+ logInfo ("[EMD][DELETE-CITIZEN-CONSENT] Deleted" );
59
59
return mapperToDTO .citizenConsentMapper (citizenConsent );
60
60
}
61
61
62
62
@ Override
63
63
public CitizenConsentDTO updateCitizenConsent (String fiscalCode , String channelId ) {
64
- log . info ("[EMD][UPDATE-CITIZEN-CONSENT] Received fiscalCode: {} and channelId {} " , fiscalCode , channelId );
64
+ logInfo ("[EMD][UPDATE-CITIZEN-CONSENT] Received fiscalCode: %s and channelId %s " . formatted ( fiscalCode , channelId ) );
65
65
fiscalCode = Utils .createSHA256 (fiscalCode );
66
66
CitizenConsent citizenConsent = citizenRepository .findByHashedFiscalCodeAndChannelId (fiscalCode ,channelId );
67
67
if (citizenConsent == null ) {
68
- log . error ("[EMD][UPDATE-CITIZEN-CONSENT] User not onboarded" );
68
+ logInfo ("[EMD][UPDATE-CITIZEN-CONSENT] User not onboarded" );
69
69
throw new UserNotOnboardedException ("User not onboarded" , true , null );
70
70
}
71
71
citizenConsent .setChannelState (true );
72
72
citizenConsent .setLastUpdateDate (LocalDateTime .now ());
73
73
citizenRepository .save (citizenConsent );
74
- log . info ("[EMD][UPDATE-CITIZEN-CONSENT] Updated" );
74
+ logInfo ("[EMD][UPDATE-CITIZEN-CONSENT] Updated" );
75
75
return mapperToDTO .citizenConsentMapper (citizenConsent );
76
76
}
77
77
0 commit comments