Disclosure of Invention
In view of this, the present invention provides a page construction method and device, which implement automatic extraction of page attributes and binding of page objects, and implement a full-automatic process of constructing a page to a database.
In order to achieve the above purpose, the invention provides the following specific technical scheme:
a page construction method, comprising:
opening a page designer, dynamically setting page layout elements according to business requirements, and converting the set page file into an XML file for storage;
opening a data model designer, and creating a data model in a self-defined form;
extracting a page service object in the XML file, and setting table field attribute information of the data model according to the extracted page service object;
and storing and persisting the data model to complete page construction.
Optionally, the dynamically setting the page layout element according to the service requirement includes:
newly building a form page;
and dynamically setting the page layout elements in the form page in a mode of dragging the page layout elements according to the business requirements.
Optionally, the creating a data model in a customized form includes:
and creating a data model, and recording basic information of the data model in the data model.
Optionally, the extracting the page service object in the XML file includes:
reading the XML file;
analyzing the XML file according to the page construction source code of the XML file, traversing the XML file according to a specific service type, and extracting a page service object in the XML file;
and carrying out duplication elimination treatment on the extracted page business object to obtain the duplicated page business object.
Optionally, before saving and persisting the data model, the method further includes:
and setting the table field attribute information of the data model in a self-defined mode.
Optionally, before saving and persisting the data model, the method further includes:
calling an attribute dictionary, and matching the table field attribute Chinese name in the data model with the table field attribute Chinese name in the attribute dictionary;
if the Chinese name of the table field attribute is matched, backfilling the English name of the table field attribute matched in the attribute dictionary into an attribute list of the data model;
and if the Chinese name of the table field attribute cannot be matched, maintaining the attribute dictionary, and adding the Chinese name which is not matched with the table field attribute, and the English name and the dictionary maintenance information corresponding to the Chinese name into the attribute dictionary.
Optionally, the saving and persisting the data model includes:
saving the data model to a database;
and generating a table building statement according to the table field attribute information of the data model, and creating a data table in a database according to the table building statement.
A page construction apparatus comprising:
the page design unit is used for opening a page designer, dynamically setting page layout elements according to business requirements, and converting the set page file into an XML file for storage;
the data model creating unit is used for opening a data model designer and creating a data model in a self-defined form;
the data model setting unit is used for extracting the page business object in the XML file and setting the table field attribute information of the data model according to the extracted page business object;
and the data model persistence unit is used for storing and persisting the data model to complete the page construction.
Optionally, the page design unit is specifically configured to create a new form page; and dynamically setting the page layout elements in the form page in a mode of dragging the page layout elements according to the business requirements.
Optionally, the data model creating unit is specifically configured to create a data model, and enter basic information of the data model into the data model.
Optionally, the data model setting unit includes:
the page business object extraction subunit is used for reading the XML file; analyzing the XML file according to the page construction source code of the XML file, traversing the XML file according to a specific service type, and extracting a page service object in the XML file; and carrying out duplication elimination treatment on the extracted page business object to obtain the duplicated page business object.
Optionally, the apparatus further comprises:
and the custom data model setting unit is used for setting the table field attribute information of the data model in a custom mode.
Optionally, the apparatus further comprises:
the table field attribute matching unit is used for calling an attribute dictionary and matching the table field attribute Chinese name in the data model with the table field attribute Chinese name in the attribute dictionary; if the Chinese name of the table field attribute is matched, backfilling the English name of the table field attribute matched in the attribute dictionary into an attribute list of the data model; and if the Chinese name of the table field attribute cannot be matched, maintaining the attribute dictionary, and adding the Chinese name which is not matched with the table field attribute, and the English name and the dictionary maintenance information corresponding to the Chinese name into the attribute dictionary.
Optionally, the data model persistence unit is specifically configured to store the data model in a database; and generating a table building statement according to the table field attribute information of the data model, and creating a data table in a database according to the table building statement.
Compared with the prior art, the invention has the following beneficial effects:
according to the page construction method and device, the page service object is automatically extracted, the table field attribute information of the data model is set according to the page service object, the table field attribute information of the data model does not need to be manually set, and the error rate of manually establishing the data model is reduced. And the table field attribute of the data model is set by automatically extracting the page business object, so that the automatic binding of the page business object and the data model is realized, and the persistence from the page construction to the database is completely and automatically completed, so that the page construction is more efficient and stable, and the later operation and maintenance are facilitated.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment discloses a page construction method, which is applied to a software development tool, the software development work can run with a server or a mobile terminal, a page designer, a data model designer and a database are integrated, specifically, please refer to fig. 1, the page construction method realizes dynamic setting of page layout elements in the page designer, converts a set page file into an XML file for storage, the XML file comprises a page construction source code, then creates a data model in the data model designer, extracts a page service object by analyzing the page construction source code in the XML file, and sets table field attribute information of the data model according to the extracted page service object, thereby realizing binding of the page service object and the data model. And then storing and persisting the data model, completing page construction, running the page and checking the page running effect. The page construction method disclosed by the embodiment realizes the automatic completion of the page construction to the database persistence, so that the page construction is more efficient and stable, and the later operation and maintenance are facilitated.
Specifically, referring to fig. 2, the page construction method specifically includes the following steps:
s101: opening a page designer, dynamically setting page layout elements according to business requirements, and converting the set page file into an XML file for storage;
specifically, after the page designer is opened, a form page needs to be newly created, and in a visual interface of the page designer, page layout elements are dynamically set in the form page in a manner of dragging the page layout elements according to business requirements.
And the design function of the page designer converts the set page file into an XML file for storage.
S102: opening a data model designer, and creating a data model in a self-defined form;
in a visual interface of a data model designer, a data model is created in a self-defined mode, and basic information of the data model, such as Chinese name of a table, English name of the table, description of the table and the like, is input.
S103: extracting a page service object in the XML file, and setting table field attribute information of the data model according to the extracted page service object;
specifically, referring to fig. 3, the method for extracting a page service object in an XML file includes the following steps:
s201: reading the XML file;
s202: analyzing the XML file according to the page construction source code of the XML file, traversing the XML file according to a specific service type, and extracting a page service object in the XML file;
s203: and carrying out duplication elimination treatment on the extracted page business object to obtain the duplicated page business object.
The XML file structure is integrally distributed by < div > </div > layer tags, the outmost layer is page layout, layout attributes are set, page elements are arranged in the middle of the layout, and the custom attributes are used for storing element related attribute setting and style setting. The rcpName in the element attribute is the business object display attribute, rcpStyle is the element type.
In the process of extracting the page object, firstly, reading a page source code XML; secondly, analyzing the page source code XML, traversing according to a specific service type (such as rcpStype: "type: DataLabel"), extracting the page service object, temporarily storing the page service object in a cache page object set, and finally, removing the duplication of the page service object in the set.
It should be further noted that the table field attribute information of the data model may also be set in a manner of customizing the table field attribute, and the table field attribute information may be customized by adding a row, deleting a row, moving up, moving down, and other functional keys in the attribute list.
Extracting a page service object in an XML file and setting the field attribute of a table in a user-defined way, wherein the two ways of setting the field attribute of the table need to maintain the information of Name (Chinese Name), Code (English Name), Comment (Comment or description), Domain (field for defining standard Data Type), Data Type, primary key, foreign key and the like in the list.
S104: and storing and persisting the data model to complete page construction.
Specifically, the data model is stored, that is, information of the data model is stored in a database so as to be maintained and used. And the persistent data model is used for generating a table building statement according to the table field attribute information of the data model and creating a data table in a database according to the table building statement for service operation.
Further, when the page construction is completed, the page file created in S101 is clicked, page preview or transmission is clicked, and the page operation effect can be viewed.
As a preferred implementation manner of this embodiment, in the page construction method disclosed in this embodiment, before saving and persisting the data model, a property dictionary is called, and the table field property chinese name in the data model is matched with the table field property chinese name in the property dictionary. Referring to fig. 4, the method specifically includes the following steps:
s301: calling an attribute dictionary, and matching the table field attribute Chinese name in the data model with the table field attribute Chinese name in the attribute dictionary;
s302: judging whether the Chinese name of each table field in the data model is matched with the Chinese name of the table field attribute in the attribute dictionary;
if so, executing S303: backfilling English names of the table field attributes matched in the attribute dictionary into an attribute list of the data model;
if not, go to step S304: and maintaining the attribute dictionary, and adding Chinese names which are not matched with the attributes of the table fields, English names corresponding to the Chinese names and dictionary maintenance information into the attribute dictionary.
The data dictionary is an attribute library which is continuously increased and maintained in the service process, a base is initialized or an empty library is provided in advance for the system, and the data dictionary is continuously perfect and abundant in the data model establishing process, so that secondary multiplexing is facilitated. The data dictionary comprises Chinese names, English names (including English full names and English short names), service classification, data states, creators, dates and other information of table field attributes.
The function purpose of the attribute dictionary is to keep the consistency of creating the attribute of the Code column of the table field in the modeling process of the data model, the attribute dictionary is continuously maintained and used in creating the attribute of the table field, in the attribute function of the maintenance table field, the system automatically matches the Name attribute column of the attribute dictionary according to the Name attribute column of the table field through the attribute matching function, matched Code information is backfilled into the attribute list, the field attribute which is not successfully matched can be maintained in the attribute list, and the attribute dictionary is maintained through adding the dictionary function so as to be reused, thereby improving the flexibility of data modeling, unifying the Code attribute in the data model and increasing the readability of the service.
Referring to fig. 5, the present embodiment discloses a page constructing method based on the foregoing embodiments, and correspondingly discloses a page constructing apparatus, including:
the page design unit 401 is configured to open a page designer, dynamically set page layout elements according to service requirements, and convert a set page file into an XML file for storage;
a data model creation unit 402, configured to open a data model designer and create a data model in a customized form;
a data model setting unit 403, configured to extract a page service object in the XML file, and set table field attribute information of the data model according to the extracted page service object;
and a data model persistence unit 404, configured to store and persist the data model to complete page construction.
Optionally, the page design unit 401 is specifically configured to create a new form page; and dynamically setting the page layout elements in the form page in a mode of dragging the page layout elements according to the business requirements.
Optionally, the data model creating unit 402 is specifically configured to create a data model, and enter basic information of the data model into the data model.
Optionally, the data model setting unit 403 includes:
the page business object extraction subunit is used for reading the XML file; analyzing the XML file according to the page construction source code of the XML file, traversing the XML file according to a specific service type, and extracting a page service object in the XML file; and carrying out duplication elimination treatment on the extracted page business object to obtain the duplicated page business object.
Optionally, the apparatus further comprises:
and the custom data model setting unit is used for setting the table field attribute information of the data model in a custom mode.
Optionally, the data model persistence unit 404 is specifically configured to store the data model in a database; and generating a table building statement according to the table field attribute information of the data model, and creating a data table in a database according to the table building statement.
According to the page construction device disclosed by the embodiment, the page service object is automatically extracted, and the table field attribute information of the data model is set according to the page service object, so that the table field attribute information of the data model does not need to be manually set, and the error rate of manually establishing the data model is reduced. And the table field attribute of the data model is set by automatically extracting the page business object, so that the automatic binding of the page business object and the data model is realized, and the persistence from the page construction to the database is completely and automatically completed, so that the page construction is more efficient and stable, and the later operation and maintenance are facilitated.
On the basis of the above embodiments, referring to fig. 6, the present embodiment discloses another page structure apparatus, which specifically includes:
the page design unit 501 is used for opening a page designer, dynamically setting page layout elements according to business requirements, and converting the set page file into an XML file for storage;
a data model creation unit 502, configured to open a data model designer and create a data model in a customized form;
a data model setting unit 503, configured to extract a page service object in the XML file, and set table field attribute information of the data model according to the extracted page service object;
a table field attribute matching unit 504, configured to invoke an attribute dictionary, and match a table field attribute chinese name in the data model with a table field attribute chinese name in the attribute dictionary; if the Chinese name of the table field attribute is matched, backfilling the English name of the table field attribute matched in the attribute dictionary into an attribute list of the data model; if the Chinese name of the table field attribute can not be matched, maintaining the attribute dictionary, and adding the Chinese name which is not matched with the table field attribute, and the English name and the dictionary maintenance information corresponding to the Chinese name which are not matched with the table field attribute into the attribute dictionary;
and a data model persistence unit 505, configured to store and persist the data model to complete page construction.
The page construction device disclosed by the embodiment automatically matches the Chinese name of the table field with the Chinese name of the table field in the attribute dictionary by adding the table field attribute matching unit, backfills the English name of the matched table field attribute in the attribute list, can maintain the field attribute which is not successfully matched in the attribute list, and maintains the attribute dictionary by adding the dictionary function so as to reuse the English name again, thereby improving the flexibility of data modeling, unifying the English name of the table field attribute in the data model and increasing the readability of the service.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.