README.md 3,2 КБ
Newer Older
Radch-enko's avatar
Radch-enko включено в состав коммита
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Domain Module

## Overview
The Domain Module defines the core business entities, interfaces, and services for the Effective Office backend. It encapsulates the business logic and rules of the application, independent of specific implementations or external dependencies.

## Features
- Core domain models representing business entities
- Service interfaces defining business operations
- Business logic and validation rules

## Architecture
The module is organized into model and service packages:

```
domain/
├── src/
│   └── main/
│       └── kotlin/
│           └── band/
│               └── effective/
│                   └── office/
│                       └── backend/
│                           └── core/
│                               └── domain/
│                                   ├── model/       # Domain entities
│                                   │   ├── CalendarId.kt
│                                   │   ├── User.kt
│                                   │   ├── Utility.kt
│                                   │   ├── Workspace.kt
│                                   │   └── WorkspaceZone.kt
│                                   └── service/     # Domain services
│                                       ├── UserDomainService.kt
│                                       └── WorkspaceDomainService.kt
```

## Key Components

### Domain Models
- **User**: Represents a user in the system with properties like username, email, name, etc.
- **Workspace**: Represents a workspace or office space
- **WorkspaceZone**: Represents a zone within a workspace
- **Utility**: Represents utilities available in workspaces
- **CalendarId**: Represents a calendar identifier linked to a workspace

### Domain Services
- **UserDomainService**: Defines operations for user management (find, create)
- **WorkspaceDomainService**: Defines operations for workspace management

## Validation
The domain models include validation annotations to ensure data integrity:
- Required fields validation
- String length constraints
- Email format validation

## Integration
The Domain Module is used by:
- Feature modules that implement business logic
- Repository implementations that persist domain entities
- API controllers that expose domain operations

## Usage Examples

### Working with Domain Models
```kotlin
// Creating a new user
val user = User(
    username = "johndoe",
    email = "john.doe@example.com",
    firstName = "John",
    lastName = "Doe",
    role = "USER"
)

// Using domain services
class UserServiceImpl(private val userRepository: UserRepository) : UserDomainService {
    override fun findByUsername(username: String): User? {
        return userRepository.findByUsername(username)
    }
    
    override fun createUser(user: User): User {
        // Business logic for user creation
        return userRepository.save(user)
    }
}
```

## Development
When extending this module:
1. Keep domain models focused on business concepts, not technical details
2. Ensure domain services define clear contracts for business operations
3. Maintain separation between domain logic and implementation details
4. Add proper validation to ensure data integrity