Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 76fe8e1

Browse files
Added DTO folder in the MVCPracticeAdvanced section of a small course on Java EE
1 parent c44ac98 commit 76fe8e1

File tree

5 files changed

+147
-0
lines changed

5 files changed

+147
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package AirportSimulatorTwo.DTO;
2+
3+
import jakarta.servlet.http.Part;
4+
import lombok.Builder;
5+
import lombok.Value;
6+
7+
/*
8+
Все DTO объекты должны быть имутабельны,
9+
поэтому применяем Lombok аннотацию @Value
10+
*/
11+
@Value
12+
@Builder
13+
public class CreateUserDto {
14+
15+
String name;
16+
String birthday;
17+
String email;
18+
Part image;
19+
String password;
20+
String role;
21+
String gender;
22+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package AirportSimulatorTwo.DTO;
2+
3+
import java.util.Objects;
4+
5+
public class FlightDto {
6+
private final Long id;
7+
private final String description;
8+
9+
public FlightDto(Long id, String description) {
10+
this.id = id;
11+
this.description = description;
12+
}
13+
14+
public Long getId() {
15+
return id;
16+
}
17+
18+
public String getDescription() {
19+
return description;
20+
}
21+
22+
@Override
23+
public boolean equals(Object o) {
24+
if (this == o) return true;
25+
if (o == null || getClass() != o.getClass()) return false;
26+
FlightDto flightDto = (FlightDto) o;
27+
return Objects.equals(id, flightDto.id) &&
28+
Objects.equals(description, flightDto.description);
29+
}
30+
31+
@Override
32+
public int hashCode() {
33+
return Objects.hash(id, description);
34+
}
35+
36+
@Override
37+
public String toString() {
38+
return "FlightDto{" +
39+
"id=" + id +
40+
", description='" + description + '\'' +
41+
'}';
42+
}
43+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package AirportSimulatorTwo.DTO;
2+
3+
import AirportSimulatorTwo.Entity.EntityEnum.Gender;
4+
import AirportSimulatorTwo.Entity.EntityEnum.Role;
5+
import lombok.Builder;
6+
import lombok.Value;
7+
8+
import java.time.LocalDate;
9+
10+
@Value
11+
@Builder
12+
public class ReadUserDto {
13+
Integer id;
14+
String name;
15+
LocalDate birthday;
16+
String email;
17+
String image;
18+
Role role;
19+
Gender gender;
20+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package AirportSimulatorTwo.DTO;
2+
3+
import java.util.Objects;
4+
5+
public class TicketDto {
6+
private final Long id;
7+
private final Long flight_id;
8+
private final String seat_no;
9+
10+
public TicketDto(Long id, Long flight_id, String seat_no) {
11+
this.id = id;
12+
this.flight_id = flight_id;
13+
this.seat_no = seat_no;
14+
}
15+
16+
public Long getId() {
17+
return id;
18+
}
19+
20+
public Long getFlight_id() {
21+
return flight_id;
22+
}
23+
24+
public String getSeat_no() {
25+
return seat_no;
26+
}
27+
28+
@Override
29+
public boolean equals(Object o) {
30+
if (this == o) return true;
31+
if (o == null || getClass() != o.getClass()) return false;
32+
TicketDto ticketDto = (TicketDto) o;
33+
return Objects.equals(id, ticketDto.id) &&
34+
Objects.equals(flight_id, ticketDto.flight_id) &&
35+
Objects.equals(seat_no, ticketDto.seat_no);
36+
}
37+
38+
@Override
39+
public int hashCode() {
40+
return Objects.hash(id, flight_id, seat_no);
41+
}
42+
43+
@Override
44+
public String toString() {
45+
return "TicketDto{" +
46+
"id=" + id +
47+
", flight_id=" + flight_id +
48+
", seat_no='" + seat_no + '\'' +
49+
'}';
50+
}
51+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package AirportSimulatorTwo.DTO;
2+
/* Применим Lombok чтобы не писать рутинный код */
3+
import lombok.Builder;
4+
import lombok.Value;
5+
6+
@Value
7+
@Builder
8+
public class UserDto {
9+
Long id;
10+
String mail;
11+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /