[go: up one dir, main page]

CN115480745B - Code generation method and device based on configuration file - Google Patents

Code generation method and device based on configuration file Download PDF

Info

Publication number
CN115480745B
CN115480745B CN202211027750.9A CN202211027750A CN115480745B CN 115480745 B CN115480745 B CN 115480745B CN 202211027750 A CN202211027750 A CN 202211027750A CN 115480745 B CN115480745 B CN 115480745B
Authority
CN
China
Prior art keywords
code
code template
template
configuration file
generating
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
CN202211027750.9A
Other languages
Chinese (zh)
Other versions
CN115480745A (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.)
Seashell Housing Beijing Technology Co Ltd
Original Assignee
Seashell Housing Beijing Technology 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 Seashell Housing Beijing Technology Co Ltd filed Critical Seashell Housing Beijing Technology Co Ltd
Priority to CN202211027750.9A priority Critical patent/CN115480745B/en
Publication of CN115480745A publication Critical patent/CN115480745A/en
Application granted granted Critical
Publication of CN115480745B publication Critical patent/CN115480745B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/36Software reuse
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal 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)
  • Computing Systems (AREA)
  • Stored Programmes (AREA)

Abstract

The application provides a code generation method and device based on a configuration file, wherein the method comprises the following steps: acquiring a code template set; generating code segments corresponding to each code template in the target page according to the configuration file corresponding to each code template in the code template set; wherein the code template set is a code template with an association relationship; the code template set is used for generating codes of different parts of the same page; the configuration file is used for indicating the calling rule of the interface contained in the corresponding code template. The code generation method and device based on the configuration file are used for improving the multiplexing degree of the code template and further improving the code generation efficiency.

Description

Code generation method and device based on configuration file
Technical Field
The present application relates to the field of automatic code generation, and in particular, to a method and apparatus for generating a code based on a configuration file.
Background
With the vigorous development of the information age, the demand of various industries for various software is increasing, and various software products are also layered endlessly. However, due to the differences in development levels of developers, software products are of poor quality. In the face of huge market demands, how to improve the development efficiency and reduce the development period and development cost becomes the focus of attention of developers and even the whole industry.
In the related art, the period of the software product development process and the manpower consumed can be reduced by means of the code automatic generation tool.
However, the code generated by the code automatic generation tool in the related art is often required to be configured in a complicated way to be normally used, and the generated code can only be aimed at a specific service scene, so that the applicability is poor.
Disclosure of Invention
The application aims to provide a code generation method and device based on a configuration file, which are used for improving the multiplexing degree of a code template and further improving the code generation efficiency.
The application provides a code generation method based on a configuration file, which comprises the following steps:
acquiring a code template set; the set of code templates includes at least one code template; generating code segments corresponding to each code template in the target page according to the configuration file corresponding to each code template in the code template set; wherein the code template set is a code template with an association relationship; the code template set is used for generating codes of different parts of the same page; the configuration file is used for indicating the calling rule of the interface contained in the corresponding code template.
Optionally, the configuration file includes at least one of: the interface can be called in the code template, the calling mode of the interface can be called in the code template, and the parameter information of the interface can be called in the code template.
Optionally, before the acquiring the code template set, the method further includes: and under the condition that the code template set comprises one code template, generating the code templates in the code template set and configuration files corresponding to the code templates based on code differences among the pages in the plurality of pages.
Optionally, before the acquiring the code template set, the method further includes: in the case that the code template set contains a plurality of code templates, code templates in the code template set, configuration files corresponding to each code template in the code template set, and calling sequences of the code templates in the code template set are generated based on code differences among the pages in the plurality of pages.
Optionally, the generating, according to the configuration file corresponding to each code template in the code template set, a code segment corresponding to each code template in the target page includes: and generating code fragments corresponding to the code templates in the target page according to the calling rules of the interfaces indicated by the configuration files corresponding to the code templates in the code template set.
Optionally, the generating, according to the configuration file corresponding to each code template in the code template set, a code segment corresponding to each code template in the target page includes: and generating code fragments corresponding to each code template in the target page according to the calling sequence of each code template in the code template set and the calling rule of the interface indicated by the configuration file corresponding to each code template.
Optionally, the generating, according to the configuration file corresponding to each code template in the code template set, a code segment corresponding to each code template in the target page includes: determining the corresponding position information of each code template in the target page according to the dynamic code occupation identifier corresponding to each code template in the code template set; and generating code fragments corresponding to each code template according to the code positions indicated by the position information of each code template.
The application also provides a code generation device based on the configuration file, which comprises the following steps:
the acquisition module is used for acquiring the code template set; the set of code templates includes at least one code template; the code generation module is used for generating code fragments corresponding to each code template in the target page according to the configuration file corresponding to each code template in the code template set; wherein the code template set is a code template with an association relationship; the code template set is used for generating codes of different parts of the same page; the configuration file is used for indicating the calling rule of the interface contained in the corresponding code template.
Optionally, the configuration file includes at least one of: the interface can be called in the code template, the calling mode of the interface can be called in the code template, and the parameter information of the interface can be called in the code template.
Optionally, the apparatus further comprises: a template generation module; the template generation module is used for generating the code templates in the code template set and configuration files corresponding to the code templates based on code differences among the pages in the plurality of pages under the condition that the code template set contains one code template.
Optionally, the template generating module is further configured to, when the code template set includes a plurality of code templates, generate a code template in the code template set, a configuration file corresponding to each code template in the code template set, and a calling order of each code template in the code template set based on code differences between pages in the plurality of pages.
Optionally, the code generating module is specifically configured to generate a code segment corresponding to the code template in the target page according to a calling rule of an interface indicated by a configuration file corresponding to the code template in the code template set.
Optionally, the code generating module is specifically configured to generate a code segment corresponding to each code template in the target page according to a calling sequence of each code template in the code template set and a calling rule of an interface indicated by a configuration file corresponding to each code template.
Optionally, the apparatus further comprises: a determining module; the determining module is used for determining the corresponding position information of each code template in the target page according to the dynamic code occupation identifier corresponding to each code template in the code template set; the code generation module is specifically configured to generate a code segment corresponding to each code template according to the code position indicated by the position information of each code template.
The application also provides a computer program product comprising computer programs/instructions which when executed by a processor implement the steps of a profile-based code generation method as described in any of the above.
The application also provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of any of the profile-based code generation methods described above when the program is executed.
The present application also provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of a profile-based code generation method as described in any of the above.
According to the code generation method and device based on the configuration file, the code template set is obtained under the condition that the code of the target page needs to be generated. And then, generating code fragments corresponding to each code template in the target page according to the configuration file corresponding to each code template in the code template set. Wherein the code template set is a code template with an association relationship; the code template set is used for generating codes of different parts of the same page; the configuration file is used for indicating the calling rule of the interface contained in the corresponding code template. Therefore, codes corresponding to the code templates can be generated according to the configuration file of each code template, and the multiplexing degree of the code templates and the code generation efficiency are improved.
Drawings
In order to more clearly illustrate the application or the technical solutions of the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described, and it is obvious that the drawings in the description below are some embodiments of the application, and other drawings can be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of a configuration file-based code generation method provided by the application;
FIG. 2 is a second flow chart of a code generation method based on configuration files provided by the application;
FIG. 3 is a schematic diagram of a configuration file-based code generating apparatus according to the present application;
fig. 4 is a schematic structural diagram of an electronic device provided by the present application.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some embodiments of the present application, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The terms first, second and the like in the description and in the claims, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged, as appropriate, such that embodiments of the present application may be implemented in sequences other than those illustrated or described herein, and that the objects identified by "first," "second," etc. are generally of a type, and are not limited to the number of objects, such as the first object may be one or more. Furthermore, in the description and claims, "and/or" means at least one of the connected objects, and the character "/", generally means that the associated object is an "or" relationship.
In the related art, a code generation tool that is popular in comparison includes: a template engine such as Beetl, freeMarker for developing a scene based on a World Wide Web (Web), and a CodeSmith template engine based on a c# language. Taking a FreeMark template engine as an example, the template engine is a View, a Model, and a Controller (Model View Controller, MVC) framework, namely, data is transmitted to a code template by a back-end code through a data Model, the code template is responsible for the display (View) of the data, and the back-end code and the code template are controlled through a Controller (Controller).
The code generation tool provided in the related art mainly solves the problems of page data binding and the like in the web development process. The configured code templates need a large number of custom labels, the development and maintenance cost is high, and the code templates can only aim at specific business scenes and lack multiplexing degree.
Aiming at the technical problems in the related art, the embodiment of the application provides a code generation method based on a configuration file, which can obviously improve the multiplexing degree of a code template, further improve the code generation efficiency and save the development time.
The code generation method based on the configuration file provided by the embodiment of the application is described in detail through specific embodiments and application scenes thereof with reference to the accompanying drawings.
As shown in fig. 1, a code generating method based on a configuration file according to an embodiment of the present application may include the following steps 101 and 102:
and 101, acquiring a code template set.
Wherein the set of code templates comprises at least one code template; the code template set is a code template with an association relation; the set of code templates is used to generate codes for different portions of the same page.
Illustratively, the code templates are templates generated based on a plurality of pages. In the process of developing service codes, especially mobile terminal service codes, more common codes (for example, logic codes and User Interface (UI) codes) exist in a plurality of pages, a set of code templates can be extracted through preset rules by the codes, and then the codes can be quickly generated through the code templates to replace manual writing of the codes by a developer.
The code template set may be stored in a server, and may be obtained from the server when required by the user.
It should be noted that, in the embodiment of the present application, the code of one page needs to be generated through one or more code templates, and in general, multiple code templates are required to generate codes of different portions of the same page.
Step 102, generating code segments corresponding to each code template in the target page according to the configuration file corresponding to each code template in the code template set.
The configuration file is used for indicating calling rules of interfaces contained in the corresponding code templates. The configuration file corresponding to the code template can be contained in the code template set or can exist as a separate file.
Illustratively, the configuration file includes at least one of: the interface can be called in the code template, the calling mode of the interface can be called in the code template, and the parameter information of the interface can be called in the code template.
For the code template in the embodiment of the application, a corresponding configuration file is also generated in the process of generating the code template. In generating code using the code template, the interface of the code template may be invoked according to the invocation rules indicated by the configuration file.
For example, the configuration file may be stored in the form of a JSON string, as follows:
the JSON string is used for indicating an interface which can be called by the outside in the corresponding code template, parameters of the interface and the like. Wherein, the parameter "type" represents the mode of external calling, including: calling a method to construct a construction method; the parameter "method" indicates an interface that can be called, "name" indicates the name of the interface (i.e., the interface whose interface name is "request"), and "params" indicates the parameters that the interface needs to transfer in and the data type of each parameter; the parameter "call" indicates how to call the interface contained in "method".
Illustratively, before the step 101, the method for generating a code based on a configuration file according to the embodiment of the present application may further include the following step 103:
step 103, generating a code template in the code template set and a configuration file corresponding to the code template based on code differences among pages in the plurality of pages when the code template set contains one code template.
It will be appreciated that in the case where the set of code templates contains only one code template, there is no need to consider the order of calls, and therefore there is no need to generate the order of calls when generating the set of code templates. And, for the generation of the one code template, the common portion of each page may be extracted as a fixed code portion, i.e., a static portion, of the code template, while the differential portion of each page is taken as a dynamic code portion, i.e., a dynamic portion, of the code template.
Illustratively, before the step 101, the method for generating a code based on a configuration file according to the embodiment of the present application may further include the following step 104:
step 104, generating code templates in the code template set, configuration files corresponding to each code template in the code template set and calling sequences of the code templates in the code template set based on code differences among pages in the plurality of pages when the code template set contains the plurality of code templates.
It can be understood that in the case that the code template set includes a plurality of code templates, the calling sequence of each code template in the code template set needs to be generated, so that when the code of the target page is generated, each code template is conveniently called according to the calling sequence.
Illustratively, since the code template set is used to generate the same page file, when each code template in the code template set is called, the call needs to be performed according to a certain calling sequence, otherwise, an error may occur when generating the code.
For example, the code template set includes: for example, when the template A and the template B are used, the template B needs to call the method a in the template A, if the template B is called first in the process of generating the target page, at this time, the method a in the template A is not initialized yet, and an error prompt that the method a cannot be found can appear. Therefore, each code template in the code template set needs to be called in the order of call specified when the code template set is generated.
For example, in the process of generating the target page, the corresponding code template may be invoked according to the invoking rule indicated by the configuration file.
Specifically, the step 102 may include the following step 102a or step 102b:
step 102a, generating a code segment corresponding to the code template in the target page according to a calling rule of an interface indicated by a configuration file corresponding to the code template in the code template set.
In an exemplary case where only one code template is included in the code template set, the code template is only required to be called according to the interface calling rule indicated by the configuration file corresponding to the code template.
Step 102b, generating code segments corresponding to each code template in the target page according to the calling sequence of each code template in the code template set and the calling rule of the interface indicated by the configuration file corresponding to each code template.
Illustratively, in the case where a plurality of code templates are included in the above-described code template set, it is also necessary to call each code template in the above-described call order.
For example, the code template is invoked according to the interface invocation rule indicated by the configuration file, and the following steps may be referred to: as mentioned above, when the code template corresponding to the configuration file is called, according to the instruction of the configuration file, the "request" interface in the code template can be called, and when the interface is called, the parameters to be transferred are respectively: "PageNo", "PageSize" and "id", the data types of the above parameters are respectively: integer "int", "int" and String ".
Illustratively, since each code template in the set of code templates is used to generate a code segment for a different portion of the target page, it is also necessary to determine the specific location in the target page where each code template generates a code segment.
Illustratively, in the step 102, the step of generating the code segment corresponding to each code template in the target page may specifically include the following steps 102c1 and 102c2:
step 102c1, determining the corresponding position information of each code template in the target page according to the dynamic code occupation identifier corresponding to each code template in the code template set.
When any code template in the code template set is called, the code template can be called based on the calling rule indicated by the configuration file corresponding to the code template.
Step 102c2, generating code segments corresponding to each code template according to the code positions indicated by the position information of each code template.
Illustratively, in the process of generating the code corresponding to the target page, the corresponding position information of each code template in the target page can be determined according to the dynamic code placeholder corresponding to each code template. The location information is used to indicate the location of the code segment generated in the target page.
For example, after determining the location information corresponding to each code template in the target page, a code segment corresponding to each code template may be generated according to the code location indicated by the location information of each code template. And then, combining all the generated codes to obtain the codes corresponding to the target page.
Illustratively, the code generation method based on the configuration file provided by the embodiment of the present application may include two engines (a template configuration engine and a code generation engine) as shown in fig. 3. The template configuration engine is used for generating a code template, and comprises the following specific steps: s1, generating and extracting a plurality of templates based on a plurality of pages; s2, configuring interface definition of each template callable interface; s3, associating the templates, and configuring the calling sequence of each template; s4, cloud storage is carried out on the generated templates. The specific steps of the code generation engine for generating the code segments of the target page according to the code template include: s5, the code generation engine pulls the needed template from the cloud; s6, acquiring a template file, and analyzing the calling sequence of each template and the calling rule of each template; s7, generating code fragments corresponding to each template at corresponding positions according to the calling sequence and the calling rule; s8, integrating each code segment to finish code generation of the target page.
It should be noted that, the developer may share the code template with other developers through the cloud end, so as to improve the development efficiency.
It should be noted that, the code generation flow shown in fig. 3 is implemented for a configuration file based on each code template.
According to the code generation method based on the configuration file, under the condition that codes of the target page are generated, a code template set required for generating the target page is obtained from a cloud. And then, generating code fragments corresponding to each code template in the target page according to the configuration file corresponding to each code template in the code template set. Therefore, codes corresponding to the code templates can be generated according to the configuration file of each code template, and the multiplexing degree of the code templates and the code generation efficiency are improved.
It should be noted that, in the configuration file-based code generation method provided by the embodiment of the present application, the execution subject may be a configuration file-based code generation device, or a control module in the configuration file-based code generation device for executing the configuration file-based code generation method. In the embodiment of the present application, a configuration file-based code generating device executes a configuration file-based code generating method as an example, and the configuration file-based code generating device provided in the embodiment of the present application is described.
In the embodiment of the present application, the method is shown in the drawings. The code generation method based on the configuration file is taken as an example and explained by taking a figure in combination with the embodiment of the application as an illustration. In specific implementation, the code generating method based on the configuration file shown in the above method drawings may also be implemented in combination with any other drawing that may be combined and is illustrated in the above embodiment, which is not repeated herein.
The configuration file-based code generating apparatus provided by the present application will be described below, and the configuration file-based code generating method described below and the configuration file-based code generating method described above may be referred to in correspondence with each other.
Fig. 3 is a schematic structural diagram of a code generating device based on a configuration file according to an embodiment of the present application, where, as shown in fig. 3, the code generating device specifically includes:
an acquiring module 301, configured to acquire a code template set; the set of code templates includes at least one code template; the code generating module 302 is configured to generate a code segment corresponding to each code template in the target page according to the configuration file corresponding to each code template in the code template set; wherein the code template set is a code template with an association relationship; the code template set is used for generating codes of different parts of the same page; the configuration file is used for indicating the calling rule of the interface contained in the corresponding code template.
Optionally, the configuration file includes at least one of: the interface can be called in the code template, the calling mode of the interface can be called in the code template, and the parameter information of the interface can be called in the code template.
Optionally, the apparatus further comprises: a template generation module; the template generation module is used for generating the code templates in the code template set and configuration files corresponding to the code templates based on code differences among the pages in the plurality of pages under the condition that the code template set contains one code template.
Optionally, the template generating module is further configured to, when the code template set includes a plurality of code templates, generate a code template in the code template set, a configuration file corresponding to each code template in the code template set, and a calling order of each code template in the code template set based on code differences between pages in the plurality of pages.
Optionally, the code generating module 302 is specifically configured to generate, according to a call rule of an interface indicated by a configuration file corresponding to the code template in the code template set, a code segment corresponding to the code template in the target page.
Optionally, the code generating module 302 is specifically configured to generate a code segment corresponding to each code template in the target page according to a calling sequence of each code template in the code template set and a calling rule of an interface indicated by a configuration file corresponding to each code template.
Optionally, the apparatus further comprises: a determining module; the determining module is used for determining the corresponding position information of each code template in the target page according to the dynamic code occupation identifier corresponding to each code template in the code template set; the code generating module 302 is specifically configured to generate a code segment corresponding to each code template according to the code position indicated by the position information of each code template.
According to the code generating device based on the configuration file, under the condition that codes of the target page are generated, a code template set required for generating the target page is obtained from a cloud. And then, generating code fragments corresponding to each code template in the target page according to the configuration file corresponding to each code template in the code template set. Therefore, codes corresponding to the code templates can be generated according to the configuration file of each code template, and the multiplexing degree of the code templates and the code generation efficiency are improved.
Fig. 4 illustrates a physical schematic diagram of an electronic device, as shown in fig. 4, which may include: processor 410, communication interface (Communications Interface) 420, memory 430 and communication bus 440, wherein processor 410, communication interface 420 and memory 430 communicate with each other via communication bus 440. Processor 410 may invoke logic instructions in memory 430 to perform a profile-based code generation method comprising: acquiring a code template set; generating code segments corresponding to each code template in the target page according to the configuration file corresponding to each code template in the code template set; wherein the code template set is a code template with an association relationship; the code template set is used for generating codes of different parts of the same page; the configuration file is used for indicating the calling rule of the interface contained in the corresponding code template.
Further, the logic instructions in the memory 430 described above may be implemented in the form of software functional units and may be stored in a computer-readable storage medium when sold or used as a stand-alone product. Based on this understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
In another aspect, the present application also provides a computer program product comprising a computer program stored on a computer readable storage medium, the computer program comprising program instructions which, when executed by a computer, enable the computer to perform the method of profile-based code generation provided by the methods described above, the method comprising: acquiring a code template set; generating code segments corresponding to each code template in the target page according to the configuration file corresponding to each code template in the code template set; wherein the code template set is a code template with an association relationship; the code template set is used for generating codes of different parts of the same page; the configuration file is used for indicating the calling rule of the interface contained in the corresponding code template.
In yet another aspect, the present application also provides a computer readable storage medium having stored thereon a computer program which when executed by a processor is implemented to perform the above provided profile-based code generation methods, the method comprising: acquiring a code template set; generating code segments corresponding to each code template in the target page according to the configuration file corresponding to each code template in the code template set; wherein the code template set is a code template with an association relationship; the code template set is used for generating codes of different parts of the same page; the configuration file is used for indicating the calling rule of the interface contained in the corresponding code template.
The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present application without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on this understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present application, and are not limiting; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims (8)

1. A method for generating a code based on a configuration file, comprising:
acquiring a code template set; the set of code templates includes at least one code template;
generating code segments corresponding to each code template in the target page according to the configuration file corresponding to each code template in the code template set;
wherein the code template set is a code template with an association relationship; the code template set is used for generating codes of different parts of the same page; the configuration file is used for indicating the calling rule of the interface contained in the corresponding code template;
before the acquiring the code template set, the method further includes:
generating code templates in the code template set, configuration files corresponding to each code template in the code template set and calling sequences of all the code templates in the code template set based on code differences among all pages in a plurality of pages when the code template set comprises a plurality of code templates;
generating a code segment corresponding to each code template in the target page according to the configuration file corresponding to each code template in the code template set, including:
and generating code fragments corresponding to each code template in the target page according to the calling sequence of each code template in the code template set and the calling rule of the interface indicated by the configuration file corresponding to each code template.
2. The method of claim 1, wherein the configuration file comprises at least one of: the interface can be called in the code template, the calling mode of the interface can be called in the code template, and the parameter information of the interface can be called in the code template.
3. The method of claim 1, wherein prior to the acquiring the set of code templates, the method further comprises:
and under the condition that the code template set comprises one code template, generating the code templates in the code template set and configuration files corresponding to the code templates based on code differences among the pages in the plurality of pages.
4. The method of claim 3, wherein the generating the code segment corresponding to each code template in the target page according to the configuration file corresponding to each code template in the code template set comprises:
and generating code fragments corresponding to the code templates in the target page according to the calling rules of the interfaces indicated by the configuration files corresponding to the code templates in the code template set.
5. The method according to claim 1 or 4, wherein the generating code segments corresponding to each code template in the target page includes:
determining the corresponding position information of each code template in the target page according to the dynamic code occupation identifier corresponding to each code template in the code template set;
and generating a code segment corresponding to each code template in the target page according to the code position indicated by the position information of each code template.
6. A profile-based code generation apparatus, the apparatus comprising:
the acquisition module is used for acquiring the code template set; the set of code templates includes at least one code template;
the code generation module is used for generating code fragments corresponding to each code template in the target page according to the configuration file corresponding to each code template in the code template set;
wherein the code template set is a code template with an association relationship; the code template set is used for generating codes of different parts of the same page; the configuration file is used for indicating the calling rule of the interface contained in the corresponding code template;
the template generation module is used for generating a code template in the code template set and a configuration file corresponding to the code template based on code differences among all pages in a plurality of pages under the condition that the code template set comprises one code template;
the code generation module is specifically configured to generate a code segment corresponding to the code template in the target page according to a calling rule of an interface indicated by a configuration file corresponding to the code template in the code template set.
7. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the profile-based code generation method of any one of claims 1 to 5 when the program is executed.
8. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, implements the steps of the profile-based code generation method of any one of claims 1 to 5.
CN202211027750.9A 2022-08-25 2022-08-25 Code generation method and device based on configuration file Active CN115480745B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211027750.9A CN115480745B (en) 2022-08-25 2022-08-25 Code generation method and device based on configuration file

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211027750.9A CN115480745B (en) 2022-08-25 2022-08-25 Code generation method and device based on configuration file

Publications (2)

Publication Number Publication Date
CN115480745A CN115480745A (en) 2022-12-16
CN115480745B true CN115480745B (en) 2023-10-24

Family

ID=84421085

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211027750.9A Active CN115480745B (en) 2022-08-25 2022-08-25 Code generation method and device based on configuration file

Country Status (1)

Country Link
CN (1) CN115480745B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106873949A (en) * 2015-12-11 2017-06-20 泰康保险集团股份有限公司 Code generating method and its device
CN107621954A (en) * 2017-09-19 2018-01-23 深圳市华傲数据技术有限公司 Interface interchange method and device
CN108563435A (en) * 2018-04-19 2018-09-21 北京百度网讯科技有限公司 The method and device of code building
CN110806866A (en) * 2019-11-05 2020-02-18 连连银通电子支付有限公司 Generation method and device of front-end management system
CN114741070A (en) * 2022-04-12 2022-07-12 中国联合网络通信集团有限公司 Code generation method and device, electronic equipment and storage medium
CN114840190A (en) * 2022-04-07 2022-08-02 土巴兔集团股份有限公司 Code generation method and device, computer equipment and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106980504B (en) * 2017-03-28 2022-07-01 腾讯科技(深圳)有限公司 Application program development method and tool and equipment thereof
CN110308908B (en) * 2018-03-20 2023-07-18 北京小米移动软件有限公司 Method, device, and storage medium for generating application configuration files and displaying application pages

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106873949A (en) * 2015-12-11 2017-06-20 泰康保险集团股份有限公司 Code generating method and its device
CN107621954A (en) * 2017-09-19 2018-01-23 深圳市华傲数据技术有限公司 Interface interchange method and device
CN108563435A (en) * 2018-04-19 2018-09-21 北京百度网讯科技有限公司 The method and device of code building
CN110806866A (en) * 2019-11-05 2020-02-18 连连银通电子支付有限公司 Generation method and device of front-end management system
CN114840190A (en) * 2022-04-07 2022-08-02 土巴兔集团股份有限公司 Code generation method and device, computer equipment and storage medium
CN114741070A (en) * 2022-04-12 2022-07-12 中国联合网络通信集团有限公司 Code generation method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN115480745A (en) 2022-12-16

Similar Documents

Publication Publication Date Title
CN111435367B (en) Knowledge graph construction method, system, equipment and storage medium
CN113467980B (en) Log output method, device and system and embedded equipment
CN110532182B (en) Automatic testing method and device for virtualization platform
CN115599359A (en) Code generation method, device, equipment and medium
CN102929646A (en) Application program production method and device
CN114238055B (en) Task data processing method, device, electronic device and storage medium
CN112540837A (en) Service processing component calling method, system, electronic equipment and storage medium
CN112395339B (en) Intersystem data access verification method, device, computer equipment and storage medium
WO2024011994A1 (en) Methods and systems for updating an algorithm package
CN112732242B (en) Method and device for generating wide-table processing script
CN115480745B (en) Code generation method and device based on configuration file
CN111078573A (en) Test message generation method and device
CN113342631B (en) Distribution management optimization method and device and electronic equipment
CN113342647A (en) Test data generation method and device
CN111273901B (en) A file format and deployment method of a machine learning model that can be quickly deployed online
CN112860248B (en) Source code generation method and device
CN119172218A (en) A method and system for implementing dynamic thread pool based on microservice framework and Nacos
CN118427088A (en) Method, device, equipment and storage medium for evaluating code content
CN110096266A (en) A kind of characteristic processing method and device
CN113342885B (en) Data import method, apparatus, apparatus and computer program product
CN117234623B (en) Page theme changing method and device of application program and electronic equipment
CN114356252A (en) Dynamic field printing method, system and related device
CN111208980B (en) Data analysis processing method and system
CN112947920A (en) Script generation method and system for camera effect
CN114115833B (en) Automatic protocol audit code generation method and device

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