Nothing Special   »   [go: up one dir, main page]

CN115599359A - Code generation method, device, equipment and medium - Google Patents

Code generation method, device, equipment and medium Download PDF

Info

Publication number
CN115599359A
CN115599359A CN202211339209.1A CN202211339209A CN115599359A CN 115599359 A CN115599359 A CN 115599359A CN 202211339209 A CN202211339209 A CN 202211339209A CN 115599359 A CN115599359 A CN 115599359A
Authority
CN
China
Prior art keywords
file
interface
fields
developed
code generation
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.)
Pending
Application number
CN202211339209.1A
Other languages
Chinese (zh)
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.)
China Construction Bank Corp
CCB Finetech Co Ltd
Original Assignee
China Construction Bank Corp
CCB Finetech 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 China Construction Bank Corp, CCB Finetech Co Ltd filed Critical China Construction Bank Corp
Priority to CN202211339209.1A priority Critical patent/CN115599359A/en
Publication of CN115599359A publication Critical patent/CN115599359A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application relates to the technical field of interface development, in particular to a code generation method, a device, equipment and a medium, which are used for solving the problems of low development efficiency and difficult subsequent code maintenance of the traditional interface development scheme. The method comprises the following steps: responding to code generation operation aiming at the first control, calling a code generation tool corresponding to the first control, analyzing the configuration file of the interface to be developed, and obtaining each field contained in the configuration file and the logic relationship among the fields; generating a target file and a test file corresponding to the interface to be developed based on each field and the logical relationship among the fields, wherein the target file comprises at least one of a configuration file and an application file of the interface to be developed; therefore, the development efficiency can be improved, the labor cost is reduced, joint debugging of the front-end interface and the rear-end interface can be performed in advance, the consistency of the developed code formats is ensured, and subsequent code maintenance is facilitated.

Description

Code generation method, device, equipment and medium
Technical Field
The present application relates to the field of interface development technologies, and in particular, to a code generation method, apparatus, device, and medium.
Background
In a conventional interface development scheme, a configuration file (e.g., an Excel interface configuration file) of an interface to be developed is usually pre-compiled, then a matched data dictionary is searched according to fields in the configuration file, and then a data structure is compiled to perform message conversion configuration, thereby completing the development of the interface.
For the above traditional interface development scheme, there are many repetitive operations in the process of generating codes based on configuration files, such as a search process of searching each field in a configuration file from a data dictionary, a process of writing a data structure for the same field, and the like, so that the development efficiency of interface development is low; moreover, the same function may be written by different developers, and the individual writing style of each developer usually has differences, which leads to the problems that the finally written code is difficult to maintain, and even the interface formats corresponding to the front end and the back end are not matched.
Disclosure of Invention
The embodiment of the application provides a code generation method, a device, equipment and a medium, which are used for solving the problems of low development efficiency and difficult subsequent code maintenance of the traditional interface development scheme.
In a first aspect, the present application provides a code generation method, including:
responding to code generation operation aiming at a first control, calling a code generation tool corresponding to the first control, analyzing the configuration file of the interface to be developed, and obtaining each field contained in the configuration file and the logic relationship among the fields;
and generating a target file and a test file corresponding to the interface to be developed based on the fields and the logical relationship among the fields, wherein the target file comprises at least one of a configuration file and an application file of the interface to be developed.
In a possible embodiment, the analyzing the configuration file of the interface to be developed to obtain each field included in the configuration file and a logical relationship between the fields includes:
analyzing the configuration file of the interface to be developed line by line to obtain each field;
and respectively obtaining the logical relationship among the fields based on the hierarchical relationship of the fields in the configuration file.
In a possible embodiment, the generating a target file and a test file corresponding to the interface to be developed based on the fields and the logical relationship between the fields includes:
constructing a logic data structure based on the logic relationship among the fields;
filling each field into the logic data structure according to a preset rule;
respectively determining missing fields corresponding to the fields based on a data dictionary corresponding to the code generation tool, and respectively supplementing the missing fields into the logic data structure;
and generating a target file and a test file corresponding to the interface to be developed based on the supplemented logic data structure.
In a possible embodiment, the generating a target file and a test file corresponding to the interface to be developed based on the supplemented logical data structure includes:
generating a logic structure view file corresponding to the interface to be developed based on the supplemented logic data structure;
and generating a target file and a test file corresponding to the interface to be developed by respectively using the code templates included by the code generation tool based on the logic structure view file, wherein the code templates are compiled based on a preset coding language.
In one possible embodiment, each field is at least one of a request message field, a response message field; in the configuration file, the format of the data composition corresponding to each request message field and each response message field is the same.
In a possible embodiment, after the generating the target file and the test file corresponding to the interface to be developed based on the fields and the logical relationship between the fields, the method further includes:
responding to actual measurement operation aiming at a second control, and loading an actual measurement file corresponding to the interface to be developed, wherein the actual measurement file is a code file obtained after application logic in the application file is adjusted;
and calling the test file to test the actual measurement file, and outputting abnormal prompt information based on a test result, wherein the abnormal prompt information is used for prompting to modify any application logic.
In a second aspect, the present application provides a code generation apparatus, comprising:
the analysis module is used for responding to code generation operation aiming at a first control, calling a code generation tool corresponding to the first control, and analyzing the configuration file of the interface to be developed to obtain each field contained in the configuration file and the logic relationship among the fields;
and the code generation module is used for generating a target file and a test file corresponding to the interface to be developed based on the fields and the logical relationship among the fields, wherein the target file comprises at least one of a configuration file and an application file of the interface to be developed.
In a possible embodiment, the parsing module is specifically configured to:
analyzing the configuration file of the interface to be developed line by line to obtain each field;
and respectively obtaining the logical relationship among the fields based on the hierarchical relationship of the fields in the configuration file.
In a possible embodiment, the code generation module is specifically configured to:
constructing a logic data structure based on the logic relationship among the fields;
filling each field into the logic data structure according to a preset rule;
respectively determining missing fields corresponding to the fields based on a data dictionary corresponding to the code generation tool, and respectively supplementing the missing fields into the logic data structure;
and generating a target file and a test file corresponding to the interface to be developed based on the supplemented logic data structure.
In a possible embodiment, the code generation module is specifically configured to:
generating a logic structure view file corresponding to the interface to be developed based on the supplemented logic data structure;
and generating a target file and a test file corresponding to the interface to be developed by respectively using the code templates included by the code generation tool based on the logic structure view file, wherein the code templates are compiled based on a preset coding language.
In one possible embodiment, each field is at least one of a request message field, a response message field; in the configuration file, the format of the data composition corresponding to each request message field and each response message field is the same.
In one possible embodiment, the code generation module is further configured to:
after the target file and the test file corresponding to the interface to be developed are generated based on the fields and the logical relationship among the fields, responding to actual measurement operation aiming at a second control, and loading the actual measurement file corresponding to the interface to be developed, wherein the actual measurement file is a code file after the application logic in the application file is adjusted;
and calling the test file to test the actual measurement file, and outputting abnormal prompt information based on a test result, wherein the abnormal prompt information is used for prompting to modify any application logic.
In a third aspect, the present application provides an electronic device, comprising:
a memory for storing program instructions;
a processor for calling the program instructions stored in the memory and executing the steps comprised in any one of the methods of the first aspect in accordance with the obtained program instructions.
In a fourth aspect, the present application provides a computer readable storage medium having stored thereon a computer program comprising program instructions which, when executed by a computer, cause the computer to perform the method of any one of the first aspects.
In a fifth aspect, the present application provides a computer program product comprising: computer program code which, when run on a computer, causes the computer to perform the method of any one of the first aspects.
In the embodiment of the application, in response to a code generation operation for a first control, a code generation tool corresponding to the first control is called, and a configuration file of an interface to be developed is analyzed to obtain each field contained in the configuration file and a logic relationship between each field; then, generating a target file and a test file corresponding to the interface to be developed based on each field and the logical relationship among the fields, wherein the target file comprises at least one of a configuration file and an application file of the interface to be developed; therefore, the target file and the test file of the interface to be developed can be quickly generated through the code generation tool corresponding to the first control, so that the development efficiency is improved, the labor cost is reduced, and the error rate of the code file is also reduced; meanwhile, the uniform writing style of the code lyric can be realized, and the follow-up code maintenance is convenient. Furthermore, in the interface development process, joint debugging of the front-end interface and the back-end interface can be performed in advance through the request message field and the response message field included in the configuration file, so that the format consistency of the developed code file is ensured, and the subsequent code actual measurement and code maintenance are facilitated.
Drawings
Fig. 1 is a flowchart of a code generation method provided in an embodiment of the present application;
fig. 2 is a flowchart of a method for parsing a configuration file according to an embodiment of the present application;
fig. 3 is a flowchart of a method for generating a target file and a test file according to an embodiment of the present disclosure;
fig. 4 is a flowchart of a specific method for generating a target file and a test file according to an embodiment of the present application;
fig. 5 is a flowchart of a method for testing a measured file according to an embodiment of the present application;
FIG. 6 is a flowchart illustrating an overall method for generating code according to an embodiment of the present disclosure;
fig. 7 is a block diagram of a code generation apparatus according to an embodiment of the present application;
fig. 8 is a structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions in the embodiments of the present application will be described clearly and completely with reference to the accompanying drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, 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 application. In the present application, the embodiments and features of the embodiments may be arbitrarily combined with each other without conflict. Also, while a logical order is shown in the flow diagrams, in some cases, the steps shown or described may be performed in an order different than here.
The terms "first" and "second" in the description and claims of the present application and the above-described drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the term "comprises" and any variations thereof, which are intended to cover non-exclusive protection. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus. The "plurality" in the present application may mean at least two, for example, two, three or more, and the embodiments of the present application are not limited.
In the technical scheme, the data acquisition, transmission, use and the like meet the requirements of relevant national laws and regulations.
Before describing the code generation method provided in the embodiments of the present application, for ease of understanding, the following detailed description will first be made on the technical background of the embodiments of the present application.
In a conventional interface development scheme, an Excel interface configuration file is generally defined for an interface to be developed in advance, then a matched data dictionary is searched for according to each field in the Excel interface configuration file, a data structure of each field is compiled, message conversion configuration or Structured Query Language (SQL) configuration is performed, then an interface configuration file, an interface implementation class, a corresponding Extensible Markup Language (XML) file and the like are compiled, and thus, the development work of the interface is completed.
However, in the above conventional interface development scheme, there are many repetitive operations in the process of generating codes based on the Excel interface configuration file, such as a search process of searching each field in the Excel interface configuration file from the data dictionary; the development efficiency of the interface is low because the compiling process of repeatedly compiling the data structure and the message conversion configuration process are carried out for the same field.
In practical application, in one scenario, the front-end application needs to call the back-end interface to realize service logic; in another scenario, the backend application needs to obtain the required data by calling the front-end interface. In the interface development process, the front end and the back end are usually developed separately, the same or similar functions of the front end interface and the back end interface may be written by different developers, and the code lyric writing style of each developer often differs, which results in different generated code styles. If an abnormal condition occurs under the code test condition, the front-end code and the back-end code of the interface are usually required to be checked word by word and segment by segment, so that the workload of code checking is increased, the development efficiency of the interface is further reduced, and even the packaging, starting and deployment of the whole service related to the interface are influenced.
In view of this, in order to solve the problems of low development efficiency and difficulty in subsequent code maintenance in the conventional interface development scheme, an embodiment of the present application provides a code generation method, where in the embodiment of the present application, a code generation tool corresponding to a first control is called in response to a code generation operation for the first control, and a configuration file of an interface to be developed is analyzed to obtain fields included in the configuration file and a logical relationship between the fields; then, generating a target file and a test file corresponding to the interface to be developed based on each field and the logical relationship among the fields, wherein the target file comprises at least one of a configuration file and an application file of the interface to be developed; therefore, the configuration file and/or the application file of the interface to be developed can be quickly generated through the code generating tool corresponding to the first control, so that the interface development efficiency is improved, the labor cost is reduced, and meanwhile, the code lyric style can be unified due to the adoption of the same code generating tool, so that the follow-up code maintenance is facilitated.
Some simple descriptions are given below to application scenarios to which the technical solution of the embodiment of the present application can be applied, and it should be noted that the application scenarios described below are only used for describing the embodiment of the present application and are not limited. In specific implementation, the technical scheme provided by the embodiment of the application can be flexibly applied according to actual needs.
The code generation method provided by the embodiment of the application can be applied to a terminal, a server side and software running in the terminal or the server side. In some embodiments, the terminal may be a smartphone, tablet, laptop, desktop computer, smart watch, or the like; the server side can be configured as an independent physical server, or a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as cloud service, a cloud database, cloud computing, cloud functions, cloud storage, network service, cloud communication, middleware service, domain name service, security service, content Delivery Network (CDN) and a big data and artificial intelligence platform; the software may be an application or the like implementing a code generation method, but is not limited to the above form.
To further explain the technical solutions provided by the embodiments of the present application, the technical solutions provided by the embodiments of the present application will be described in detail below with reference to the accompanying drawings. It is to be understood that the preferred embodiments described herein are for purposes of illustration and explanation only and are not intended to limit the present application, and that the features of the embodiments and examples of the present application may be combined with one another without conflict.
Fig. 1 is a flowchart of a code generation method according to an embodiment of the present application, and please refer to fig. 1.
In step 101, in response to a code generation operation for the first control, a code generation tool corresponding to the first control is called, and a configuration file of the interface to be developed is analyzed to obtain fields included in the configuration file and a logical relationship between the fields.
In the embodiment of the present application, before executing step 101, a developer pre-compiles the configuration file, where the configuration file includes interface purpose description information of an interface to be developed, a request packet, and a response packet, where the request packet includes a plurality of request packet fields, and the response packet includes at least one response packet field; in the same configuration file, the format of the data composition corresponding to each request message field and each response message field is the same, for example, each field includes a field item name, a Chinese name, a data item number, an XML input length, a field attribute, and the like.
In the embodiment of the application, the configuration file may be an Excel interface configuration file, and a developer defines interface use description information corresponding to an interface to be developed, a request message and a response message by compiling the Excel interface configuration file in advance, where the request message includes each request message field of the interface to be developed and a logical relationship between each request message field, for example, the logical relationship between the request message field 1 and the request message field 2 is that the request message field 2 is the next stage of the request message field 1; the logical relationship between the request message field 2 and the request message field 3 is that the request message field 2 and the request message field 3 are in the same level.
Then, after the configuration file is prepared, the issuers perform a code generation operation on the first control, so that the device performs step 101 in response to the code generation operation.
In some embodiments, referring to fig. 2, when step 101 is executed, the following steps are specifically executed:
in step 1011, the configuration file of the interface to be developed is parsed line by line to obtain each field.
In step 1012, the logical relationship between the fields is obtained based on the hierarchical relationship of the fields in the configuration file.
In this embodiment, in step 1011, if the configuration file includes a plurality of pages, the configuration file is parsed page by page, and when each page is parsed, the configuration file is parsed line by line.
For example, the configuration file of the interface to be developed is taken as an Excel interface configuration file.
Suppose an Excel interface configuration file representation is shown in the following table:
table Excel interface configuration file example table
Figure BDA0003915792750000091
The "in the above table is used to characterize the hierarchical relationship of each field in the configuration file, and if the fields 1 and 2 are not preceded by the" a ", and the field attribute of the field 1 is" C ", it indicates that the field corresponding to the field 1 and the field corresponding to the field 2 are located at the same level; no "-", a "-", and a "-", are preceded by a field 3, and the field attribute of the field 2 is "GROUP", then the field corresponding to the field 3 is the next level of the field corresponding to the field 2; the "data item number" in the above table represents the specific position of the corresponding data information of the field in the data dictionary.
Then, after receiving a code generation operation for the first control, calling a code generation tool corresponding to the first control, and analyzing the Excel interface configuration file line by line to obtain each field; the data in a row in the table corresponds to a field, and each field is at least one of a request message field and a response message field.
In this embodiment of the application, when step 1102 is executed, the logical relationship between the fields is obtained based on the hierarchical relationship of the fields in the configuration file, that is, ". And the field attributes in the table above.
In step 102, a target file and a test file corresponding to the interface to be developed are generated based on the fields and the logical relationship between the fields, wherein the target file includes at least one of a configuration file and an application file of the interface to be developed.
In the embodiment of the present application, referring to fig. 3, when step 102 is executed, the following steps are specifically executed:
at step 1021, a logical data structure is constructed based on the logical relationships between the various fields.
In a specific implementation, when step 1021 is executed, a corresponding logical data structure is constructed based on the logical relationship between the fields, and for example, if the field attribute corresponding to field 1 is "GROUP", a list (list) structure is set for field 1 in the logical data structure.
In step 1022, the fields are populated into the logical data structure according to preset rules.
In the embodiment of the present application, after the logical data structure is constructed in step 1021, each field is filled in the logical data structure based on a preset rule in the data dictionary corresponding to the code generation tool.
In step 1023, missing fields corresponding to the respective fields are determined based on the data dictionary corresponding to the code generation tool, and the missing fields are supplemented into the logical data structure.
In practice, it usually happens that all fields required for the subsequent code generation are not contained in the predefined configuration file, so after the step 1022 is executed, the step 1023 is executed to obtain each missing field based on the data dictionary, and then the missing fields are supplemented into the logical data structure.
In step 1024, based on the supplemented logical data structure, a target file and a test file corresponding to the interface to be developed are generated.
In the embodiment of the present application, referring to fig. 4, when step 1024 is executed, the following steps are specifically executed:
in step 401, based on the supplemented logical data structure, a logical structure view file corresponding to the interface to be developed is generated.
Wherein the logical structure view file contains a complete input output logical view.
In step 402, based on the logical structure view file, a target file and a test file corresponding to the interface to be developed are generated by using the code templates included in the code generation tool, respectively, where the code templates are compiled based on a preset coding language.
The format of the code template includes but is not limited to Java, excel, and the like.
In a specific implementation, after the step 102 is executed, the target file and the test file of the interface to be developed are obtained, at this time, the basic development work of the interface to be developed is completed, and then the actual measurement link is entered. Before actual measurement, adaptive adjustment is further performed on application logic and an operating environment in an application file included in a target file, that is, partial or all application logic of the application file included in the target file is adjusted to obtain an actual measurement file used in the actual measurement (which may be an interface code file used in an actual application scenario), please refer to fig. 5.
In step 501, in response to the actual measurement operation on the second control, an actual measurement file corresponding to the interface to be developed is loaded, where the actual measurement file is a code file after the application logic in the application file is adjusted.
In this embodiment of the application, after the developer performs the actual measurement operation on the second control, step 501 is performed, and the actual measurement file is loaded in response to the actual measurement operation.
In step 502, a test file is called to test the actual measurement file, and an exception prompting message is output based on the test result, where the exception prompting message is used to prompt modification of any application logic.
For example, the configuration file of the interface to be developed is still taken as an Excel interface configuration file as an example.
It is still assumed that the Excel interface configuration file is as shown in the aforementioned table.
Then, referring to fig. 6, the overall flow of the code generation method provided in the present application is as follows:
in step 601, in response to the code generation operation for the first control, a code generation tool corresponding to the first control is called, and the configuration file of the interface to be developed is analyzed line by line to obtain each field.
Wherein the first control characterizes an online service.
In step 602, a logical relationship between the fields is obtained based on the hierarchical relationship of the fields in the configuration file.
In step 603, a logical data structure is constructed based on the logical relationships between the various fields.
In step 604, the fields are filled into the logical data structure according to preset rules.
In step 605, based on the data dictionary corresponding to the code generation tool, the missing fields corresponding to the respective fields are determined, and the missing fields are supplemented into the logical data structure.
In step 606, a logical structure view file corresponding to the interface to be developed is generated based on the supplemented logical data structure.
In step 607, based on the logical structure view file, the target file and the test file corresponding to the interface to be developed are generated by using the code template included in the code generation tool, where the target file includes at least one of a configuration file and an application file of the interface to be developed.
In this embodiment of the application, assuming that the developer performs application logic adjustment on the application file in the target file after obtaining the target file and the test file to obtain an actual measurement file, and performs an actual measurement operation on the second control, the process goes to step 608.
In step 608, in response to the actual measurement operation on the second control, the actual measurement file corresponding to the interface to be developed is loaded, where the actual measurement file is a code file after the application logic in the application file is adjusted.
In step 609, the test file is called to test the actual measurement file, and an exception prompting message is output based on the test result, wherein the exception prompting message is used for prompting to modify any application logic.
After the logical structure view file corresponding to the interface to be developed is obtained based on the fields and the logical relationship between the fields in step 607, the mapping from the fields to the codes can be implemented by using a tool for generating mapping codes by using a data dictionary in step 607, so that the above functions of generating the target file and the test file corresponding to the interface to be developed based on the logical structure view file are implemented. The generated target file comprises at least one of a View Object (VO) related code file, a service interface implementation class file, a registration service configuration file and a mapping message; the generated test file comprises at least one of a test code and test data, and the test file can be an http-client debugging simulation message and the like.
In the embodiment of the present application, the code generation tool may be a data service layer code generation tool, an outbound service code generation tool, or an online service code generation tool (as shown in the Excel interface configuration file). Accordingly, for the data service layer code generation tool, the generated target file may include at least one of a Portable Object (PO) file, a Disk Operating System (DOS) file, and an XML file corresponding to ibatis, and the generated test file may be a DOSTest file. For the outbound service code generation tool, the generated target file may include at least one of a VO-related code file, an outbound service interface implementation class file, and a mapping message, and the generated test file may be an outbound test message, and the like.
In the embodiment of the present application, the running processes of other types of code generation tools and the online service code generation tool are similar to that described above, and are not described herein again.
It should be noted that, in the embodiment of the present application, the specific representation forms of the target document and the test document are only examples, and the specific document forms and document types are not specifically limited in the embodiment of the present application.
In this embodiment of the present application, the response packet of the interface to be developed, which is included in the configuration file of the interface to be developed, is further used for docking front-end logic development.
Therefore, by calling the code generation tool, the code file can be quickly and automatically generated, and the code generation speed is increased, so that the development efficiency of interface development is improved, and the error rate of the target file is reduced; meanwhile, as the target file and the test file are generated by calling the code generating tool, the writing styles of the codes can be unified, thereby facilitating the maintenance of the subsequent codes. Furthermore, in the interface development process, joint debugging of the front-end interface and the back-end interface can be performed in advance by standardizing the data format of the configuration file (such as the format formed by the data of the request message and the data of the response message), so that the code formats of the front-end interface and the back-end interface are ensured to be consistent, the maintenance difficulty of subsequent codes is further reduced, and the maintenance efficiency of the subsequent codes is improved.
In some feasible embodiments, the code generation method provided by the application can also enable the code generation operation environment to be more flexible, namely, the configuration file is imported into the integrated equipment, and the integrated equipment can directly run the code generation tool to generate the required target file and the required test file, so that the development efficiency is greatly improved.
Based on the same inventive concept, an embodiment of the present application provides a code generating apparatus, referring to fig. 7, the apparatus includes:
the analysis module 701 is configured to, in response to a code generation operation for a first control, invoke a code generation tool corresponding to the first control, analyze the configuration file of the interface to be developed, and obtain each field included in the configuration file and a logical relationship between the fields;
a code generating module 702, configured to generate a target file and a test file corresponding to the interface to be developed based on the fields and the logical relationship between the fields, where the target file includes at least one of a configuration file and an application file of the interface to be developed.
In a possible embodiment, the parsing module 701 is specifically configured to:
analyzing the configuration file of the interface to be developed line by line to obtain each field;
and respectively obtaining the logical relationship among the fields based on the hierarchical relationship of the fields in the configuration file.
In a possible embodiment, the code generation module 702 is specifically configured to:
constructing a logic data structure based on the logic relationship among the fields;
filling each field into the logic data structure according to a preset rule;
respectively determining missing fields corresponding to the fields based on a data dictionary corresponding to the code generation tool, and respectively supplementing the missing fields into the logic data structure;
and generating a target file and a test file corresponding to the interface to be developed based on the supplemented logic data structure.
In a possible embodiment, the code generating module 702 is specifically configured to:
generating a logic structure view file corresponding to the interface to be developed based on the supplemented logic data structure;
and generating a target file and a test file corresponding to the interface to be developed by respectively utilizing a code template included by the code generation tool based on the logic structure view file, wherein the code template is compiled based on a preset coding language.
In one possible embodiment, each field is at least one of a request message field, a response message field; in the configuration file, the format of the data composition corresponding to each request message field and each response message field is the same.
In a possible embodiment, the code generation module 702 is further configured to:
after the target file and the test file corresponding to the interface to be developed are generated based on the fields and the logical relationship among the fields, responding to actual measurement operation aiming at a second control, and loading the actual measurement file corresponding to the interface to be developed, wherein the actual measurement file is a code file after the application logic in the application file is adjusted;
and calling the test file to test the actual measurement file, and outputting abnormal prompt information based on a test result, wherein the abnormal prompt information is used for prompting to modify any application logic.
Based on the same inventive concept, the present application provides an electronic device, which can implement the functions discussed in the foregoing, please refer to fig. 8, which includes one or more processors 801 and a memory 802,
the processor 801 may include one or more Central Processing Units (CPUs), or be a digital processing unit, etc. The processor 801 is configured to implement the code generation method when calling the computer program stored in the memory 802.
A memory 802 for storing computer programs executed by the processor 801. The memory 802 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, programs required for running an instant messaging function, and the like; the storage data area can store various instant messaging information, operation instruction sets and the like.
The memory 802 may be a volatile memory (volatile memory), such as a random-access memory (RAM); the memory 802 may also be a non-volatile memory (non-volatile memory) such as, but not limited to, a read-only memory (rom), a flash memory (flash memory), a Hard Disk Drive (HDD) or a solid-state drive (SSD), or the memory 802 may be any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer. The memory 802 may be a combination of the above.
The specific connection medium between the processor 801 and the memory 802 is not limited in the embodiment of the present application. In the embodiment of the present application, the processor 801 and the memory 802 are connected by a bus 803 in fig. 8, the bus 803 is represented by a thick line in fig. 8, and the connection manner between other components is merely illustrative and is not limited. The bus 803 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 8, but this is not intended to represent only one bus or type of bus.
Based on the same inventive concept, embodiments of the present application provide a computer-readable storage medium, and a computer program product includes: computer program code which, when run on a computer, causes the computer to perform any of the code generation methods as discussed in the foregoing. Since the principle of solving the problem of the computer-readable storage medium is similar to that of the code generation method, the implementation of the computer-readable storage medium can refer to the implementation of the method, and repeated details are not described herein.
Based on the same inventive concept, the embodiment of the present application further provides a computer program product, where the computer program product includes: computer program code which, when run on a computer, causes the computer to perform any of the code generation methods as discussed in the foregoing. Because the principle of solving the problem of the computer program product is similar to the code generation method, the implementation of the computer program product can refer to the implementation of the method, and repeated parts are not described again.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and so forth) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart block or blocks and/or flowchart block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of user-operated steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.

Claims (15)

1. A method of code generation, comprising:
responding to code generation operation aiming at a first control, calling a code generation tool corresponding to the first control, analyzing the configuration file of the interface to be developed, and obtaining each field contained in the configuration file and the logic relationship among the fields;
and generating a target file and a test file corresponding to the interface to be developed based on the fields and the logical relationship among the fields, wherein the target file comprises at least one of a configuration file and an application file of the interface to be developed.
2. The method according to claim 1, wherein the parsing the configuration file of the interface to be developed to obtain the fields included in the configuration file and the logical relationship between the fields includes:
analyzing the configuration file of the interface to be developed line by line to obtain each field;
and respectively obtaining the logical relationship among the fields based on the hierarchical relationship of the fields in the configuration file.
3. The method of claim 2, wherein the generating the target file and the test file corresponding to the interface to be developed based on the fields and the logical relationship between the fields comprises:
constructing a logic data structure based on the logic relationship among the fields;
filling each field into the logic data structure according to a preset rule;
respectively determining missing fields corresponding to the fields based on a data dictionary corresponding to the code generation tool, and respectively supplementing the missing fields into the logic data structure;
and generating a target file and a test file corresponding to the interface to be developed based on the supplemented logic data structure.
4. The method of claim 3, wherein generating the target file and the test file corresponding to the interface to be developed based on the supplemented logical data structure comprises:
generating a logic structure view file corresponding to the interface to be developed based on the supplemented logic data structure;
and generating a target file and a test file corresponding to the interface to be developed by respectively utilizing a code template included by the code generation tool based on the logic structure view file, wherein the code template is compiled based on a preset coding language.
5. The method according to any of claims 1-4, wherein each field is at least one of a request message field, a response message field; in the configuration file, the format of the data composition corresponding to each request message field and each response message field is the same.
6. The method of claim 5, wherein after generating the target file and the test file corresponding to the interface to be developed based on the fields and the logical relationship between the fields, the method further comprises:
responding to actual measurement operation aiming at a second control, and loading an actual measurement file corresponding to the interface to be developed, wherein the actual measurement file is a code file after application logic in the application file is adjusted;
and calling the test file to test the actual measurement file, and outputting abnormal prompt information based on a test result, wherein the abnormal prompt information is used for prompting to modify any application logic.
7. A code generation apparatus, comprising:
the analysis module is used for responding to code generation operation aiming at a first control, calling a code generation tool corresponding to the first control, and analyzing the configuration file of the interface to be developed to obtain each field contained in the configuration file and the logic relationship among the fields;
and the code generation module is used for generating a target file and a test file corresponding to the interface to be developed based on the fields and the logical relationship among the fields, wherein the target file comprises at least one of a configuration file and an application file of the interface to be developed.
8. The apparatus of claim 7, wherein the parsing module is specifically configured to:
analyzing the configuration file of the interface to be developed line by line to obtain each field;
and respectively obtaining the logical relationship among the fields based on the hierarchical relationship of the fields in the configuration file.
9. The apparatus of claim 8, wherein the code generation module is specifically configured to:
constructing a logic data structure based on the logic relationship among the fields;
filling each field into the logic data structure according to a preset rule;
respectively determining missing fields corresponding to the fields based on a data dictionary corresponding to the code generation tool, and respectively supplementing the missing fields into the logic data structure;
and generating a target file and a test file corresponding to the interface to be developed based on the supplemented logic data structure.
10. The apparatus of claim 9, wherein the code generation module is specifically configured to:
generating a logic structure view file corresponding to the interface to be developed based on the supplemented logic data structure;
and generating a target file and a test file corresponding to the interface to be developed by respectively utilizing a code template included by the code generation tool based on the logic structure view file, wherein the code template is compiled based on a preset coding language.
11. The apparatus according to any of claims 7-10, wherein each field is at least one of a request message field, a response message field; in the configuration file, the format of the data composition corresponding to each request message field and each response message field is the same.
12. The apparatus of claim 11, wherein the code generation module is further to:
after the target file and the test file corresponding to the interface to be developed are generated based on the fields and the logical relationship among the fields, responding to actual measurement operation aiming at a second control, and loading the actual measurement file corresponding to the interface to be developed, wherein the actual measurement file is a code file after the application logic in the application file is adjusted;
and calling the test file to test the actual measurement file, and outputting abnormal prompt information based on a test result, wherein the abnormal prompt information is used for prompting to modify any application logic.
13. An electronic device, comprising:
a memory for storing program instructions;
a processor for calling program instructions stored in said memory and for executing the steps comprised by the method of any one of claims 1 to 6 in accordance with the obtained program instructions.
14. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program comprising program instructions that, when executed by a computer, cause the computer to perform the method according to any one of claims 1-6.
15. A computer program product, the computer program product comprising: computer program code which, when run on a computer, causes the computer to perform the method according to any of the preceding claims 1-6.
CN202211339209.1A 2022-10-28 2022-10-28 Code generation method, device, equipment and medium Pending CN115599359A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211339209.1A CN115599359A (en) 2022-10-28 2022-10-28 Code generation method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211339209.1A CN115599359A (en) 2022-10-28 2022-10-28 Code generation method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN115599359A true CN115599359A (en) 2023-01-13

Family

ID=84850215

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211339209.1A Pending CN115599359A (en) 2022-10-28 2022-10-28 Code generation method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN115599359A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116382703A (en) * 2023-06-07 2023-07-04 建信金融科技有限责任公司 Software package generation method, code development method and device, electronic equipment and medium
CN117472336A (en) * 2023-12-28 2024-01-30 芯瞳半导体技术(山东)有限公司 Code generating device based on program API, method, equipment and medium thereof

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116382703A (en) * 2023-06-07 2023-07-04 建信金融科技有限责任公司 Software package generation method, code development method and device, electronic equipment and medium
CN116382703B (en) * 2023-06-07 2023-08-22 建信金融科技有限责任公司 Software package generation method, code development method and device, electronic equipment and medium
CN117472336A (en) * 2023-12-28 2024-01-30 芯瞳半导体技术(山东)有限公司 Code generating device based on program API, method, equipment and medium thereof
CN117472336B (en) * 2023-12-28 2024-04-12 芯瞳半导体技术(山东)有限公司 Code generating device based on program API, method, equipment and medium thereof

Similar Documents

Publication Publication Date Title
CN111209005B (en) Method and apparatus for compiling program file, and computer-readable storage medium
CN104657140B (en) Code generating method and device
CN111176996A (en) Test case generation method and device, computer equipment and storage medium
CN112800095B (en) Data processing method, device, equipment and storage medium
CN115599359A (en) Code generation method, device, equipment and medium
CN106547527B (en) JavaScript file construction method and device
CN111782330A (en) Web application-based page data acquisition method, device and equipment
CN110955409B (en) Method and device for creating resources on cloud platform
CN111881183B (en) Enterprise name matching method and device, storage medium and electronic equipment
CN107391528B (en) Front-end component dependent information searching method and equipment
US11366704B2 (en) Configurable analytics for microservices performance analysis
CN113177062A (en) Data query method and device
CN111290996A (en) Document format conversion method, device, equipment and readable storage medium
CN110941655A (en) Data format conversion method and device
CN111159040A (en) Test data generation method, device, equipment and storage medium
CN115599386A (en) Code generation method, device, equipment and storage medium
CN116560683A (en) Software updating method, device, equipment and storage medium
CN117493309A (en) Standard model generation method, device, equipment and storage medium
CN113342353B (en) Mock data generation method and device
CN116382640A (en) Method, device, equipment and storage medium for managing micro-service
CN114896269A (en) Structured query statement detection method and device, electronic equipment and storage medium
CN110688430B (en) Method and device for obtaining data bypass and electronic equipment
CN113868138A (en) Method, system, equipment and storage medium for acquiring test data
CN114116268A (en) Method and device for checking Flink SQL statement, computer equipment and storage medium
CN111651362A (en) Test case generation method and device, storage medium and computer equipment

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