Реализация на 4

This commit is contained in:
Grbisba
2026-11-05 14:24:40 +03:00
parent 20f2f00a60
commit 8d44c74535
85 changed files with 3601 additions and 1109 deletions
+26 -44
View File
@@ -7,9 +7,7 @@ import (
"github.com/google/uuid"
"gitea.privcloud.tech/mtusi2026/internal/pkg/authidentity"
"gitea.privcloud.tech/mtusi2026/internal/pkg/authprovider"
"gitea.privcloud.tech/mtusi2026/internal/pkg/role"
"gitea.privcloud.tech/mtusi2026/internal/pkg/types/role"
)
// ---- Tokens ----
@@ -92,53 +90,37 @@ type RevokeRefreshTokensByUserID struct {
// ---- Auth ----
type Session struct {
ExpiresAt time.Time
Token string
TokenType string
User User
}
type Login struct {
Email string
Username string
Password string
}
type LoginResult struct {
ExpiresAt time.Time
TokenType string
User User
Tokens Tokens
}
// UserCredentials is internal authentication data, never a public user response.
type UserCredentials struct {
User User
PasswordHash string `json:"-"`
}
type Logout struct {
Token string
}
type Register struct {
Email string
Password string
RepeatPassword string
}
// ---- Auth Identities ----
type AuthIdentity struct {
ID uuid.UUID
Role role.Role
UserID uuid.UUID
Provider authprovider.Type
Identifier string
PasswordHash *string
Status authidentity.Status
CreatedAt time.Time
UpdatedAt time.Time
}
type UpdateAuthIdentity struct {
ID uuid.UUID
Role *role.Role
Provider *authprovider.Type
Identifier *string
PasswordHash *string
Status *authidentity.Status
UpdatedAt time.Time
}
type UpdateAuthIdentityPasswordHash struct {
ID uuid.UUID
PasswordHash string
UpdatedAt time.Time
}
type UpdateAuthIdentityStatus struct {
ID uuid.UUID
Status authidentity.Status
UpdatedAt time.Time
}
type GetAuthIdentityByRoleAndUserID struct {
Role role.Role
UserID uuid.UUID
}
+11
View File
@@ -18,3 +18,14 @@ type CreateChat struct {
Title string
MemberIDs []uuid.UUID
}
type ChatMember struct {
UserID uuid.UUID
ChatID uuid.UUID
}
type ChatFilters struct {
UserID uuid.UUID
Limit *int
AfterID *uuid.UUID
}
+7
View File
@@ -19,3 +19,10 @@ type CreateMessage struct {
SenderID uuid.UUID
Text string
}
type MessageFilters struct {
ChatID uuid.UUID
UserID uuid.UUID
Limit *int
AfterID *uuid.UUID
}
+17 -1
View File
@@ -1,9 +1,25 @@
package dto
import "github.com/google/uuid"
import (
"time"
"github.com/google/uuid"
)
// Page is a page of records with the ID to use for the next page.
type Page[T any] struct {
Items []T
NextCursorID *uuid.UUID
}
// PagePosition is a resolved database cursor, ordered by creation time and ID.
type PagePosition struct {
CreatedAt time.Time
ID uuid.UUID
}
// PageQuery is prepared by a service; Limit includes the lookahead row.
type PageQuery struct {
Limit int
After *PagePosition
}
+11
View File
@@ -16,4 +16,15 @@ type User struct {
type CreateUser struct {
Username string
DisplayName string
Password string
}
// CreateStoredUser contains the prepared database record, never a plaintext password.
type CreateStoredUser struct {
ID uuid.UUID
Username string
DisplayName string
PasswordHash string `json:"-"`
CreatedAt time.Time
UpdatedAt time.Time
}