Creates dtos
This commit is contained in:
@@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.szymonsawicki.reactivetimesheetapp.domain.team.dto.GetTeamDto;
|
||||
import net.szymonsawicki.reactivetimesheetapp.domain.user.User;
|
||||
|
||||
import java.util.List;
|
||||
@@ -13,8 +14,17 @@ import java.util.List;
|
||||
@Builder
|
||||
@EqualsAndHashCode
|
||||
public class Team {
|
||||
|
||||
String id;
|
||||
String name;
|
||||
User lead;
|
||||
List<User> mambers;
|
||||
List<User> members;
|
||||
|
||||
public GetTeamDto toGetTeamDto() {
|
||||
return new GetTeamDto(
|
||||
id,
|
||||
name,
|
||||
lead,
|
||||
members);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package net.szymonsawicki.reactivetimesheetapp.domain.team.dto;
|
||||
|
||||
import net.szymonsawicki.reactivetimesheetapp.domain.team.Team;
|
||||
import net.szymonsawicki.reactivetimesheetapp.domain.user.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record CreateTeamDto(String name, User lead, List<User> members) {
|
||||
public Team toTeam() {
|
||||
return Team.builder()
|
||||
.name(name)
|
||||
.lead(lead)
|
||||
.members(members)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.szymonsawicki.reactivetimesheetapp.domain.team.dto;
|
||||
|
||||
import net.szymonsawicki.reactivetimesheetapp.domain.team.Team;
|
||||
import net.szymonsawicki.reactivetimesheetapp.domain.user.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record GetTeamDto(String id, String name, User lead, List<User> members) {
|
||||
public Team toTeam() {
|
||||
return Team.builder()
|
||||
.id(id)
|
||||
.name(name)
|
||||
.lead(lead)
|
||||
.members(members)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.szymonsawicki.reactivetimesheetapp.domain.time_entry.dto.GetTimeEntryDto;
|
||||
import net.szymonsawicki.reactivetimesheetapp.domain.time_entry.type.Category;
|
||||
|
||||
import java.time.LocalDate;
|
||||
@@ -14,9 +15,21 @@ import java.time.LocalTime;
|
||||
@Builder
|
||||
@EqualsAndHashCode
|
||||
public class TimeEntry {
|
||||
|
||||
String id;
|
||||
LocalDate date;
|
||||
LocalTime timeFrom;
|
||||
LocalTime timeTo;
|
||||
Category category;
|
||||
String description;
|
||||
|
||||
GetTimeEntryDto toGetTimeEntryDto() {
|
||||
return new GetTimeEntryDto(
|
||||
id,
|
||||
date,
|
||||
timeFrom,
|
||||
timeTo,
|
||||
category,
|
||||
description);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package net.szymonsawicki.reactivetimesheetapp.domain.time_entry.dto;
|
||||
|
||||
import net.szymonsawicki.reactivetimesheetapp.domain.time_entry.TimeEntry;
|
||||
import net.szymonsawicki.reactivetimesheetapp.domain.time_entry.type.Category;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
|
||||
public record CreateTimeEntryDto(LocalDate date, LocalTime timeFrom, LocalTime timeTo, Category category, String description) {
|
||||
TimeEntry toTimeEntry() {
|
||||
return TimeEntry.builder()
|
||||
.date(date)
|
||||
.timeFrom(timeFrom)
|
||||
.timeTo(timeTo)
|
||||
.category(category)
|
||||
.description(description)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package net.szymonsawicki.reactivetimesheetapp.domain.time_entry.dto;
|
||||
|
||||
import net.szymonsawicki.reactivetimesheetapp.domain.time_entry.TimeEntry;
|
||||
import net.szymonsawicki.reactivetimesheetapp.domain.time_entry.type.Category;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
|
||||
public record GetTimeEntryDto(String id, LocalDate date, LocalTime timeFrom, LocalTime timeTo, Category category, String description) {
|
||||
TimeEntry toTimeEntry() {
|
||||
return TimeEntry.builder()
|
||||
.id(id)
|
||||
.date(date)
|
||||
.timeFrom(timeFrom)
|
||||
.timeTo(timeTo)
|
||||
.category(category)
|
||||
.description(description)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.szymonsawicki.reactivetimesheetapp.domain.user.dto.GetUserDto;
|
||||
import net.szymonsawicki.reactivetimesheetapp.domain.user.type.Role;
|
||||
|
||||
@AllArgsConstructor
|
||||
@@ -11,8 +12,19 @@ import net.szymonsawicki.reactivetimesheetapp.domain.user.type.Role;
|
||||
@Builder
|
||||
@EqualsAndHashCode
|
||||
public class User {
|
||||
|
||||
String id;
|
||||
String username;
|
||||
String password;
|
||||
Role role;
|
||||
String teamId;
|
||||
|
||||
GetUserDto toGetUserDto() {
|
||||
return new GetUserDto(
|
||||
id,
|
||||
username,
|
||||
password,
|
||||
role,
|
||||
teamId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package net.szymonsawicki.reactivetimesheetapp.domain.user.dto;
|
||||
|
||||
import net.szymonsawicki.reactivetimesheetapp.domain.user.User;
|
||||
import net.szymonsawicki.reactivetimesheetapp.domain.user.type.Role;
|
||||
|
||||
public record CreateUserDto(String username, String password, String passwordConfirmation, Role role, String teamId) {
|
||||
User toUser() {
|
||||
return User.builder()
|
||||
.username(username)
|
||||
.password(password)
|
||||
.role(role)
|
||||
.teamId(teamId)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package net.szymonsawicki.reactivetimesheetapp.domain.user.dto;
|
||||
|
||||
import net.szymonsawicki.reactivetimesheetapp.domain.user.User;
|
||||
import net.szymonsawicki.reactivetimesheetapp.domain.user.type.Role;
|
||||
|
||||
public record GetUserDto(String id, String username, String password, Role role, String teamId) {
|
||||
User toUser() {
|
||||
return User.builder()
|
||||
.id(id)
|
||||
.username(username)
|
||||
.password(password)
|
||||
.role(role)
|
||||
.teamId(teamId)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user