CN112527286A - Service code generation method and device, computer equipment and storage medium - Google Patents

Service code generation method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN112527286A
CN112527286A CN202011496978.3A CN202011496978A CN112527286A CN 112527286 A CN112527286 A CN 112527286A CN 202011496978 A CN202011496978 A CN 202011496978A CN 112527286 A CN112527286 A CN 112527286A
Authority
CN
China
Prior art keywords
content
service
variable
fixed
component
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
CN202011496978.3A
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.)
Ping An Consumer Finance Co Ltd
Original Assignee
Ping An Consumer Finance 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 Ping An Consumer Finance Co Ltd filed Critical Ping An Consumer Finance Co Ltd
Priority to CN202011496978.3A priority Critical patent/CN112527286A/en
Publication of CN112527286A publication Critical patent/CN112527286A/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
    • G06F8/35Creation or generation of source code model driven
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3644Software debugging by instrumenting at runtime
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2358Change logging, detection, and notification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/427Parsing

Abstract

The application relates to the field of tool software development, and discloses a method and a device for generating a service code, computer equipment and a storage medium, wherein the method comprises the following steps: responding to a data connection mode and a data table attribute input in a console, and configuring a database according to the data connection mode and the data table attribute; receiving parameter variables input in a console, and establishing association between the parameter variables and the database to serve as variable content; acquiring fixed content of a component, combining the variable content with the fixed content of the component, and filling the combined variable content and the fixed content of the component into a preset position of a service template to generate the service template; and generating a service code with a corresponding format and content according to the service template. By customizing the service template and transplanting the service template in different projects, corresponding service codes are quickly generated in different projects, and the development efficiency of repeated or logically repeated codes is improved.

Description

Service code generation method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of tool software development, and in particular, to a method and an apparatus for generating a service code, a computer device, and a storage medium.
Background
In the prior art, aiming at the existence of repeated codes, one solution in the industry is to manually copy and transplant the codes through developers, the solution needs to consume a large amount of manpower and time and has a high probability of missing or error, the other solution is to use a code generator to quickly generate the partial codes, the current code generator needs to be based on a specific development framework and needs too many configuration items, the configuration flow is complex and tedious, and the same set of code logic application needs to be repeatedly configured in different projects, so that the universality is poor and the efficiency is low.
Disclosure of Invention
The application mainly aims to provide a method and a device for generating business codes, computer equipment and a storage medium, and aims to solve the problems of long time consumption and low efficiency of the development of repeated or similar logic codes at present.
In order to achieve the above object of the invention, the present application provides a method for generating a service code, including the following steps:
responding to a data connection mode and a data table attribute input in a console, and configuring a database according to the data connection mode and the data table attribute;
receiving parameter variables input in a console, and establishing association between the parameter variables and the database to serve as variable content;
acquiring fixed content of a component, combining the variable content with the fixed content of the component, and filling the combined variable content and the fixed content of the component into a preset position of a service template to generate the service template;
and generating a service code with a corresponding format and content according to the service template.
Further, after the associating the parameter variable with the database as the variable content, the method further includes:
acquiring a data operation statement in the variable content;
judging the legality of the data operation statement according to the associated parameter variable and a database;
if the variable content is legal, performing subsequent acquisition of the fixed content of the component, combining the variable content with the fixed content of the component, and filling the combined variable content and the fixed content of the component into a preset position of a service template to generate the service template; and generating a service code with a corresponding format and content according to the service template.
Further, the acquiring fixed content of the component, combining the variable content with the fixed content of the component, and filling the combined variable content and fixed content into a preset position of a service template to generate the service template, including:
acquiring fixed contents of a plurality of components, and combining the fixed contents of the plurality of components with corresponding variable contents respectively to obtain combined component contents;
and filling the combined component content into a preset position of the service template and establishing the association between the components to generate the service template.
Further, the acquiring fixed content of the component, combining the variable content with the fixed content of the component, and filling the combined variable content and fixed content into a preset position of a service template to generate the service template, including:
acquiring fixed contents of a plurality of components, combining the fixed contents of the plurality of components, and combining the combined fixed contents with corresponding variable contents to obtain combined component contents;
and filling the combined component content into a preset position of the service template to generate the service template.
Further, after receiving the parameter variable input at the console and associating the parameter variable with the database as the variable content, the method further includes:
associating the variable content with a corresponding service scene to generate variable content under the corresponding service scene;
the fixed content of the component is obtained, the variable content and the fixed content of the component are combined and then filled in a preset position of a service template to generate the service template, which comprises,
and acquiring the fixed content of the assembly, combining the variable content of different service scenes with the fixed content of the assembly, and filling the combined variable content into the preset position of the service template to generate the service templates of different service scenes.
Further, after generating the service code having the corresponding format and content according to the service template, the method further includes:
running the service code;
monitoring whether the operation of the service code has errors;
if yes, locating the fixed content and/or the variable content with the error.
Further, the error is the fixed content of the service code; after the locating the fixed content and/or the variable content with the error, the method further comprises the following steps:
matching the corresponding modification scheme according to the error;
acquiring different service templates with the fixed content with errors;
and applying the modification scheme to different service templates with the fixed content to complete the modification of the service templates.
The present application further provides a device for generating a service code, including:
a data configuration module: the system comprises a database, a console and a database server, wherein the database is used for responding to a data connection mode and a data table attribute input in the console and configuring the database according to the data connection mode and the data table attribute;
a parameter association module: receiving parameter variables input in a console, and establishing association between the parameter variables and the database to serve as variable content;
a template definition module: the system comprises a fixed content acquisition module, a service template generation module and a service module, wherein the fixed content acquisition module is used for acquiring the fixed content of the component, combining the variable content with the fixed content of the component and filling the combined variable content and the fixed content of the component into a preset position of the service template to generate the service template;
a code generation module: and the service code is used for generating a service code with a corresponding format and content according to the service template.
The present application further provides a computer device, which includes a memory and a processor, where the memory stores a computer program, and the processor implements the steps of the service code generation method described in any one of the above when executing the computer program.
The present application also provides a computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the steps of the method for generating a service code according to any one of the above.
The application provides a method for self-defining a service template so as to automatically generate a service code, which comprises the steps of receiving a self-defined data connection mode and a data sheet attribute through a console, configuring a database according to the data connection mode and the data sheet attribute, receiving a parameter variable of a self-defined assembly, establishing association between the parameter variable and the database to be used as variable content, acquiring fixed content of the assembly, combining the variable content and the fixed content of the assembly into a finished assembly logic, filling the assembly logic into a preset position of the service template to generate the service template, so that the corresponding service code is quickly generated according to the service template, time and resources consumed by a large amount of repeated work of same or similar service development are reduced, in addition, the code of the same service can be unified to the greatest extent through the service template generation of the service code, and the reading of the service code is convenient, furthermore, because the same service code has a uniform style, if the same service code needs to be modified, the service code can be rapidly modified, so that the maintenance efficiency of the service code is improved.
Drawings
Fig. 1 is a schematic flowchart of an embodiment of a method for generating a service code according to the present application;
FIG. 2 is a schematic diagram of an embodiment of determining validity of a data operation statement in the method for generating a service code according to the present application;
fig. 3 is a schematic structural diagram of an embodiment of a device for generating a service code according to the present application;
FIG. 4 is a block diagram illustrating a computer device according to an embodiment of the present invention.
The implementation, functional features and advantages of the objectives of the present application will be further explained with reference to the accompanying drawings.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
Referring to fig. 1, an embodiment of the present application provides a method for generating a service code, which includes at least steps S10-S40, and details of each step of the method for generating a service code are described as follows.
And S10, responding to the data connection mode and the data table attribute input in the console, and configuring a database according to the data connection mode and the data table attribute.
The embodiment is applied to the business development scene of project engineering, in the process of business development, repeated or similar business modules exist, in order to improve the development efficiency of repeated or similar business modules and avoid multiple development, the embodiment outputs a console with a graphical interface, then receiving the data connection mode and data sheet attribute input in the console, one embodiment is that the user inputs the self-defined data sheet attribute and the connection mode of different data in the data sheet on the graphic interface of the console, generates the database description file, and by obtaining the database description file, extracting a data connection mode and a data table attribute from the database description file, wherein the data connection mode comprises the incidence relation among different data, the primary key attribute of the data and the operable attribute of the data; the data table attributes comprise the table name, the main key, the line number, the column number and the stored data field of the newly-built data table, then the database is configured according to the data connection mode and the data table attributes, the connection of the database is determined, and the configuration of the database is completed; in another embodiment, the console receives a database description file uploaded by a user, acquires a data connection mode and a data table attribute contained in the database description file, configures the database according to the data connection mode and the data table attribute, determines the connection of the database, and completes the configuration of the database.
And S20, receiving the parameter variable input by the console, and associating the parameter variable with the database to serve as variable content.
In this embodiment, the console may further receive an input parameter variable, where the parameter variable is a parameter variable of the component, and one implementation manner is that a user may provide a custom configuration input of the parameter variable on a graphical interface of the console, and the user may customize the parameter variable on the console, including the number of the custom parameter variables and the name of the parameter variable, so as to receive the parameter variable of the component input on the console, and then establish a relationship between the parameter variable and the database, including a mapping relationship between the parameter variable and a data field in the database, and a value range of the parameter variable; another embodiment is that a configuration file of an externally imported parameter variable is acquired to acquire a parameter variable of a custom configuration, then a correlation between the parameter variable and the database is established according to the configuration file, after the correlation is established, the value of the parameter variable can be taken and operated from the database, so as to adapt to the requirement of a service, and the correlation between the parameter variable and the database is established as a variable content.
And S30, acquiring the fixed content of the component, combining the variable content and the fixed content of the component, and filling the combined variable content and the fixed content of the component into a preset position of a service template to generate the service template.
In the embodiment, the service template is composed of a series of independent components, when the service template is customized, the components can be visually added through a console by customizing the added components, the existing components are provided on the console for selection, and after the corresponding components are selected, the fixed content of the components is obtained; the fixed contents of the component can also be obtained by reading a file in which the component has been written. The method comprises the steps of obtaining the running logic of the fixed content of the assembly, wherein the running logic of the obtained fixed content of the assembly is not related to data and does not change due to the change of the data, the change of other content does not influence the logic execution of the part of the fixed content, combining the variable content with the fixed content of the assembly to generate complete logic inside the assembly, combining the variable content with the fixed content and filling the combination into the preset position of a service template to generate the service template, wherein in the service template, the part of the fixed content does not need to be changed, the parameter variable of the variable content is related to a database, and the variable content is changed by changing the parameter variable based on the data in the database, so that the same assembly can adapt to the service requirements under different service scenes.
And S40, generating a service code with a corresponding format and content according to the service template.
After the service template is generated, the service template is operated in a code generation tool to analyze and compile the service template, thereby generating a service code with a format and content corresponding to the service template, wherein the service code comprises a text part, a comment part, a difference part and an instruction part, the content of each part can only comprise fixed content, or fixed content and variable content are included, for example, the service template includes four main elements of text, comments, interpolation and instructions, when a service code is generated, the text part is directly output in corresponding text, information in the format of '< # - - - - - >' of the annotation part is not output, information in the format of '{. - - - >' of the interpolation part is output by replacing corresponding parameter variables in variable contents, and the instruction part adds # in front of the name of the instruction part for distinguishing and outputting. And the service codes generated based on the service template all have a uniform format, and if the service template is implemented in other engineering projects, the service codes with the same format are generated, so that the quick generation of the service codes is completed.
This embodiment provides a method for self-defining a service template to automatically generate service codes, which includes receiving a self-defined data connection mode and a data sheet attribute through a console, configuring a database according to the data connection mode and the data sheet attribute, receiving a parameter variable of a self-defined component, associating the parameter variable with the database as a variable content, acquiring a fixed content of the component, combining the variable content and the fixed content of the component into a completed component logic, filling the completed component logic into a preset position of the service template to generate the service template, thereby quickly generating corresponding service codes according to the service template, reducing time and resources consumed by a large amount of repetitive work of same or similar service development, and generating service codes through the service template to maximally unify codes of the same service, thereby facilitating reading of the service codes, furthermore, because the same service code has a uniform style, if the same service code needs to be modified, the service code can be rapidly modified, so that the maintenance efficiency of the service code is improved.
In one embodiment, as shown in fig. 2, after the step S20 associates the parameter variable with the database, as variable content, the method further includes:
s21: acquiring a data operation statement in the variable content;
s22: judging the legality of the data operation statement according to the associated parameter variable and a database;
s221: if the variable content is legal, performing subsequent acquisition of the fixed content of the component, combining the variable content with the fixed content of the component, and filling the combined variable content and the fixed content of the component into a preset position of a service template to generate the service template; and generating a service code with a corresponding format and content according to the service template.
In this embodiment, the variable content includes a variable parameter variable, the variable parameter variable operates data in the database through a data operation statement in which the variable parameter variable is located, the variable parameter variable performs operations such as adding, deleting, modifying, and checking on the data in the database, in order to early warn of data operation errors and reduce data operation errors, a correlation is established between the parameter variable and the database, the data operation statement in the variable content is acquired as the variable content, the validity of the data operation statement is determined according to the correlated data, the validity determination includes determining whether value conflicts exist between the data operation statements and determining whether an operation sequence error exists between the data operation statements, and when it is determined that the data operation statements are valid legal statements, the variable content in which the service template is established by the established correlation template parameter and the database is determined, executing fixed content of a subsequent acquisition component, combining the variable content and the fixed content of the component, and filling the combined variable content and the fixed content of the component into a preset position of a service template to generate the service template; generating a service code with a corresponding format and content according to the service template; if any data operation statement error exists or any two data operation statements conflict in operation, the data operation statement is confirmed to be illegal, corresponding risk prompt information is output, and the error of the variable content is informed, so that the phenomenon that the generated service code cannot normally run due to the fact that the illegal data operation statements enter a template is avoided, and the accuracy of service code generation is improved.
In one embodiment, the step S30 of obtaining the fixed content of the component, and combining the variable content and the fixed content of the component to fill in the preset position of the service template to generate the service template includes:
acquiring fixed contents of a plurality of components, and combining the fixed contents of the plurality of components with corresponding variable contents respectively to obtain combined component contents;
and filling the combined component content into a preset position of the service template and establishing the association between the components to generate the service template.
In this embodiment, considering that different services need to be associated with each other or services need to be added under different development conditions, a plurality of components are added when a service template is customized, fixed contents of the plurality of components are obtained, then the fixed contents of the plurality of components are combined with corresponding different variable contents respectively to obtain combined component contents, at this time, a plurality of components with variable contents and fixed contents are combined, then the combined component contents are filled into preset positions of the service template, association among the components is established based on the preset positions, association relation among the components is determined, so as to generate the service template, the generated service module has different functions of the plurality of components, and the plurality of components can be associated with each other, data transmission among the components can be completed, the service template is flexibly configured through combination of the plurality of different components, therefore, the service codes of different complex services can be generated quickly, and the generation efficiency of the service codes is improved.
In one embodiment, the step S30 of obtaining the fixed content of the component, and combining the variable content and the fixed content of the component to fill in the preset position of the service template to generate the service template includes:
acquiring fixed contents of a plurality of components, combining the fixed contents of the plurality of components, and combining the combined fixed contents with corresponding variable contents to obtain combined component contents;
and filling the combined component content into a preset position of the service template to generate the service template.
In the embodiment, a plurality of components are added when a service template is customized to obtain fixed contents of the components, then the fixed contents of the components are combined to generate a single component, the association between the components is established according to the combination of the components, the combined component contents are combined with corresponding variable contents to obtain the combined component contents, at this time, the fixed contents of the components are combined into the fixed contents of one component and combined with the variable contents into one component containing the variable contents and the fixed contents, then the combined component contents are filled into the preset position of the service template without establishing the association between the components, so that the service template is generated, the generated service module has different functions of the components, the components can be associated with each other, and the data transmission between the original components can be completed in the same component logic, the service template is flexibly configured through the combination of a plurality of different components, so that service codes of different complex services are quickly generated, and the generation efficiency of the service codes is improved.
In one embodiment, the step S20, after receiving the parameter variable input from the console, and associating the parameter variable with the database as the variable content, further includes:
associating the variable content with a corresponding service scene to generate variable content under the corresponding service scene;
the step S30 is to obtain the fixed content of the component, combine the variable content with the fixed content of the component, and fill the combined content into the preset position of the service template to generate the service template, including,
and acquiring the fixed content of the assembly, combining the variable content of different service scenes with the fixed content of the assembly, and filling the combined variable content into the preset position of the service template to generate the service templates of different service scenes.
In this embodiment, in a service scenario, a parameter variable input in a console is received, the parameter variable is associated with the database to serve as a variable content, the variable content is associated with a corresponding service scenario to generate a variable content of the service scenario, and the variable content is stored in a local storage, one implementation manner of classification of the service scenario is to classify the variable content according to different data volumes of the database so as to simulate generation and operation of service codes in databases of different data volumes, then when a fixed content of a component is obtained, the variable contents of a plurality of service scenarios can be selected, the fixed content is combined with the variable contents of a plurality of different service scenarios, the combined content is filled in a preset position of the service template to generate service templates of different service scenarios, thereby rapidly completing template development in different service scenarios, and finishing the generation of codes corresponding to different service scenes.
In one embodiment, after the step S40 generates the service code having the corresponding format and content according to the service template, the method further includes:
running the service code;
monitoring whether the operation of the service code has errors;
if yes, locating the fixed content and/or the variable content with the error.
In this embodiment, after a service code is generated, the service code is run in a development environment, and then whether an error occurs in the running of the service code is monitored, if an error occurs in the service code during the running, the content in which the error occurs is quickly located by monitoring the service code, and it is determined whether a fixed content part or a variable content part in which the error occurs, and if the error occurs is the fixed content, the fixed content is modified in a service template; if the error is variable content, acquiring the input variable, the operation variable and the output variable in the execution process of the variable content, and positioning the specific error problem through monitoring the input, the operation and the output to facilitate maintenance of the service code, thereby improving the accuracy of the generated service code and the maintenance efficiency of the service code.
In one embodiment, the error is a fixed content of the service code; after the locating the fixed content and/or the variable content with the error, the method further comprises the following steps:
matching the corresponding modification scheme according to the error;
acquiring different service templates with the fixed content with errors;
and applying the modification scheme to different service templates with the fixed content to complete the modification of the service templates.
In this embodiment, after monitoring that an error occurs in the operation of the service code, the fixed content in which the error occurs is located, when the fixed content in one template has an error, the error also occurs in other templates to which the fixed content is applied, at this time, a corresponding modification scheme is matched according to the error that occurs, different service templates having the fixed content in which the error occurs are obtained, then the modification scheme is applied to different service templates having the fixed content, the modification of the fixed content in which the error occurs in different service templates is completed, and by monitoring whether the error occurs in the service code of one service template, whether the error occurs in other service templates having the same content can be monitored, so that the service code in which the error occurs in different service templates is quickly found out and the modification of the service code in which the error occurs is completed, and the maintenance efficiency of the service codes is improved.
Referring to fig. 3, the present application further provides a device for generating a service code, including:
the data configuration module 10: the system comprises a database, a console and a database server, wherein the database is used for responding to a data connection mode and a data table attribute input in the console and configuring the database according to the data connection mode and the data table attribute;
the parameter association module 20: receiving parameter variables input in a console, and establishing association between the parameter variables and the database to serve as variable content;
the template definition module 30: the system comprises a fixed content acquisition module, a service template generation module and a service module, wherein the fixed content acquisition module is used for acquiring the fixed content of the component, combining the variable content with the fixed content of the component and filling the combined variable content and the fixed content of the component into a preset position of the service template to generate the service template;
the code generation module 40: and the service code is used for generating a service code with a corresponding format and content according to the service template.
As described above, it can be understood that each component of the service code generation apparatus proposed in the present application can implement the step function of any one of the service code generation methods described above.
In one embodiment, the parameter association module 20 further performs:
acquiring a data operation statement in the variable content;
judging the legality of the data operation statement according to the associated parameter variable and a database;
if the code is legal, the control template definition module 30 and the code generation module 40 are executed.
In one embodiment, the template defining module 30 further performs the steps of obtaining fixed contents of a plurality of components, and combining the fixed contents of the plurality of components with corresponding variable contents, respectively, to obtain combined component contents; and filling the combined component content into a preset position of the service template and establishing the association between the components to generate the service template.
In one embodiment, the template definition module 30 further includes a module for acquiring fixed contents of a plurality of components, combining the fixed contents of the plurality of components with corresponding variable contents, and obtaining combined component contents; and filling the combined component content into a preset position of the service template to generate the service template.
In one embodiment, the parameter association module 20 further performs:
associating the variable content with a corresponding service scene to generate variable content under the corresponding service scene;
the template definition module 30 further performs:
and acquiring the fixed content of the assembly, combining the variable content of different service scenes with the fixed content of the assembly, and filling the combined variable content into the preset position of the service template to generate the service templates of different service scenes.
In one embodiment, the apparatus further comprises a monitoring module configured to perform:
running the service code;
monitoring whether the operation of the service code has errors;
if yes, locating the fixed content and/or the variable content with the error.
In one embodiment, the monitoring module is further configured to execute
Matching the corresponding modification scheme according to the error;
acquiring different service templates with the fixed content with errors;
and applying the modification scheme to different service templates with the fixed content to complete the modification of the service templates.
Referring to fig. 4, a computer device, which may be a mobile terminal and whose internal structure may be as shown in fig. 4, is also provided in the embodiment of the present application. The computer equipment comprises a processor, a memory, a network interface, a display device and an input device which are connected through a system bus. Wherein, the network interface of the computer equipment is used for communicating with an external terminal through network connection. The display device of the computer equipment is used for displaying the interactive interface. The input means of the computer device is for receiving input from a user. The computer designed processor is used to provide computational and control capabilities. The memory of the computer device includes non-volatile storage media. The non-volatile storage medium stores an operating system, a computer program, and a database. The computer program, when executed by a processor, implements a method of generating business code.
The processor executes the method for generating the service code, and the method comprises the following steps: responding to a data connection mode and a data table attribute input in a console, and configuring a database according to the data connection mode and the data table attribute; receiving parameter variables input in a console, and establishing association between the parameter variables and the database to serve as variable content; acquiring fixed content of a component, combining the variable content with the fixed content of the component, and filling the combined variable content and the fixed content of the component into a preset position of a service template to generate the service template; and generating a service code with a corresponding format and content according to the service template. The computer equipment provides a method for self-defining a service template so as to automatically generate a service code, a self-defined data connection mode and a data sheet attribute are received through a control console, a database is configured according to the data connection mode and the data sheet attribute, a parameter variable of a self-defined component is received, association is established between the parameter variable and the database to be used as variable content, fixed content of the component is obtained, the variable content and the fixed content of the component are combined into finished component logic and then filled in a preset position of the service template to generate the service template, so that a corresponding service code is quickly generated according to the service template, time and resources consumed by a large amount of repetitive work of same or similar service development are reduced, in addition, the service code generated through the service template can unify the codes of the same service to the greatest extent, the reading of the service codes is facilitated, and further, as the same service codes have a uniform style, if the same service codes need to be modified, the service codes can be rapidly modified, so that the maintenance efficiency of the service codes is improved.
An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by the processor, implements a method for generating a service code, and includes the steps of: responding to a data connection mode and a data table attribute input in a console, and configuring a database according to the data connection mode and the data table attribute; receiving parameter variables input in a console, and establishing association between the parameter variables and the database to serve as variable content; acquiring fixed content of a component, combining the variable content with the fixed content of the component, and filling the combined variable content and the fixed content of the component into a preset position of a service template to generate the service template; and generating a service code with a corresponding format and content according to the service template. The computer readable storage medium provides a method for self-defining a service template so as to automatically generate a service code, a self-defined data connection mode and a data table attribute are received through a console, a database is configured according to the data connection mode and the data table attribute, a parameter variable of a self-defined component is received, association is established between the parameter variable and the database to be used as variable content, fixed content of the component is obtained, the variable content and the fixed content of the component are combined into finished component logic and then filled in a preset position of the service template to generate the service template, so that a corresponding service code is quickly generated according to the service template, time and resources consumed by a large amount of repeated work of same or similar service development are reduced, in addition, the service code generated through the service template can be unified to the same service code to the maximum extent, the reading of the service codes is facilitated, and further, as the same service codes have a uniform style, if the same service codes need to be modified, the service codes can be rapidly modified, so that the maintenance efficiency of the service codes is improved.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware related to instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, the computer program can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium provided herein and used in the examples may include non-volatile and/or volatile memory. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), double-rate SDRAM (SSRSDRAM), Enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and bus dynamic RAM (RDRAM).
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, apparatus, article, or method. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, apparatus, article, or method that includes the element.
The above description is only a preferred embodiment of the present application, and not intended to limit the scope of the present application, and all modifications of equivalent structures and equivalent processes, which are made by the contents of the specification and the drawings of the present application, or which are directly or indirectly applied to other related technical fields, are also included in the scope of the present application.

Claims (10)

1. A method for generating a service code, comprising:
responding to a data connection mode and a data table attribute input in a console, and configuring a database according to the data connection mode and the data table attribute;
receiving parameter variables input in a console, and establishing association between the parameter variables and the database to serve as variable content;
acquiring fixed content of a component, combining the variable content with the fixed content of the component, and filling the combined variable content and the fixed content of the component into a preset position of a service template to generate the service template;
and generating a service code with a corresponding format and content according to the service template.
2. The method for generating service code according to claim 1, wherein the associating the parameter variable with the database as variable content further comprises:
acquiring a data operation statement in the variable content;
judging the legality of the data operation statement according to the associated parameter variable and a database;
if the variable content is legal, performing subsequent acquisition of the fixed content of the component, combining the variable content with the fixed content of the component, and filling the combined variable content and the fixed content of the component into a preset position of a service template to generate the service template; and generating a service code with a corresponding format and content according to the service template.
3. The method for generating a service code according to claim 1, wherein the acquiring fixed content of the component, combining the variable content with the fixed content of the component, and filling the combined variable content and fixed content into a preset position of a service template to generate the service template comprises:
acquiring fixed contents of a plurality of components, and combining the fixed contents of the plurality of components with corresponding variable contents respectively to obtain combined component contents;
and filling the combined component content into a preset position of the service template and establishing the association between the components to generate the service template.
4. The method for generating a service code according to claim 1, wherein the acquiring fixed content of the component, combining the variable content with the fixed content of the component, and filling the combined variable content and fixed content into a preset position of a service template to generate the service template comprises:
acquiring fixed contents of a plurality of components, combining the fixed contents of the plurality of components, and combining the combined fixed contents with corresponding variable contents to obtain combined component contents;
and filling the combined component content into a preset position of the service template to generate the service template.
5. The method for generating service code according to claim 1, wherein said receiving the parameter variable inputted at the console, associating the parameter variable with the database as variable content, further comprises:
associating the variable content with a corresponding service scene to generate variable content under the corresponding service scene;
the fixed content of the component is obtained, the variable content and the fixed content of the component are combined and then filled in a preset position of a service template to generate the service template, which comprises,
and acquiring the fixed content of the assembly, combining the variable content of different service scenes with the fixed content of the assembly, and filling the combined variable content into the preset position of the service template to generate the service templates of different service scenes.
6. The method for generating service codes according to claim 1, wherein after generating the service codes having the corresponding format and content according to the service template, the method further comprises:
running the service code;
monitoring whether the operation of the service code has errors;
if yes, locating the fixed content and/or the variable content with the error.
7. The method of generating a service code according to claim 6, wherein the error is a fixed content of the service code; after the locating the fixed content and/or the variable content with the error, the method further comprises the following steps:
matching the corresponding modification scheme according to the error;
acquiring different service templates with the fixed content with errors;
and applying the modification scheme to different service templates with the fixed content to complete the modification of the service templates.
8. An apparatus for generating a service code, comprising:
a data configuration module: the system comprises a database, a console and a database server, wherein the database is used for responding to a data connection mode and a data table attribute input in the console and configuring the database according to the data connection mode and the data table attribute;
a parameter association module: receiving parameter variables input in a console, and establishing association between the parameter variables and the database to serve as variable content;
a template definition module: the system comprises a fixed content acquisition module, a service template generation module and a service module, wherein the fixed content acquisition module is used for acquiring the fixed content of the component, combining the variable content with the fixed content of the component and filling the combined variable content and the fixed content of the component into a preset position of the service template to generate the service template;
a code generation module: and the service code is used for generating a service code with a corresponding format and content according to the service template.
9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of generating a service code according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of generating a service code according to any one of claims 1 to 7.
CN202011496978.3A 2020-12-17 2020-12-17 Service code generation method and device, computer equipment and storage medium Pending CN112527286A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011496978.3A CN112527286A (en) 2020-12-17 2020-12-17 Service code generation method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011496978.3A CN112527286A (en) 2020-12-17 2020-12-17 Service code generation method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112527286A true CN112527286A (en) 2021-03-19

Family

ID=75001055

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011496978.3A Pending CN112527286A (en) 2020-12-17 2020-12-17 Service code generation method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112527286A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113051354A (en) * 2021-04-09 2021-06-29 金蝶软件(中国)有限公司 Online source searching method and device based on dynamic configuration and computer equipment
CN115357252A (en) * 2022-10-08 2022-11-18 成都数联云算科技有限公司 Source code file generation method and device, electronic equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113051354A (en) * 2021-04-09 2021-06-29 金蝶软件(中国)有限公司 Online source searching method and device based on dynamic configuration and computer equipment
CN115357252A (en) * 2022-10-08 2022-11-18 成都数联云算科技有限公司 Source code file generation method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN110244936B (en) Method and device for supporting VISIO flow chart to automatically import DCS algorithm configuration software
CN112527286A (en) Service code generation method and device, computer equipment and storage medium
CN109062925B (en) Method, device, computer equipment and storage medium for automatically generating insert sentences
CN107179971B (en) Automatic coding method and system for CAN bus fault processing
CN109361628A (en) Message assemble method, device, computer equipment and storage medium
CN104657274A (en) Method and device for testing software interface
CN112528619A (en) Page template file generation method and device, electronic equipment and storage medium
WO2021196674A1 (en) System code testing method and apparatus, and computer device and storage medium
CN114816404A (en) Method and device for dynamically rendering view page, computer equipment and storage medium
CN113656404A (en) Data verification method and device, computer equipment and storage medium
CN113282513B (en) Interface test case generation method and device, computer equipment and storage medium
CN113268409B (en) Method, apparatus, device and medium for tracking logical nodes during automated testing
CN115860451A (en) Flow operation method and device, electronic equipment and storage medium
CN114510536A (en) Data verification method and device, computer equipment and storage medium
CN115525534A (en) Test case generation method and platform based on swagger interface test
CN111324540B (en) Interface testing method and device
CN110865943A (en) Interface testing method and device, computer equipment and storage medium
CN110837500A (en) Data screening method and device based on local embedded window and computer equipment
CN114756183A (en) Data printing method, device, equipment and storage medium
CN114297088A (en) Method, device, equipment and medium for testing front end vue frame assembly
CN113918594A (en) Method and device for generating structured query statement and computer equipment
CN117270956B (en) Configuration method of hardware equipment, client, hardware equipment network management system and medium
CN117234512B (en) Method, system, electronic equipment and storage medium for rapidly developing business
CN116911406B (en) Wind control model deployment method and device, computer equipment and storage medium
CN112905459B (en) Service interface testing method and device, electronic equipment and storage medium

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