CN109947422B - Business entity implementation method and system based on domain-driven design - Google Patents

Business entity implementation method and system based on domain-driven design Download PDF

Info

Publication number
CN109947422B
CN109947422B CN201910192561.9A CN201910192561A CN109947422B CN 109947422 B CN109947422 B CN 109947422B CN 201910192561 A CN201910192561 A CN 201910192561A CN 109947422 B CN109947422 B CN 109947422B
Authority
CN
China
Prior art keywords
entity
layer
data
business
service
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910192561.9A
Other languages
Chinese (zh)
Other versions
CN109947422A (en
Inventor
宫保金
孙立新
张进
周由甲
王洁
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur General Software Co Ltd
Original Assignee
Inspur General Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Inspur General Software Co Ltd filed Critical Inspur General Software Co Ltd
Priority to CN201910192561.9A priority Critical patent/CN109947422B/en
Publication of CN109947422A publication Critical patent/CN109947422A/en
Application granted granted Critical
Publication of CN109947422B publication Critical patent/CN109947422B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

The invention discloses a method and a system for realizing a business entity based on field-driven design, belonging to the field of application program development, aiming at providing a unified framework for field core business logic development, enhancing the constraint force of developing an application program and ensuring the compactness of field layer development so as to reduce the requirements on developers and adopting the technical scheme that: a method for realizing a service entity based on a domain-driven design comprises the following steps: s1, establishing a business entity model through a business entity modeling tool; s2, establishing a service entity operation framework; s3, establishing a cache frame in the business entity operation frame; s4, establishing an increment mechanism in the business entity operation framework; s5, splitting the service logic into an entity logic layer and a service logic layer; s6, establishing a business entity designer; and S7, establishing a JIT generator. The invention also discloses a business entity system based on the field drive design.

Description

Business entity implementation method and system based on domain-driven design
Technical Field
The invention belongs to the field of application program development, relates to the field of core service logic layer development, and particularly relates to a service entity implementation method and system based on field drive design.
Background
With the development of more and more application programs, the development of the field layer is loose due to the fact that a unified framework and constraint capability are lacked in the field core business logic development, the requirement on the level of developers is high, and the developed application programs are weak in stability and adaptation to the change of a front-end UI (user interface), and are not beneficial to the stability of business logic layer codes.
The Business Logic Layer (Business Logic Layer) is undoubtedly part of the system architecture that embodies the core value. The main focus of its attention is on system design related to business requirements, such as formulation of business rules, implementation of business processes, etc., that is, it is related to Domain logic to which the system corresponds, and often, the business logic layer is also called Domain layer. The three-layer development is to divide the whole service application of the system into a presentation layer, a service logic layer and a data access layer, which is beneficial to the development, maintenance, deployment and extension of the system. Delamination is to achieve "high cohesion, low coupling". The idea of 'divide and conquer' is adopted to divide the problem into various solutions, and the control, the extension and the resource allocation are easy. The service logic layer is responsible for processing services in the system field and for generating, processing and converting logical data. The method is responsible for the correctness and the validity of the input logical data, but not responsible for the correctness of the output logical data and the user data, and not responsible for the presentation style of the data.
Patent document CN106815016A discloses an MVVM design model (DDMVVM) based on domain-driven design, which mainly includes: MVVM design model based on field driven design, the whole framework divides into 4 layers: the system comprises a view layer, a view model layer, a field model layer and an infrastructure layer; the MVVM model design method based on the field-driven design specifically comprises the following steps of: strategic and tactical design; and the MVVM model development framework based on the field drive design realizes each layer of the MVVM model based on the field drive design under a WeChat small program development platform. The technical scheme solves the problem that software complexity is higher and higher in front-end application program development, but a unified framework can not be provided for field core service logic development, the constraint force of the developed application program is enhanced, the field layer development is compact, the requirements on developers are reduced, the development cost is reduced, the stability of the developed application program and the adaptability of adapting to the change of a front-end UI are improved, and the stability of service logic layer codes is facilitated.
Disclosure of Invention
The technical task of the invention is to provide a method and a system for realizing a business entity based on domain-driven design, so as to solve the problems of how to provide a unified framework for domain core business logic development, enhance the constraint force of developing an application program, ensure the compactness of domain layer development, further reduce the requirements on developers, further reduce the development cost, simultaneously improve the stability of the developed application program and the adaptability of adapting to the change of a front-end UI (user interface) and be beneficial to the stability of a business logic layer code.
The technical task of the invention is realized according to the following mode, a service entity realizing method based on field-driven design comprises the following steps:
s1, establishing a business entity model through a business entity modeling tool: the business entity model adopts an entity model abstracted by the field drive design and is used for describing business logic; the business entity model comprises an entity data structure and a business logic layer;
s2, establishing a service entity operation framework: the service entity operation framework provides a basic framework for service logic operation, the service entity operation framework comprises the most basic content of a service logic layer and a common service logic implementation extension mechanism, and the service function is to add a self-defined service logic code on the basis of the framework;
s3, establishing a cache frame in the business entity operation frame, wherein the cache frame comprises a session level cache layer, a transaction level cache layer and an action level cache layer, and the three levels of cache are as follows: the data of different states of business logic are cached, the session level cache layer corresponds to original data, the object level cache corresponds to current transaction level data, and the action level cache corresponds to current operation level data, so that the access frequency of the database is reduced on the premise of meeting the access requirements of business functions on the data of different states, and the overall efficiency is improved;
s4, establishing an increment mechanism in the business entity operation framework: the data returned by the front-end caller, the data submitted by the front-end modification and the data submitted to the database during storage are all incremental data, so that the transmission quantity of the data is greatly reduced, and the program performance is improved;
s5, dividing the business logic into an entity logic layer and a service logic layer, wherein the entity logic layer is the business logic division layer with the finest granularity, and the service logic layer is used for arranging and processing the entity logic layer;
s6, establishing a business entity designer: carrying out service development through a service entity modeling tool, and modeling an entity data structure and service logic;
s7, establishing a JIT generator: the modeling business entity model is generated into a business code which runs on the basis of a business entity running framework, the generation logic is executed only once when the business entity model is deployed to a formal production environment, and the business code is executed in running, so that the performance consumption caused by loading and analyzing the business entity model is saved, and the running efficiency is greatly improved; and the JIT generator generates a corresponding Api, Entity, Core and Persistence four program packages from one service Entity model according to the service Entity model generation runtime code.
Preferably, the entity data structure in step S1 includes a root entity and several sub-entities (there may be no sub-entities);
the entity comprises a plurality of attributes, and the data type of the attributes is set or the attributes are set to be an enumeration type or an association type; wherein the data types comprise basic types of characters, texts, time, dates, Boolean, integer, floating point numbers and binary types; the association type refers to the association of the main sub-entity and the association of the current business entity and the business entities except the current business entity.
Preferably, the service logic layer in step S1 is divided into an entity operation layer, a linkage calculation rule layer, a data verification rule layer, and a service operation layer according to different scenarios;
the entity operation layer is a business logic layer surrounding an entity data instance, is a business logic layer with the finest granularity, and can carry out operation modification on current entity data in entity operation;
the linkage calculation rule layer is triggered by internal data change at different occasions; the linkage calculation rule layer needs to set a trigger field (namely the rule is triggered by the modification of the fields, the linkage calculation rule is a business logic, the execution of the rule is not actively triggered by external calling), the trigger field is used for triggering the modification of the field, and the trigger field is a field on the current entity or a field on a sub-entity of the current entity;
the data checking rule layer (same linkage calculation rule) is triggered by internal data change at different time; the data checking rule layer needs to set a trigger field;
the service operation layer is a method provided for the outside, belongs to the field service layer, and is responsible for arranging and executing the operation of each internal entity;
each service logic layer corresponds to a component description, and each component description corresponds to a section of code logic; wherein the component description includes the corresponding assembly, the parameter, and the return value.
Preferably, the service entity operation framework in step S2 is based on a microkernel architecture mode, and the service entity operation framework is divided into a kernel layer, a service entity framework layer, and an extended service-service component layer;
the kernel layer is a basic operation framework layer, and provides the most basic structure and extension mechanisms of service logic development, such as conflict control, authority control, plug-in mechanisms and the like;
the business entity framework layer is an inner core layer business entity framework layer for abstracting form development on the basis of the inner core layer, and the business entity framework layer provides business realization of form development, such as built-in addition, deletion, modification and check operations and the like;
the extended service-business component layer is based on business entity framework layer, providing extended service and business component, and business operations except CRUD are realized in the layer.
Preferably, the specific steps of the operation of the business entity operation framework in step S2 are as follows:
s201, a user opens operation, automatically submits a change set and stores the change set in a business entity operation frame; the change set comprises newly added data change, modified data change and deleted data change, and the newly added data change, the modified data change and the deleted data change are all required to be submitted to a data change interface;
s202, a rule component library in the business entity running framework is loaded, executed and transmitted to a business operation processor in the business entity running framework, and the business operation processor transmits action rules to be arranged to an action level cache layer in a cache framework;
s203, a rule component library in the business entity operation frame is loaded, executed and transmitted to the business entity operation frame in the business entity operation frame, and a storage processor in the business entity operation frame transmits a submission rule to be arranged on an object level cache layer in the cache frame;
s203, the storage processor constructs a DB transaction and submits the DB transaction to a database;
s204, the database loads data to a session level cache layer, the session level cache layer loads data to an object level cache layer, the object level cache layer loads data to an action level cache layer, the action level cache layer submits the data to the object level cache layer, and the object level cache layer submits the data to the session level cache layer.
Preferably, the session level cache layer in step S3 is used to cache data stored in a persistent storage (e.g., a database);
the transaction level cache layer is used for caching all data changes before saving in the period that a user opens a function and operates, and the transaction level cache layer is specifically divided into two cases:
if the storage operation is executed, the data in the transaction level cache layer is submitted to the persistent storage and the data is updated to the session level cache layer;
if cancel operation is executed, the data in the transaction level cache layer is lost;
the action-level cache layer caches data changes during a one-time request, and the two situations are specifically as follows:
firstly, if the request is successfully executed, submitting the data of the action level cache layer to a transaction level cache layer;
and secondly, if the request fails to be executed, rolling back the data of the action level cache layer.
Preferably, the increment mechanism in step S4 includes an increment acquiring data module and an increment submitting data module;
the increment acquisition data module is used for supporting cutting of returned data according to the entity, the attribute and multiple dimensionalities of the data line according to the front end requirement, and reducing the data transmission quantity;
the incremental submitting data module is used for submitting only changed data instead of all data when the data is submitted at the front end, so that the data transmission amount is reduced.
Preferably, the business entity designer in step S6 includes an entity node design module, an entity operation design module, an entity linkage calculation rule and data verification rule design module, and a service operation design module;
the entity node design module is used for adding and deleting entity nodes; the corresponding entity node can add or delete entity attributes (fields) and set the attributes of the fields;
the entity operation design module is used for providing an adding and deleting entity operation method;
the entity linkage calculation rule and data verification rule design module is used for adding and deleting linkage calculation and data verification rules at different occasions;
the service operation design module is used for adding and deleting service operations.
A business entity system based on domain-driven design, the system comprises,
the business entity model is used for describing business logic and adopts a domain drive to design an abstracted entity model; the business entity model comprises an entity data structure and a business logic layer;
the service entity operation module is used for providing a basic framework for service logic operation, the service entity operation module comprises the most basic content of a service logic layer and an encapsulation public service logic realization extension mechanism, and the service function is to add a self-defined service logic code on the basis of the framework;
the cache module comprises a session level cache layer, a transaction level cache layer and an action level cache layer, the data of different service logics are cached, the session level cache layer corresponds to original data, the transaction level cache corresponds to current transaction level data, and the action level cache corresponds to current operation level data, so that the access frequency of the database is reduced on the premise of meeting the access requirements of service functions on the data of different states, and the overall efficiency is improved;
the increment mechanism module is used for defining that the data returned by the front-end caller, the data submitted by the front-end modification and the data submitted to the database during storage are all increment data, so that the transmission quantity of the data is greatly reduced, and the program performance is improved;
the business logic layer comprises an entity logic layer and a service logic layer, the entity logic layer is a business logic split layer with the finest granularity, and the service logic layer is used for arranging and processing the entity logic layer;
the business entity designer is used for carrying out business development through a business entity modeling tool and modeling an entity data structure and business logic;
the JIT generator is used for generating the modeled business entity model into a business code which runs on the basis of a business entity running frame, the generation logic is executed once when the business entity model is deployed to a formal production environment, and the business code is executed when the business entity model runs, so that the performance consumption caused by loading and analyzing the business entity model is saved, and the running efficiency is greatly improved; and the JIT generator generates a corresponding Api, Entity, Core and Persistence four program packages from one service Entity model according to the service Entity model generation runtime code.
Preferably, the service entity operation module comprises a local calling agent factory and an entity object manager, wherein the local calling agent factory creates a local calling agent, the local calling agent transfers the entity object manager, the entity object manager arranges entity object instances and executes entity object manager contexts, and meanwhile, the entity object manager holds a self-defined action base class; the entity object instance executes the check rule base class, the calculation rule base class and the entity action base class, and simultaneously holds the entity action context, the check rule base class holds the check rule context, and the calculation rule base class holds the calculation rule context.
The method and the system for realizing the business entity based on the field drive design have the following advantages that:
the business logic layer implementation framework abstracted by adopting a domain-driven design method comprises two parts, namely entity data and business logic, provides standard constraint for business logic development, and carries out fine-grained splitting and arranging on the business logic to finally realize precipitable multiplexing of the business logic; in order to improve the business development efficiency, the invention provides an entity modeling tool to assist business development modeling, and provides a JIT engine to generate a model built by the modeling tool into a runtime program set adapted to a business entity framework;
providing a business entity model for a domain core business logic layer by introducing a business entity framework and based on a domain drive design method, and modeling and splitting each characteristic of the domain core business logic layer through the business entity model; when developing business logic, a developer only develops a pile of fine-grained business logic and places the logic at different positions of a business entity model, and the logic of the field core is arranged and processed by providing service operation and adapting to different application scenes, so that the field core logic can be stabilized;
through a business entity designer, a user can conveniently model and develop a business logic layer, and the development efficiency and the development period flexibility are improved;
by the service entity framework, a uniform service logic layer operation framework is packaged and built-in, so that the stability of the operation period is improved;
the JIT generator is used for generating the model during design into a program during running, so that the analysis process of metadata during running is omitted, and the running period efficiency is improved;
by providing business logic concepts such as entities, entity operation, linkage calculation, data verification, service operation and the like, the business logic can be scattered, different application scenes can be adapted through the service operation, and the stability and precipitable reuse of core business logic are realized;
by the characteristics of three-level caching, incremental data acquisition and submission and the like, the interaction with a database and the data volume of application and front-end transmission are reduced, and the overall performance is improved;
and fourthly, the invention provides a unified framework for the domain core service logic development, enhances the constraint force of the development application program, ensures the compactness of the domain layer development, further reduces the requirements on developers, thereby reducing the development cost, simultaneously improving the stability of the developed application program and the adaptability of adapting to the change of the front-end UI (user interface), and being beneficial to the stability of the service logic layer code.
Drawings
The invention is further described below with reference to the accompanying drawings.
FIG. 1 is a block diagram of a business entity system based on domain-driven design;
FIG. 2 is a block diagram of a business entity framework;
FIG. 3 is a block diagram of a change set architecture;
FIG. 4 is a flow diagram of the operation of a business entity operation module;
FIG. 5 is a design interface diagram of an entity node;
FIG. 6 is a diagram of a physical operation design interface;
FIG. 7 is a schematic representation of a linkage calculation rule design interface;
FIG. 8 is a data verification rule design interface diagram.
Detailed Description
The method and system for implementing a business entity based on domain-driven design according to the present invention will be described in detail below with reference to the drawings and specific embodiments of the specification.
Example 1:
as shown in fig. 1, the method for implementing a service entity based on a domain-driven design according to the present invention includes the following steps:
s1, establishing a business entity model through a business entity modeling tool: the business entity model adopts an entity model abstracted by the field drive design and is used for describing business logic; the business entity model comprises an entity data structure and a business logic layer;
wherein, the entity data structure comprises a root entity and a plurality of sub-entities (no sub-entity can be available);
the entity comprises a plurality of attributes, and the data type of the attributes is set or the attributes are set to be an enumeration type or an association type; wherein the data types comprise basic types of characters, texts, time, dates, Boolean, integer, floating point numbers and binary types; the association type refers to the association of the main sub-entity and the association of the current business entity and the business entities except the current business entity. The business logic layer is divided into an entity operation layer, a linkage calculation rule layer, a data verification rule layer and a service operation layer according to different scenes; the entity operation layer is a business logic layer surrounding an entity data instance, is a business logic layer with the finest granularity, and can carry out operation modification on the current entity data in the entity operation; the linkage calculation rule layer is triggered by internal data change at different occasions; the linkage calculation rule layer needs to set a trigger field (namely the rule is triggered by the modification of the fields, the linkage calculation rule is a business logic, the execution of the rule is not actively triggered by external calling), the trigger field is used for triggering the modification of the field, and the trigger field is a field on the current entity or a field on a sub-entity of the current entity; the execution of the linkage calculation rules is performed at different timings of data change, and the execution timing list is detailed in table 1:
Figure GDA0003465789820000071
Figure GDA0003465789820000081
the data checking rule layer (same linkage calculation rule) is triggered by internal data change at different time; the data checking rule layer needs to set a trigger field; the execution timing of the data verification rule is detailed in table 2:
Figure GDA0003465789820000082
the service operation layer is a method provided for the outside, belongs to the field service layer, and is responsible for arranging and executing the operation of each internal entity;
each service logic layer corresponds to a component description, and each component description corresponds to a section of code logic; wherein the component description includes the corresponding assembly, the parameter, and the return value.
S2, establishing a service entity operation framework: the service entity operation framework provides a basic framework for service logic operation, the service entity operation framework comprises the most basic content of a service logic layer and a common service logic implementation extension mechanism, and the service function is to add a self-defined service logic code on the basis of the framework; the service entity operation framework is based on a microkernel architecture mode and is divided into a kernel layer, a service entity framework layer and an extended service-service component layer; the kernel layer is a basic operation framework layer, and provides the most basic structure and extension mechanisms of service logic development, such as conflict control, authority control, plug-in mechanisms and the like; the business entity framework layer is an inner core layer business entity framework layer for abstracting form development on the basis of the inner core layer, and the business entity framework layer provides business realization of form development, such as built-in addition, deletion, modification and check operations and the like; the extended service-business component layer is based on business entity framework layer, providing extended service and business component, and business operations except CRUD are realized in the layer.
As shown in fig. 2, the specific steps of the operation of the service entity operation framework are as follows:
s201, a user opens operation, automatically submits a change set and stores the change set in a business entity operation frame; as shown in fig. 3, the change set includes new data changes, modified data changes, and deleted data changes, and the new data changes, the modified data changes, and the deleted data changes are all submitted to the data change interface;
s202, a rule component library in the business entity running framework is loaded, executed and transmitted to a business operation processor in the business entity running framework, and the business operation processor transmits action rules to be arranged to an action level cache layer in a cache framework;
s203, a rule component library in the business entity operation frame is loaded, executed and transmitted to the business entity operation frame in the business entity operation frame, and a storage processor in the business entity operation frame transmits a submission rule to be arranged on an object level cache layer in the cache frame;
s203, the storage processor constructs a DB transaction and submits the DB transaction to a database;
s204, the database loads data to a session level cache layer, the session level cache layer loads data to an object level cache layer, the object level cache layer loads data to an action level cache layer, the action level cache layer submits the data to the object level cache layer, and the object level cache layer submits the data to the session level cache layer.
S3, establishing a cache frame in the business entity operation frame, wherein the cache frame comprises a session level cache layer, a transaction level cache layer and an action level cache layer, and the three levels of cache are as follows: the data of different states of business logic are cached, the session level cache layer corresponds to original data, the object level cache corresponds to current transaction level data, and the action level cache corresponds to current operation level data, so that the access frequency of the database is reduced on the premise of meeting the access requirements of business functions on the data of different states, and the overall efficiency is improved;
wherein, the session level cache layer is used for caching data stored in a persistent storage (such as a database);
the transaction level cache layer is used for caching all data changes before saving in the period that a user opens a function and operates, and the transaction level cache layer is specifically divided into two cases:
if the storage operation is executed, the data in the transaction level cache layer is submitted to the persistent storage and the data is updated to the session level cache layer;
if cancel operation is executed, the data in the transaction level cache layer is lost;
the action-level cache layer caches data changes during a one-time request, and the two situations are specifically as follows:
firstly, if the request is successfully executed, submitting the data of the action level cache layer to a transaction level cache layer;
and secondly, if the request fails to be executed, rolling back the data of the action level cache layer.
S4, establishing an increment mechanism in the business entity operation framework: the data returned by the front-end caller, the data submitted by the front-end modification and the data submitted to the database during storage are all incremental data, so that the transmission quantity of the data is greatly reduced, and the program performance is improved; the increment mechanism comprises an increment data acquisition module and an increment data submission module; the increment acquisition data module is used for supporting cutting of returned data according to the entity, the attribute and multiple dimensionalities of the data line according to the front end requirement, and reducing the data transmission quantity; the incremental submitting data module is used for submitting only changed data instead of all data when the data is submitted at the front end, so that the data transmission amount is reduced.
S5, dividing the business logic into an entity logic layer and a service logic layer, wherein the entity logic layer is the business logic division layer with the finest granularity, and the service logic layer is used for arranging and processing the entity logic layer;
s6, establishing a business entity designer: carrying out service development through a service entity modeling tool, and modeling an entity data structure and service logic; the business entity designer comprises an entity node design module, an entity operation design module, an entity linkage calculation rule and data verification rule design module and a service operation design module; the entity node design module is used for adding and deleting entity nodes; the entity node design interface is shown in figure 5; the entity node attributes are detailed in table 3:
Figure GDA0003465789820000101
the corresponding entity node can add or delete entity attributes (fields) and set the attributes of the fields; the field attributes are detailed in table 4:
Figure GDA0003465789820000102
the entity operation design module is used for providing an adding and deleting entity operation method; the entity operation design interface is shown in figure 6; the entity operation attributes are detailed in table 5:
Figure GDA0003465789820000103
the entity linkage calculation rule and data verification rule design module is used for adding and deleting linkage calculation and data verification rules at different occasions; the linkage calculation rule design interface is shown in FIG. 7; linkage calculation rule attributes are detailed in table 6:
Figure GDA0003465789820000111
the data verification rule design interface is shown in fig. 8; data check rule attributes are detailed in table 7:
Figure GDA0003465789820000112
the service operation design module is used for adding and deleting service operations, and the service operation attributes are detailed in table 8:
Figure GDA0003465789820000113
s7, establishing a JIT generator: the modeling business entity model is generated into a business code which runs on the basis of a business entity running framework, the generation logic is executed only once when the business entity model is deployed to a formal production environment, and the business code is executed in running, so that the performance consumption caused by loading and analyzing the business entity model is saved, and the running efficiency is greatly improved; and the JIT generator generates a corresponding Api, Entity, Core and Persistence four program packages from one service Entity model according to the service Entity model generation runtime code.
Example 2:
the invention relates to a business entity system designed based on field drive, which comprises a business entity model, a business entity operation module, a cache module, an increment mechanism module, a business logic layer, a business entity designer and a JIT generator; the business entity model is used for describing business logic and adopts a domain drive to design an abstracted entity model; the business entity model comprises an entity data structure and a business logic layer; the service entity operation module is used for providing a basic framework for service logic operation, the service entity operation module comprises the most basic content of a service logic layer and an encapsulation public service logic realization extension mechanism, and the service function is to add a self-defined service logic code on the basis of the framework; the cache module comprises a session level cache layer, a transaction level cache layer and an action level cache layer, the data of different service logics are cached, the session level cache layer corresponds to original data, the transaction level cache corresponds to current transaction level data, and the action level cache corresponds to current operation level data, so that the access frequency of the database is reduced on the premise of meeting the access requirements of service functions on the data of different states, and the overall efficiency is improved; the increment mechanism module is used for defining that the data returned by the front-end caller, the data submitted by the front-end modification and the data submitted to the database during storage are all increment data, so that the transmission quantity of the data is greatly reduced, and the program performance is improved; the business logic layer comprises an entity logic layer and a service logic layer, the entity logic layer is a business logic split layer with the finest granularity, and the service logic layer is used for arranging and processing the entity logic layer; the business entity designer is used for carrying out business development through a business entity modeling tool and modeling an entity data structure and business logic; the JIT generator is used for generating the modeled business entity model into a business code which runs on the basis of a business entity running frame, the generation logic is executed once when the business entity model is deployed to a formal production environment, and the business code is executed when the business entity model runs, so that the performance consumption caused by loading and analyzing the business entity model is saved, and the running efficiency is greatly improved; and the JIT generator generates a corresponding Api, Entity, Core and Persistence four program packages from one service Entity model according to the service Entity model generation runtime code. As shown in fig. 4, the service entity operation module includes a local call agent factory and an entity object manager, the local call agent factory creates a local call agent, the local call agent transfers the entity object manager, the entity object manager arranges entity object instances and executes entity object manager contexts, and meanwhile, holds a custom action base class; the entity object instance executes the check rule base class, the calculation rule base class and the entity action base class, and simultaneously holds the entity action context, the check rule base class holds the check rule context, and the calculation rule base class holds the calculation rule context.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (9)

1. A method for realizing a business entity based on a domain-driven design is characterized by comprising the following steps:
s1, establishing a business entity model through a business entity modeling tool: the business entity model adopts an entity model abstracted by the field drive design and is used for describing business logic; the business entity model comprises an entity data structure and a business logic layer;
s2, establishing a service entity operation framework: the service entity operation framework provides a basic framework for service logic operation, and comprises the most basic content of a service logic layer and an encapsulation public service logic realization extension mechanism; the service entity operation framework is based on a microkernel architecture mode and is divided into a kernel layer, a service entity framework layer and an extended service-service component layer;
the kernel layer is a basic operation framework layer and provides the most basic structure and the expansion mechanism for business logic development;
the business entity framework layer is an inner core layer business entity framework layer for abstracting form development on the basis of the inner core layer, and the business entity framework layer provides business realization of form development;
the service expansion-service component layer is based on the service entity framework layer and provides the service expansion and the service components;
s3, establishing a cache frame in the business entity operation frame, wherein the cache frame comprises a session level cache layer, a transaction level cache layer and an action level cache layer, and the three levels of cache are as follows: the data of different service logic states are cached, the session level cache layer corresponds to original data, the transaction level cache corresponds to current transaction level data, the action level cache corresponds to current operation level data, and the access frequency of the database is reduced on the premise that the access requirements of service functions on the data of different states are met;
s4, establishing an increment mechanism in the business entity operation framework: the data returned by the front-end caller, the data submitted by the front-end modification and the data submitted to the database during storage are all incremental data;
s5, dividing the business logic into an entity logic layer and a service logic layer, wherein the entity logic layer is the business logic division layer with the finest granularity, and the service logic layer is used for arranging and processing the entity logic layer;
s6, establishing a business entity designer: carrying out service development through a service entity modeling tool, and modeling an entity data structure and service logic;
s7, establishing a JIT generator: generating a business entity model of the modeling into a business code which runs on the basis of a business entity running framework; and the JIT generator generates a corresponding Api, Entity, Core and Persistence four program packages from one service Entity model according to the service Entity model generation runtime code.
2. The method for implementing business entities based on domain-driven design according to claim 1, wherein the entity data structure in step S1 includes a root entity and several sub-entities;
the entity comprises a plurality of attributes, and the data type of the attributes is set or the attributes are set to be an enumeration type or an association type; wherein the data types comprise basic types of characters, texts, time, dates, Boolean, integer, floating point numbers and binary types; the association type refers to the association of the main sub-entity and the association of the current business entity and the business entities except the current business entity.
3. The method for implementing a business entity based on a domain-driven design according to claim 1 or 2, wherein the business logic layer in step S1 is divided into an entity operation layer, a linkage calculation rule layer, a data verification rule layer and a service operation layer according to different scenarios;
the entity operation layer is a business logic layer surrounding an entity data instance, is a business logic layer with the finest granularity, and can carry out operation modification on current entity data in entity operation;
the linkage calculation rule layer is triggered by internal data change at different occasions; the linkage calculation rule layer needs to set a trigger field, the trigger field is used for triggering field modification, and the trigger field is a field on the current entity or a field on a sub-entity of the current entity;
the data checking rule layer is triggered by internal data change at different time; the data checking rule layer needs to set a trigger field;
the service operation layer is a method provided for the outside, belongs to the field service layer, and is responsible for arranging and executing the operation of each internal entity;
each service logic layer corresponds to a component description, and each component description corresponds to a section of code logic; wherein the component description includes the corresponding assembly, the parameter, and the return value.
4. The method for implementing business entities based on domain-driven design according to claim 3, wherein the specific steps of the business entity operation framework in the step S2 are as follows:
s201, a user opens operation, automatically submits a change set and stores the change set in a business entity operation frame; the change set comprises newly added data change, modified data change and deleted data change, and the newly added data change, the modified data change and the deleted data change are all required to be submitted to a data change interface;
s202, a rule component library in the business entity running framework is loaded, executed and transmitted to a business operation processor in the business entity running framework, and the business operation processor transmits action rules to be arranged to an action level cache layer in a cache framework;
s203, a rule component library in the business entity operation frame is loaded, executed and transmitted to the business entity operation frame in the business entity operation frame, and a storage processor in the business entity operation frame transmits a submission rule to be arranged to a transaction-level cache layer in the cache frame;
s203, the storage processor constructs a DB transaction and submits the DB transaction to a database;
s204, the database loads data to a session level cache layer, the session level cache layer loads data to a transaction level cache layer, the transaction level cache layer loads data to an action level cache layer, the action level cache layer submits the data to the transaction level cache layer, and the transaction level cache layer submits the data to the session level cache layer.
5. The method for implementing business entities based on domain-driven design according to claim 1, wherein the session level cache layer in step S3 is used for caching data stored in persistent storage;
the transaction level cache layer is used for caching all data changes before saving in the period that a user opens a function and operates, and the transaction level cache layer is specifically divided into two cases:
if the storage operation is executed, the data in the transaction level cache layer is submitted to the persistent storage and the data is updated to the session level cache layer;
if cancel operation is executed, the data in the transaction level cache layer is lost;
the action-level cache layer caches data changes during a one-time request, and the two situations are specifically as follows:
firstly, if the request is successfully executed, submitting the data of the action level cache layer to a transaction level cache layer;
and secondly, if the request fails to be executed, rolling back the data of the action level cache layer.
6. The method for implementing business entities based on domain-driven design according to claim 1, wherein the increment mechanism in step S4 includes an increment acquisition data module and an increment submission data module;
the increment acquisition data module is used for supporting cutting of returned data according to the entity, the attribute and multiple dimensionalities of the data line according to the front end requirement, and reducing the data transmission quantity;
the incremental submitting data module is used for submitting only changed data instead of all data when the data is submitted at the front end, so that the data transmission amount is reduced.
7. The method for implementing a business entity based on domain-driven design according to claim 1, wherein the business entity designer in step S6 includes an entity node design module, an entity operation design module, an entity linkage calculation rule and data verification rule design module, and a service operation design module;
the entity node design module is used for adding and deleting entity nodes; the corresponding entity node can add or delete the entity attribute and set the attribute of the field;
the entity operation design module is used for providing an adding and deleting entity operation method;
the entity linkage calculation rule and data verification rule design module is used for adding and deleting linkage calculation and data verification rules at different occasions;
the service operation design module is used for adding and deleting service operations.
8. A business entity system based on domain-driven design, which is characterized by comprising,
the business entity model is used for describing business logic and adopts a domain drive to design an abstracted entity model; the business entity model comprises an entity data structure and a business logic layer;
the service entity operation module is used for providing a basic framework for service logic operation, and comprises the most basic content of a service logic layer and an encapsulation public service logic realization extension mechanism; the service entity operation framework is based on a microkernel architecture mode and is divided into a kernel layer, a service entity framework layer and an extended service-service component layer;
the kernel layer is a basic operation framework layer and provides the most basic structure and the expansion mechanism for business logic development;
the business entity framework layer is an inner core layer business entity framework layer for abstracting form development on the basis of the inner core layer, and the business entity framework layer provides business realization of form development;
the service expansion-service component layer is based on the service entity framework layer and provides the service expansion and the service components;
the cache module comprises a session level cache layer, a transaction level cache layer and an action level cache layer, the data of different service logics are cached, the session level cache layer corresponds to original data, the transaction level cache corresponds to current transaction level data, the action level cache corresponds to current operation level data, and the access frequency of the database is reduced on the premise of meeting the access requirements of service functions on the data of different states;
the increment mechanism module is used for defining that the data returned by the front-end caller, the data submitted by the front-end modification and the data submitted to the database during storage are all increment data;
the business logic layer comprises an entity logic layer and a service logic layer, the entity logic layer is a business logic split layer with the finest granularity, and the service logic layer is used for arranging and processing the entity logic layer;
the business entity designer is used for carrying out business development through a business entity modeling tool and modeling an entity data structure and business logic;
a JIT generator for generating a modeled business entity model as a business code running on a business entity running framework basis; and the JIT generator generates a corresponding Api, Entity, Core and Persistence four program packages from one service Entity model according to the service Entity model generation runtime code.
9. The system of claim 8, wherein the business entity execution module comprises a local call agent factory and an entity object manager, the local call agent factory creates a local call agent, the local call agent transfers the entity object manager, the entity object manager organizes entity object instances and executes entity object manager contexts, and meanwhile holds a custom action base class; the entity object instance executes the check rule base class, the calculation rule base class and the entity action base class, and simultaneously holds the entity action context, the check rule base class holds the check rule context, and the calculation rule base class holds the calculation rule context.
CN201910192561.9A 2019-03-14 2019-03-14 Business entity implementation method and system based on domain-driven design Active CN109947422B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910192561.9A CN109947422B (en) 2019-03-14 2019-03-14 Business entity implementation method and system based on domain-driven design

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910192561.9A CN109947422B (en) 2019-03-14 2019-03-14 Business entity implementation method and system based on domain-driven design

Publications (2)

Publication Number Publication Date
CN109947422A CN109947422A (en) 2019-06-28
CN109947422B true CN109947422B (en) 2022-03-15

Family

ID=67009812

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910192561.9A Active CN109947422B (en) 2019-03-14 2019-03-14 Business entity implementation method and system based on domain-driven design

Country Status (1)

Country Link
CN (1) CN109947422B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111091213A (en) * 2019-11-28 2020-05-01 泰康保险集团股份有限公司 Product data processing method and device, electronic equipment and computer readable medium
CN111666355B (en) * 2020-06-12 2023-09-08 远光软件股份有限公司 Model construction method and device for field, data and scene three-layer model
CN111666073B (en) * 2020-06-12 2023-09-29 远光软件股份有限公司 Graphical model construction method and device based on field driving design
CN111984257B (en) * 2020-06-29 2022-07-08 浪潮通用软件有限公司 Solid modeling customized extension method and device
CN111984240A (en) * 2020-06-29 2020-11-24 山东浪潮通软信息科技有限公司 Method and device for expanding public service logic of domain entity
CN112051996B (en) * 2020-08-18 2023-09-29 远光软件股份有限公司 Modeling method and device based on development platform element unified naming dictionary
CN113204329B (en) * 2021-03-19 2024-06-14 浙江华云信息科技有限公司 Control method for unified data model driving business application and application system thereof
CN113253983B (en) * 2021-05-14 2024-04-02 上海理工大学 Discrete industry network collaborative manufacturing platform modeling method and system based on drive design

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102750145A (en) * 2012-06-05 2012-10-24 怯肇乾 Network system software system framework and implementation method thereof
CN108073393A (en) * 2018-01-18 2018-05-25 山东浪潮通软信息科技有限公司 A kind of storage design method based on EF frames

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10621166B2 (en) * 2017-03-23 2020-04-14 International Business Machines Corporation Interactive dialog in natural language using an ontology

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102750145A (en) * 2012-06-05 2012-10-24 怯肇乾 Network system software system framework and implementation method thereof
CN108073393A (en) * 2018-01-18 2018-05-25 山东浪潮通软信息科技有限公司 A kind of storage design method based on EF frames

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
"基于领域驱动设计的应用***模型";李引,袁峰;《计算机工程与应用》;20130515;第1-8页 *

Also Published As

Publication number Publication date
CN109947422A (en) 2019-06-28

Similar Documents

Publication Publication Date Title
CN109947422B (en) Business entity implementation method and system based on domain-driven design
US10866791B2 (en) Transforming non-Apex code to Apex code
CN108027722B (en) Dynamically updating applications in compilation and deployment
US20190073227A1 (en) Service model-oriented software system and operation method thereof
CN103365646B (en) Form user-defined, logical definition and processing method based on script engine
US8095570B2 (en) Decorated model architecture for efficient model-driven application development
CN114096956A (en) Method and device for representing database operation layer
CN107766526B (en) Database access method, device and system
WO2004109507A1 (en) System and method for generator state object validation
CN110989976A (en) Web application componentization development method based on J2EE, storage medium and electronic device
US20040250258A1 (en) System and method for rule based object navigation
US20130151571A1 (en) Interface defined virtual data fields
CN105447051A (en) Database operation method and device
CN111782211B (en) Dynamic generation method and device for parameter page based on Vue component
CN114327481A (en) Code processing method, device, equipment and storage medium
US11176314B2 (en) XML schema description code generator
US20040064804A1 (en) Generation of partitioned enterprise application using a high-level specification
WO2015196524A1 (en) Software upgrade processing method and device, terminal and server
EP1634166B1 (en) System and method for incremental object generation
CN114911541A (en) Configuration information processing method and device, electronic equipment and storage medium
US20040249823A1 (en) System and method for object navigation grammar completion
CN112558941A (en) DDD-based micro-service request processing method, system, device and medium
US20040249940A1 (en) System and method for asynchronous resource management
CN113032468A (en) Data writing method, device and computer readable storage medium
CN117742695B (en) Method for simplifying visual configuration of low-code component

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant