fixed email active NULL

This commit is contained in:
ltiongku
2024-08-14 11:11:50 +08:00
parent 28a16ead4f
commit 25711506b4
4 changed files with 6 additions and 3 deletions

View File

@@ -45,7 +45,7 @@ public class GmailEmailEntity {
private OffsetDateTime dateCreated; private OffsetDateTime dateCreated;
@Column(name = "active") @Column(name = "active")
private Integer active = 1; private int active = 1;
@PrePersist @PrePersist
public void prePersist() { public void prePersist() {

View File

@@ -13,6 +13,7 @@ public class EmailMessage {
private String subject; private String subject;
private String historyId; private String historyId;
private String date; private String date;
private int active;
@JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonInclude(JsonInclude.Include.NON_EMPTY)
List<QRCodeByContentId> qrCodeByContentId; List<QRCodeByContentId> qrCodeByContentId;
@@ -29,6 +30,7 @@ public class EmailMessage {
this.subject = subject; this.subject = subject;
this.historyId = historyId; this.historyId = historyId;
this.date = date; this.date = date;
this.active = 1;
this.qrCodeByContentId = new ArrayList<>(); this.qrCodeByContentId = new ArrayList<>();
this.qrCodeByURL = new ArrayList<>(); this.qrCodeByURL = new ArrayList<>();
this.decodedContentsDetails = new ArrayList<>(); this.decodedContentsDetails = new ArrayList<>();

View File

@@ -17,12 +17,12 @@ public interface GmailEmailRespository extends JpaRepository<GmailEmailEntity, U
// Method to update active status to 0 for a specific userId // Method to update active status to 0 for a specific userId
@Modifying @Modifying
@Transactional @Transactional
@Query("UPDATE GmailEmailEntity e SET e.active = 0 WHERE e.userId = :userId") @Query("UPDATE GmailEmailEntity e SET e.active = e.active - 1 WHERE e.userId = :userId")
int deactivateEmailsByUserId(String userId); int deactivateEmailsByUserId(String userId);
// Method to update active status to 0 for a specific userId and messageId // Method to update active status to 0 for a specific userId and messageId
@Modifying @Modifying
@Transactional @Transactional
@Query("UPDATE GmailEmailEntity e SET e.active = 0 WHERE e.userId = :userId AND e.messageId = :messageId") @Query("UPDATE GmailEmailEntity e SET e.active = e.active - 1 WHERE e.userId = :userId AND e.messageId = :messageId")
int deactivateEmailByUserIdAndMessageId(String userId, String messageId); int deactivateEmailByUserIdAndMessageId(String userId, String messageId);
} }

View File

@@ -210,6 +210,7 @@ public class GmailService {
.historyId(Long.valueOf(emailMessage.getHistoryId())) .historyId(Long.valueOf(emailMessage.getHistoryId()))
.subject(emailMessage.getSubject()) .subject(emailMessage.getSubject())
.dateReceived(dateReceived) .dateReceived(dateReceived)
.active(emailMessage.getActive())
.build(); .build();
return gmailEmailRespository.save(gmailEmailEntity); return gmailEmailRespository.save(gmailEmailEntity);
} catch (DataIntegrityViolationException e) { } catch (DataIntegrityViolationException e) {