feat: create DTOs for requests and responses for invitations

This commit is contained in:
sBubshait 2025-07-22 09:11:45 +03:00
parent a9f5a6d5de
commit 63cff0ab24
3 changed files with 310 additions and 0 deletions

View File

@ -0,0 +1,62 @@
package online.wesal.wesal.dto;
public class ApiResponse<T> {
private boolean status;
private String message;
private T data;
public ApiResponse() {}
public ApiResponse(boolean status) {
this.status = status;
}
public ApiResponse(boolean status, String message) {
this.status = status;
this.message = message;
}
public ApiResponse(boolean status, T data) {
this.status = status;
this.data = data;
}
public ApiResponse(boolean status, String message, T data) {
this.status = status;
this.message = message;
this.data = data;
}
public static <T> ApiResponse<T> success(T data) {
return new ApiResponse<>(true, data);
}
public static <T> ApiResponse<T> error(String message) {
return new ApiResponse<>(false, message);
}
public boolean isStatus() {
return status;
}
public void setStatus(boolean status) {
this.status = status;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}

View File

@ -0,0 +1,76 @@
package online.wesal.wesal.dto;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import java.time.LocalDateTime;
public class CreateInvitationRequest {
@NotBlank
private String title;
@NotBlank
private String description;
private LocalDateTime dateTime;
private String location;
@NotNull
@Positive
private Integer maxParticipants;
@NotNull
private Long tagId;
public CreateInvitationRequest() {}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public LocalDateTime getDateTime() {
return dateTime;
}
public void setDateTime(LocalDateTime dateTime) {
this.dateTime = dateTime;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public Integer getMaxParticipants() {
return maxParticipants;
}
public void setMaxParticipants(Integer maxParticipants) {
this.maxParticipants = maxParticipants;
}
public Long getTagId() {
return tagId;
}
public void setTagId(Long tagId) {
this.tagId = tagId;
}
}

View File

@ -0,0 +1,172 @@
package online.wesal.wesal.dto;
import java.time.LocalDateTime;
public class InvitationResponse {
private Long id;
private String title;
private String description;
private LocalDateTime dateTime;
private String location;
private Integer maxParticipants;
private Integer currentAttendees;
private TagDto tag;
private UserDto creator;
private LocalDateTime createdAt;
public InvitationResponse() {}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public LocalDateTime getDateTime() {
return dateTime;
}
public void setDateTime(LocalDateTime dateTime) {
this.dateTime = dateTime;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public Integer getMaxParticipants() {
return maxParticipants;
}
public void setMaxParticipants(Integer maxParticipants) {
this.maxParticipants = maxParticipants;
}
public Integer getCurrentAttendees() {
return currentAttendees;
}
public void setCurrentAttendees(Integer currentAttendees) {
this.currentAttendees = currentAttendees;
}
public TagDto getTag() {
return tag;
}
public void setTag(TagDto tag) {
this.tag = tag;
}
public UserDto getCreator() {
return creator;
}
public void setCreator(UserDto creator) {
this.creator = creator;
}
public LocalDateTime getCreatedAt() {
return createdAt;
}
public void setCreatedAt(LocalDateTime createdAt) {
this.createdAt = createdAt;
}
public static class TagDto {
private Long id;
private String name;
private String colorHex;
private String iconName;
public TagDto() {}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getColorHex() {
return colorHex;
}
public void setColorHex(String colorHex) {
this.colorHex = colorHex;
}
public String getIconName() {
return iconName;
}
public void setIconName(String iconName) {
this.iconName = iconName;
}
}
public static class UserDto {
private Long id;
private String displayName;
private String avatar;
public UserDto() {}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
}
}