Add token field

This commit is contained in:
Laurent
2025-03-16 11:18:46 +01:00
parent 7fde0c79d2
commit 2f15cc9749
17 changed files with 34 additions and 34 deletions

View File

@@ -0,0 +1,14 @@
package be.naaturel.letsmeet.core.helpers;
import java.util.UUID;
public class TokenGenerator {
private static int length = 6;
public static String generate(){
return UUID.randomUUID().toString().replace("-", "").substring(0, length);
}
}

View File

@@ -1,4 +1,4 @@
package be.naaturel.letsmeet.models;
package be.naaturel.letsmeet.core.models;
import java.util.*;

View File

@@ -1,4 +1,4 @@
package be.naaturel.letsmeet.models;
package be.naaturel.letsmeet.core.models;
import java.util.Objects;

View File

@@ -1,4 +1,4 @@
package be.naaturel.letsmeet.models;
package be.naaturel.letsmeet.core.models;
import java.util.HashSet;
import java.util.Objects;

View File

@@ -1,6 +1,5 @@
package be.naaturel.letsmeet.dto.database;
import be.naaturel.letsmeet.models.EventDate;
import jakarta.persistence.*;
import java.util.Objects;

View File

@@ -1,7 +1,5 @@
package be.naaturel.letsmeet.dto.database;
import be.naaturel.letsmeet.models.EventDate;
import be.naaturel.letsmeet.models.Participant;
import jakarta.persistence.*;
import java.util.*;
@@ -16,6 +14,9 @@ public class EventEntity {
@Column
public String name;
@Column(unique = true)
public String token;
@Column
@OneToMany(targetEntity=EventDateEntity.class, cascade=CascadeType.ALL, mappedBy="event")
public Set<EventDateEntity> dates;

View File

@@ -1,5 +1,6 @@
package be.naaturel.letsmeet.dto.database.factories;
import be.naaturel.letsmeet.core.helpers.TokenGenerator;
import be.naaturel.letsmeet.dto.database.EventDateEntity;
import be.naaturel.letsmeet.dto.database.EventEntity;
import be.naaturel.letsmeet.dto.database.ParticipantEntity;
@@ -13,6 +14,7 @@ public class DatabasePropsFactory {
EventEntity entity = new EventEntity();
entity.name = name;
entity.token = TokenGenerator.generate();
entity.participants = participants;
entity.dates = new HashSet<>();
for (ParticipantEntity pe : entity.participants) {

View File

@@ -1,7 +1,5 @@
package be.naaturel.letsmeet.dto.httpRequest;
import be.naaturel.letsmeet.models.EventDate;
import java.util.Objects;
public class EventDateDTO {

View File

@@ -3,7 +3,7 @@ package be.naaturel.letsmeet.mappers.database;
import be.naaturel.letsmeet.dto.database.EventDateEntity;
import be.naaturel.letsmeet.dto.database.factories.DatabasePropsFactory;
import be.naaturel.letsmeet.mappers.Mapper;
import be.naaturel.letsmeet.models.EventDate;
import be.naaturel.letsmeet.core.models.EventDate;
import java.util.Collection;
import java.util.function.Supplier;

View File

@@ -4,8 +4,8 @@ import be.naaturel.letsmeet.dto.database.EventEntity;
import be.naaturel.letsmeet.dto.database.ParticipantEntity;
import be.naaturel.letsmeet.dto.database.factories.DatabasePropsFactory;
import be.naaturel.letsmeet.mappers.Mapper;
import be.naaturel.letsmeet.models.Event;
import be.naaturel.letsmeet.models.Participant;
import be.naaturel.letsmeet.core.models.Event;
import be.naaturel.letsmeet.core.models.Participant;
import java.util.*;
import java.util.function.Supplier;

View File

@@ -4,8 +4,8 @@ import be.naaturel.letsmeet.dto.database.EventDateEntity;
import be.naaturel.letsmeet.dto.database.ParticipantEntity;
import be.naaturel.letsmeet.dto.database.factories.DatabasePropsFactory;
import be.naaturel.letsmeet.mappers.Mapper;
import be.naaturel.letsmeet.models.EventDate;
import be.naaturel.letsmeet.models.Participant;
import be.naaturel.letsmeet.core.models.EventDate;
import be.naaturel.letsmeet.core.models.Participant;
import java.util.Collection;
import java.util.HashSet;

View File

@@ -3,8 +3,8 @@ package be.naaturel.letsmeet.mappers.requests;
import be.naaturel.letsmeet.dto.httpRequest.EventDTO;
import be.naaturel.letsmeet.dto.httpRequest.ParticipantDTO;
import be.naaturel.letsmeet.mappers.Mapper;
import be.naaturel.letsmeet.models.Event;
import be.naaturel.letsmeet.models.Participant;
import be.naaturel.letsmeet.core.models.Event;
import be.naaturel.letsmeet.core.models.Participant;
import java.util.Collection;
import java.util.HashSet;

View File

@@ -1,13 +1,10 @@
package be.naaturel.letsmeet.mappers.requests;
import be.naaturel.letsmeet.dto.httpRequest.EventDateDTO;
import be.naaturel.letsmeet.dto.httpRequest.ParticipantDTO;
import be.naaturel.letsmeet.mappers.Mapper;
import be.naaturel.letsmeet.models.EventDate;
import be.naaturel.letsmeet.models.Participant;
import be.naaturel.letsmeet.core.models.EventDate;
import java.util.Collection;
import java.util.HashSet;
import java.util.function.Supplier;
public class EventDateDTOMapper implements Mapper<EventDate, EventDateDTO> {

View File

@@ -3,8 +3,8 @@ package be.naaturel.letsmeet.mappers.requests;
import be.naaturel.letsmeet.dto.httpRequest.EventDateDTO;
import be.naaturel.letsmeet.dto.httpRequest.ParticipantDTO;
import be.naaturel.letsmeet.mappers.Mapper;
import be.naaturel.letsmeet.models.EventDate;
import be.naaturel.letsmeet.models.Participant;
import be.naaturel.letsmeet.core.models.EventDate;
import be.naaturel.letsmeet.core.models.Participant;
import java.util.Collection;
import java.util.HashSet;

View File

@@ -1,11 +1,10 @@
package be.naaturel.letsmeet.services;
import be.naaturel.letsmeet.dto.database.EventDateEntity;
import be.naaturel.letsmeet.dto.database.EventEntity;
import be.naaturel.letsmeet.dto.httpRequest.EventDTO;
import be.naaturel.letsmeet.mappers.database.EventMapper;
import be.naaturel.letsmeet.mappers.requests.EventDTOMapper;
import be.naaturel.letsmeet.models.Event;
import be.naaturel.letsmeet.core.models.Event;
import be.naaturel.letsmeet.repositories.EventRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.OptimisticLockingFailureException;

View File

@@ -2,7 +2,7 @@ package be.naaturel.letsmeet.mappers;
import be.naaturel.letsmeet.dto.database.EventDateEntity;
import be.naaturel.letsmeet.mappers.database.EventDateMapper;
import be.naaturel.letsmeet.models.EventDate;
import be.naaturel.letsmeet.core.models.EventDate;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

View File

@@ -1,15 +1,5 @@
package be.naaturel.letsmeet.mappers;
import be.naaturel.letsmeet.dto.database.EventDateEntity;
import be.naaturel.letsmeet.dto.database.EventEntity;
import be.naaturel.letsmeet.mappers.database.EventMapper;
import be.naaturel.letsmeet.models.EventDate;
import be.naaturel.letsmeet.models.Event;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.util.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class EventMapperTest {