This article describes how to enhance the user model based on an existing user context. You will add user Identity information to the user context and adjust the user information API to include this information in the response.
Create a domain object
-
On the bounded context page, click user context.
-
On the technical modeling page for the user context, create a new domain object. For details, see Create a domain object.
Use the following information to configure the Identity object:
-
Basic Information
Parameter
Example
object name
Identity
code
Identity
object type
value object (An identity document does not have an independent lifecycle or separate behaviors. It is a collection of attributes for the User entity, so it is defined as a value object.)
-
object attribute
Parameter
Example
field name
ID, User ID, Document Type, Document Number, Expiration Date
code
id, userId, cardType, cardId, expireDate
data type
Long, String, Integer, String, Date
-
object behavior
Parameter
Example
behavior name
List user identity documents
behavior code
listIdentityCard
behavior description
Retrieves a list of identity documents for a user based on the user ID.
input parameter
-
Parameter Name: User ID
-
code: userId
-
Parameter Type: String
-
required: Required
output parameter
-
Parameter Type: collection type > List > value object > Identity
-
Description: Identity
The preceding table details the object behavior for the new Identity object.
-
-
-
After creating a domain object, open the domain model designer to view and edit the domain object relationship diagram, for example, by drawing a relationship line to associate the User entity with the Identity value object. For more information, see Use the domain model designer. After creating the Identity object, in the domain object relationship configuration panel, set the current object to User (User), the target object to Identity (Identity), and the relationship type to 1:0..*. This indicates that one user can be associated with zero or more identity documents.
Edit the application service
After adding the Identity information, follow these steps to ensure it is included when you retrieve user information.
-
Create a Data Transfer Object (DTO): On the technical modeling page of the user context, navigate to the Data Transfer Object (DTO) page and create a new DTO. For detailed instructions, see Create and manage Data Transfer Objects (DTOs).
Use the following information to configure the new DTO:
Parameter
Example
Basic information
-
object name: User Identity DTO
-
code: UserIdentityDTO
Fields
-
field name: ID, Document Type, Document Number, Expiration Date
-
code: id, cardType, cardId, expireDate
-
data type: Long, Integer, String, Date
-
-
Modify the user basic information DTO: In the user basic information DTO, add a new field for Identity information. Configure its data type as: collection type > List > DTO > UserIdentityDTO. For detailed instructions, see Create and manage Data Transfer Objects (DTOs).