lab2 done
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
Khakimov Dmitrij
2026-10-06 22:38:28 +03:00
parent 47a3cd582d
commit 300ef7714e
74 changed files with 2785 additions and 112 deletions
+1 -3
View File
@@ -1,7 +1,5 @@
package dto
import "time"
type CreateChatRequest struct {
Title string `json:"title"`
MemberIDs []string `json:"member_ids"`
@@ -11,5 +9,5 @@ type CreateChatResponse struct {
ID string `json:"id"`
Title string `json:"title"`
MemberIDs []string `json:"member_ids"`
CreatedAt time.Time `json:"created_at"`
CreatedAt Timestamp `json:"created_at"`
}
+1 -3
View File
@@ -1,7 +1,5 @@
package dto
import "time"
type CreateMessageRequest struct {
ChatID string `json:"-"`
Text string `json:"text"`
@@ -12,5 +10,5 @@ type CreateMessageResponse struct {
ChatID string `json:"chat_id"`
SenderID string `json:"sender_id"`
Text string `json:"text"`
CreatedAt time.Time `json:"created_at"`
CreatedAt Timestamp `json:"created_at"`
}
+2 -3
View File
@@ -1,8 +1,7 @@
package dto
import "time"
type CreateUserRequest struct {
Password string `json:"password"`
Username string `json:"username"`
DisplayName string `json:"display_name"`
}
@@ -11,5 +10,5 @@ type CreateUserResponse struct {
ID string `json:"id"`
Username string `json:"username"`
DisplayName string `json:"display_name"`
CreatedAt time.Time `json:"created_at"`
CreatedAt Timestamp `json:"created_at"`
}
+1 -3
View File
@@ -1,12 +1,10 @@
package dto
import "time"
type CurrentUserRequest struct{}
type CurrentUserResponse struct {
ID string `json:"id"`
Username string `json:"username"`
DisplayName string `json:"display_name"`
CreatedAt time.Time `json:"created_at"`
CreatedAt Timestamp `json:"created_at"`
}
+1 -3
View File
@@ -1,7 +1,5 @@
package dto
import "time"
type GetChatRequest struct {
ChatID string `json:"-"`
}
@@ -10,5 +8,5 @@ type GetChatResponse struct {
ID string `json:"id"`
Title string `json:"title"`
MemberIDs []string `json:"member_ids"`
CreatedAt time.Time `json:"created_at"`
CreatedAt Timestamp `json:"created_at"`
}
+1 -3
View File
@@ -1,7 +1,5 @@
package dto
import "time"
type ListChatsRequest struct {
Limit int `json:"-"`
Cursor string `json:"-"`
@@ -16,5 +14,5 @@ type ListChatsItem struct {
ID string `json:"id"`
Title string `json:"title"`
MemberIDs []string `json:"member_ids"`
CreatedAt time.Time `json:"created_at"`
CreatedAt Timestamp `json:"created_at"`
}
+1 -3
View File
@@ -1,7 +1,5 @@
package dto
import "time"
type ListMessagesRequest struct {
ChatID string `json:"-"`
Limit int `json:"-"`
@@ -18,5 +16,5 @@ type ListMessagesItem struct {
ChatID string `json:"chat_id"`
SenderID string `json:"sender_id"`
Text string `json:"text"`
CreatedAt time.Time `json:"created_at"`
CreatedAt Timestamp `json:"created_at"`
}
+8
View File
@@ -0,0 +1,8 @@
package dto
type CreateSessionResponse struct {
Token string `json:"token"`
TokenType string `json:"token_type"`
ExpiresAt Timestamp `json:"expires_at"`
User CreateUserResponse `json:"user"`
}
+11
View File
@@ -0,0 +1,11 @@
package dto
import "time"
// Timestamp preserves PostgreSQL microseconds and is readable by Python 3.9 clients.
// time.Time's variable-length fractional part is not supported by those clients.
type Timestamp time.Time
func (t Timestamp) MarshalJSON() ([]byte, error) {
return []byte(`"` + time.Time(t).UTC().Format("2006-01-02T15:04:05.000000Z") + `"`), nil
}
+15
View File
@@ -0,0 +1,15 @@
package dto
import (
"encoding/json"
"testing"
"time"
)
func TestTimestampFixedMicroseconds(t *testing.T) {
timestamp := Timestamp(time.Date(2026, 1, 2, 3, 4, 5, 123400000, time.UTC))
encoded, err := json.Marshal(timestamp)
if err != nil || string(encoded) != `"2026-01-02T03:04:05.123400Z"` {
t.Fatalf("timestamp=%s err=%v", encoded, err)
}
}