docs(report): fill REPORT.md for lab4 grade 3
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package ru.mtusi.messenger.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public record Attachment(
|
||||
@JsonProperty("id") UUID id,
|
||||
@JsonProperty("chat_id") UUID chatId,
|
||||
@JsonProperty("owner_id") UUID ownerId,
|
||||
@JsonProperty("filename") String filename,
|
||||
@JsonProperty("content_type") String contentType,
|
||||
@JsonProperty("size_bytes") long sizeBytes,
|
||||
@JsonProperty("sha256") String sha256,
|
||||
@JsonProperty("status") String status,
|
||||
@JsonProperty("variants") List<Object> variants,
|
||||
@JsonProperty("error_code") String errorCode,
|
||||
@JsonProperty("created_at") OffsetDateTime createdAt,
|
||||
@JsonProperty("updated_at") OffsetDateTime updatedAt // <-- ДОБАВЛЕНО
|
||||
) {}
|
||||
@@ -0,0 +1,13 @@
|
||||
package ru.mtusi.messenger.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public record Chat(
|
||||
@JsonProperty("id") UUID id,
|
||||
@JsonProperty("title") String title,
|
||||
@JsonProperty("member_ids") List<UUID> memberIds,
|
||||
@JsonProperty("created_at") OffsetDateTime createdAt
|
||||
) {}
|
||||
@@ -0,0 +1,9 @@
|
||||
package ru.mtusi.messenger.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.util.List;
|
||||
|
||||
public record ChatPage(
|
||||
@JsonProperty("items") List<Chat> items,
|
||||
@JsonProperty("next_cursor") String nextCursor
|
||||
) {}
|
||||
@@ -0,0 +1,21 @@
|
||||
package ru.mtusi.messenger.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public record CreateChat(
|
||||
@JsonProperty("title")
|
||||
@NotBlank(message = "title must not be blank")
|
||||
@Size(min = 1, max = 100, message = "title must be 1..100 characters")
|
||||
String title,
|
||||
|
||||
@JsonProperty("member_ids")
|
||||
@NotEmpty(message = "member_ids must not be empty")
|
||||
@Size(min = 1, max = 100, message = "member_ids must contain 1..100 items")
|
||||
List<UUID> memberIds
|
||||
) {}
|
||||
@@ -0,0 +1,23 @@
|
||||
package ru.mtusi.messenger.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public record CreateMessage(
|
||||
@JsonProperty("text")
|
||||
@Size(max = 4000, message = "text must be up to 4000 characters")
|
||||
String text,
|
||||
|
||||
@JsonProperty("attachment_ids")
|
||||
@Size(max = 10, message = "attachment_ids can contain up to 10 items")
|
||||
List<UUID> attachmentIds
|
||||
) {
|
||||
public CreateMessage {
|
||||
if (attachmentIds == null) {
|
||||
attachmentIds = List.of();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package ru.mtusi.messenger.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
public record CreateUser(
|
||||
@JsonProperty("username")
|
||||
@NotBlank(message = "username must not be blank")
|
||||
@Pattern(regexp = "^[a-z0-9_]{3,32}$", message = "username must match ^[a-z0-9_]{3,32}$")
|
||||
String username,
|
||||
|
||||
@JsonProperty("display_name")
|
||||
@NotBlank(message = "display_name must not be blank")
|
||||
@Size(min = 1, max = 100, message = "display_name must be 1..100 characters")
|
||||
String displayName,
|
||||
|
||||
@JsonProperty("password")
|
||||
@NotBlank(message = "password must not be blank")
|
||||
@Size(min = 12, max = 128, message = "password must be 12..128 characters")
|
||||
String password
|
||||
) {}
|
||||
@@ -0,0 +1,17 @@
|
||||
package ru.mtusi.messenger.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public record ErrorResponse(
|
||||
@JsonProperty("error") ErrorBody error
|
||||
) {
|
||||
public record ErrorBody(
|
||||
@JsonProperty("code") String code,
|
||||
@JsonProperty("message") String message,
|
||||
@JsonProperty("request_id") String requestId
|
||||
) {}
|
||||
|
||||
public static ErrorResponse of(String code, String message, String requestId) {
|
||||
return new ErrorResponse(new ErrorBody(code, message, requestId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package ru.mtusi.messenger.dto;
|
||||
|
||||
public record Health(String status) {
|
||||
public static Health ok() {
|
||||
return new Health("ok");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package ru.mtusi.messenger.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public record Message(
|
||||
@JsonProperty("id") UUID id,
|
||||
@JsonProperty("chat_id") UUID chatId,
|
||||
@JsonProperty("sender_id") UUID senderId,
|
||||
@JsonProperty("text") String text,
|
||||
@JsonProperty("attachment_ids") List<UUID> attachmentIds,
|
||||
@JsonProperty("created_at") OffsetDateTime createdAt
|
||||
) {}
|
||||
@@ -0,0 +1,9 @@
|
||||
package ru.mtusi.messenger.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.util.List;
|
||||
|
||||
public record MessagePage(
|
||||
@JsonProperty("items") List<Message> items,
|
||||
@JsonProperty("next_cursor") String nextCursor
|
||||
) {}
|
||||
@@ -0,0 +1,9 @@
|
||||
package ru.mtusi.messenger.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.util.List;
|
||||
|
||||
public record Page<T>(
|
||||
@JsonProperty("items") List<T> items,
|
||||
@JsonProperty("next_cursor") String nextCursor
|
||||
) {}
|
||||
@@ -0,0 +1,15 @@
|
||||
package ru.mtusi.messenger.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
public record SessionResponse(
|
||||
@JsonProperty("token") String token,
|
||||
@JsonProperty("token_type") String tokenType,
|
||||
@JsonProperty("expires_at") OffsetDateTime expiresAt,
|
||||
@JsonProperty("user") User user
|
||||
) {
|
||||
public SessionResponse(String token, OffsetDateTime expiresAt, User user) {
|
||||
this(token, "Bearer", expiresAt, user);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package ru.mtusi.messenger.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
public record User(
|
||||
@JsonProperty("id") UUID id,
|
||||
@JsonProperty("username") String username,
|
||||
@JsonProperty("display_name") String displayName,
|
||||
@JsonProperty("created_at") OffsetDateTime createdAt
|
||||
) {}
|
||||
Reference in New Issue
Block a user