forked from mtusi2026/mtusi2026lab2
Реализация на 4
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user