Add token field
This commit is contained in:
@@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package be.naaturel.letsmeet.models;
|
package be.naaturel.letsmeet.core.models;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package be.naaturel.letsmeet.models;
|
package be.naaturel.letsmeet.core.models;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package be.naaturel.letsmeet.models;
|
package be.naaturel.letsmeet.core.models;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package be.naaturel.letsmeet.dto.database;
|
package be.naaturel.letsmeet.dto.database;
|
||||||
|
|
||||||
import be.naaturel.letsmeet.models.EventDate;
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package be.naaturel.letsmeet.dto.database;
|
package be.naaturel.letsmeet.dto.database;
|
||||||
|
|
||||||
import be.naaturel.letsmeet.models.EventDate;
|
|
||||||
import be.naaturel.letsmeet.models.Participant;
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -16,6 +14,9 @@ public class EventEntity {
|
|||||||
@Column
|
@Column
|
||||||
public String name;
|
public String name;
|
||||||
|
|
||||||
|
@Column(unique = true)
|
||||||
|
public String token;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
@OneToMany(targetEntity=EventDateEntity.class, cascade=CascadeType.ALL, mappedBy="event")
|
@OneToMany(targetEntity=EventDateEntity.class, cascade=CascadeType.ALL, mappedBy="event")
|
||||||
public Set<EventDateEntity> dates;
|
public Set<EventDateEntity> dates;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package be.naaturel.letsmeet.dto.database.factories;
|
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.EventDateEntity;
|
||||||
import be.naaturel.letsmeet.dto.database.EventEntity;
|
import be.naaturel.letsmeet.dto.database.EventEntity;
|
||||||
import be.naaturel.letsmeet.dto.database.ParticipantEntity;
|
import be.naaturel.letsmeet.dto.database.ParticipantEntity;
|
||||||
@@ -13,6 +14,7 @@ public class DatabasePropsFactory {
|
|||||||
|
|
||||||
EventEntity entity = new EventEntity();
|
EventEntity entity = new EventEntity();
|
||||||
entity.name = name;
|
entity.name = name;
|
||||||
|
entity.token = TokenGenerator.generate();
|
||||||
entity.participants = participants;
|
entity.participants = participants;
|
||||||
entity.dates = new HashSet<>();
|
entity.dates = new HashSet<>();
|
||||||
for (ParticipantEntity pe : entity.participants) {
|
for (ParticipantEntity pe : entity.participants) {
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package be.naaturel.letsmeet.dto.httpRequest;
|
package be.naaturel.letsmeet.dto.httpRequest;
|
||||||
|
|
||||||
import be.naaturel.letsmeet.models.EventDate;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class EventDateDTO {
|
public class EventDateDTO {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package be.naaturel.letsmeet.mappers.database;
|
|||||||
import be.naaturel.letsmeet.dto.database.EventDateEntity;
|
import be.naaturel.letsmeet.dto.database.EventDateEntity;
|
||||||
import be.naaturel.letsmeet.dto.database.factories.DatabasePropsFactory;
|
import be.naaturel.letsmeet.dto.database.factories.DatabasePropsFactory;
|
||||||
import be.naaturel.letsmeet.mappers.Mapper;
|
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.Collection;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import be.naaturel.letsmeet.dto.database.EventEntity;
|
|||||||
import be.naaturel.letsmeet.dto.database.ParticipantEntity;
|
import be.naaturel.letsmeet.dto.database.ParticipantEntity;
|
||||||
import be.naaturel.letsmeet.dto.database.factories.DatabasePropsFactory;
|
import be.naaturel.letsmeet.dto.database.factories.DatabasePropsFactory;
|
||||||
import be.naaturel.letsmeet.mappers.Mapper;
|
import be.naaturel.letsmeet.mappers.Mapper;
|
||||||
import be.naaturel.letsmeet.models.Event;
|
import be.naaturel.letsmeet.core.models.Event;
|
||||||
import be.naaturel.letsmeet.models.Participant;
|
import be.naaturel.letsmeet.core.models.Participant;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import be.naaturel.letsmeet.dto.database.EventDateEntity;
|
|||||||
import be.naaturel.letsmeet.dto.database.ParticipantEntity;
|
import be.naaturel.letsmeet.dto.database.ParticipantEntity;
|
||||||
import be.naaturel.letsmeet.dto.database.factories.DatabasePropsFactory;
|
import be.naaturel.letsmeet.dto.database.factories.DatabasePropsFactory;
|
||||||
import be.naaturel.letsmeet.mappers.Mapper;
|
import be.naaturel.letsmeet.mappers.Mapper;
|
||||||
import be.naaturel.letsmeet.models.EventDate;
|
import be.naaturel.letsmeet.core.models.EventDate;
|
||||||
import be.naaturel.letsmeet.models.Participant;
|
import be.naaturel.letsmeet.core.models.Participant;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package be.naaturel.letsmeet.mappers.requests;
|
|||||||
import be.naaturel.letsmeet.dto.httpRequest.EventDTO;
|
import be.naaturel.letsmeet.dto.httpRequest.EventDTO;
|
||||||
import be.naaturel.letsmeet.dto.httpRequest.ParticipantDTO;
|
import be.naaturel.letsmeet.dto.httpRequest.ParticipantDTO;
|
||||||
import be.naaturel.letsmeet.mappers.Mapper;
|
import be.naaturel.letsmeet.mappers.Mapper;
|
||||||
import be.naaturel.letsmeet.models.Event;
|
import be.naaturel.letsmeet.core.models.Event;
|
||||||
import be.naaturel.letsmeet.models.Participant;
|
import be.naaturel.letsmeet.core.models.Participant;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
package be.naaturel.letsmeet.mappers.requests;
|
package be.naaturel.letsmeet.mappers.requests;
|
||||||
|
|
||||||
import be.naaturel.letsmeet.dto.httpRequest.EventDateDTO;
|
import be.naaturel.letsmeet.dto.httpRequest.EventDateDTO;
|
||||||
import be.naaturel.letsmeet.dto.httpRequest.ParticipantDTO;
|
|
||||||
import be.naaturel.letsmeet.mappers.Mapper;
|
import be.naaturel.letsmeet.mappers.Mapper;
|
||||||
import be.naaturel.letsmeet.models.EventDate;
|
import be.naaturel.letsmeet.core.models.EventDate;
|
||||||
import be.naaturel.letsmeet.models.Participant;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class EventDateDTOMapper implements Mapper<EventDate, EventDateDTO> {
|
public class EventDateDTOMapper implements Mapper<EventDate, EventDateDTO> {
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package be.naaturel.letsmeet.mappers.requests;
|
|||||||
import be.naaturel.letsmeet.dto.httpRequest.EventDateDTO;
|
import be.naaturel.letsmeet.dto.httpRequest.EventDateDTO;
|
||||||
import be.naaturel.letsmeet.dto.httpRequest.ParticipantDTO;
|
import be.naaturel.letsmeet.dto.httpRequest.ParticipantDTO;
|
||||||
import be.naaturel.letsmeet.mappers.Mapper;
|
import be.naaturel.letsmeet.mappers.Mapper;
|
||||||
import be.naaturel.letsmeet.models.EventDate;
|
import be.naaturel.letsmeet.core.models.EventDate;
|
||||||
import be.naaturel.letsmeet.models.Participant;
|
import be.naaturel.letsmeet.core.models.Participant;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
package be.naaturel.letsmeet.services;
|
package be.naaturel.letsmeet.services;
|
||||||
|
|
||||||
import be.naaturel.letsmeet.dto.database.EventDateEntity;
|
|
||||||
import be.naaturel.letsmeet.dto.database.EventEntity;
|
import be.naaturel.letsmeet.dto.database.EventEntity;
|
||||||
import be.naaturel.letsmeet.dto.httpRequest.EventDTO;
|
import be.naaturel.letsmeet.dto.httpRequest.EventDTO;
|
||||||
import be.naaturel.letsmeet.mappers.database.EventMapper;
|
import be.naaturel.letsmeet.mappers.database.EventMapper;
|
||||||
import be.naaturel.letsmeet.mappers.requests.EventDTOMapper;
|
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 be.naaturel.letsmeet.repositories.EventRepo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.dao.OptimisticLockingFailureException;
|
import org.springframework.dao.OptimisticLockingFailureException;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package be.naaturel.letsmeet.mappers;
|
|||||||
|
|
||||||
import be.naaturel.letsmeet.dto.database.EventDateEntity;
|
import be.naaturel.letsmeet.dto.database.EventDateEntity;
|
||||||
import be.naaturel.letsmeet.mappers.database.EventDateMapper;
|
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.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,5 @@
|
|||||||
package be.naaturel.letsmeet.mappers;
|
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;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
public class EventMapperTest {
|
public class EventMapperTest {
|
||||||
|
|||||||
Reference in New Issue
Block a user