WO2018201895A1 - Interface code generation method, apparatus, terminal device and medium - Google Patents

Interface code generation method, apparatus, terminal device and medium Download PDF

Info

Publication number
WO2018201895A1
WO2018201895A1 PCT/CN2018/083549 CN2018083549W WO2018201895A1 WO 2018201895 A1 WO2018201895 A1 WO 2018201895A1 CN 2018083549 W CN2018083549 W CN 2018083549W WO 2018201895 A1 WO2018201895 A1 WO 2018201895A1
Authority
WO
WIPO (PCT)
Prior art keywords
interface
authority
instruction
code
report document
Prior art date
Application number
PCT/CN2018/083549
Other languages
French (fr)
Chinese (zh)
Inventor
张振伟
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2018201895A1 publication Critical patent/WO2018201895A1/en

Links

Classifications

    • 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/25Integrating or interfacing systems involving database management systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code

Definitions

  • the present application belongs to the field of computer technology, and in particular, to an interface code generation method, device, terminal device and medium.
  • API management tools In the WEB development mode separated from the front and the back, developers usually need to define interface documents to regulate their interface forms, such as interface address, parameters, types, meanings, and so on. In order to enable developers to manage interface documents more efficiently, various API management tools have emerged. After using the visualization tool provided by the API management tool to enter and maintain the interface document, by analyzing the interface structure corresponding to the interface document, in addition to automatically generating reusable Mock data, the correctness of the real interface can be automatically verified. Therefore, the emergence of API management tools has improved the development efficiency of developers to some extent.
  • the developer can enter and maintain the interface document through the visualization tool provided by the API management tool, the defined interface document cannot be directly synchronized into the code, so it is difficult to further improve the development efficiency.
  • the embodiment of the present application provides an interface code generation method, device, terminal device, and medium, so as to solve the problem that the interface document defined in the prior art cannot be directly synchronized into the code, thereby making it difficult to further improve the developer.
  • a first aspect of the embodiment of the present application provides a method for generating an interface code, including:
  • the updated interface field is populated with a code template such that the code template generates an interface code that matches the updated interface field.
  • a second aspect of the embodiments of the present application provides an interface code generating apparatus, including:
  • a maintenance module configured to establish, according to a predefined interface structure, an interface field corresponding to the interface structure in a database
  • An exporting module configured to export the interface field by using a report generation tool to generate a report document, and receive an interface field modification instruction issued by the user in the report document, and perform an interface field modification on the report document;
  • An update module configured to import the modified report document, and update an interface field in the database according to the modified report document;
  • a first generating module configured to fill the updated interface field with a code template, so that the code template generates an interface code that matches the updated interface field.
  • a third aspect of the embodiments of the present application provides a terminal device, including a memory and a processor, where the computer stores computer readable instructions executable on the processor, the processor executing the computer
  • the steps of the interface code generation method as described in the first aspect are implemented when the instruction is read.
  • a fourth aspect of the embodiments of the present application provides a computer readable storage medium storing computer readable instructions, the computer readable instructions being executed by a processor to implement the first aspect as described in the first aspect The steps of the interface code generation method.
  • the interface field is exported to generate a report document, and the modified report file is imported, and the interface field is synchronously updated in the database according to the interface field modified by the user in the report document, so that the development is performed.
  • the personnel need not be limited by the visualization tools provided by the API management tool, and can flexibly input and modify the interface fields in the report document at any time, thereby improving the maintenance efficiency of the interface fields in the database; by filling the interface fields in the report document with the code
  • the code template can be used to automatically generate the interface code, which ensures that the defined interface document can be directly synchronized into the code. Therefore, the development efficiency of the developer is further improved compared with the existing API management tool.
  • FIG. 1 is a flowchart of an implementation of an interface code generation method provided by an embodiment of the present application
  • FIG. 3 is a flowchart of an implementation of an interface code generating method according to another embodiment of the present application.
  • FIG. 4 is a flowchart of an implementation of an interface code generating method provided by another embodiment of the present application.
  • FIG. 5 is a flowchart of a specific implementation of an interface code generating method S403 according to another embodiment of the present disclosure
  • FIG. 6 is a structural block diagram of an interface code generating apparatus according to an embodiment of the present application.
  • FIG. 7 is a schematic structural diagram of a terminal device according to an embodiment of the present application.
  • FIG. 1 shows an implementation flow of an interface code generating method provided by an embodiment of the present application, where the method flow includes steps S101 to S104.
  • the specific implementation principles of each step are as follows:
  • S101 Establish an interface field corresponding to the interface structure in a database based on a predefined interface structure.
  • the interface is a shared boundary between the database and the external system for information exchange.
  • An interface is a declaration of a series of methods. It is a collection of method features. An interface has only the features of the method and no method implementation. Therefore, these methods can be implemented in different places in different places, and these implementations can have different functions.
  • the external system can implement these methods by calling the interface provided by the database and based on the parameters corresponding to each method in the interface, so as to achieve the functions required by the external system.
  • the data table and fields that the database should establish and maintain are determined by obtaining the interface structure predefined by the user in the database management interface or the configuration file.
  • the predefined interface structure includes basic attributes such as table name, field, type, primary key, foreign key, and index.
  • the template is generated according to the preset SQL statement, and each basic attribute corresponding to the interface structure is read, and each basic attribute is filled into the SQL statement generation template to output a corresponding SQL execution statement. Thereafter, the system executes the SQL execution statement, creates a new data table in the database with the table name, creates fields matching the types in the data table, and establishes primary keys, foreign keys, indexes, and the like. Therefore, based on the predefined interface structure, maintenance of the interface field corresponding to the interface structure is implemented in the database.
  • S102 Export the interface field by using a report generation tool to generate a report document, and receive an interface field modification instruction sent by the user in the report document, and modify an interface field of the report document.
  • the export of the interface field in the database is implemented by the report generation tool.
  • Report generation tools include, but are not limited to, Java-based open source reporting tool JasperReports, BI suite Pentaho, JasperReports as a report generation engine and Web-based reporting solution OpenReports, Java class library Pentaho Reporting, Eclipse-based open source reporting system BIRT, and Excel report generation tool based on Jakarta POI API.
  • the report generation tool in the embodiment of the present application is based on Jakarta.
  • the Excel report generation tool of the POI API which is also the JXLS framework.
  • the data table maintained by the database is processed based on the JXLS framework, and each interface field in the database is regarded as a java entity class, and the java entity class is exported to generate an Excel report document.
  • the field name and the field type of each interface field in the data table are exported, and the interface field name is exported as a row name or a column name of the Excel report document, and the specific field type is exported as a row or column corresponding to the report document.
  • the exported Excel report document is stored in the storage path specified by the user in the system.
  • the user wants to view the interface fields of each data table in the database in the system or in other external environments, it can be realized by transmitting and viewing the exported Excel report documents corresponding to each data table.
  • the user can visually view the interface fields displayed by the Excel report document and the specific field types without entering the SQL statement specifying the grammar rules in the database.
  • the database requires high security, by exporting the interface fields to the Excel report document for external system developers to view, it is possible to avoid the external system needs to connect to the database in real time to view the interface fields in the table, and ensure that only when necessary. Allows external system developers to connect to the database, thus increasing the security of the database.
  • the interface field can be modified in the Excel report document.
  • the modification of the interface field includes, but is not limited to, adding an interface field, deleting an interface field, and modifying attributes such as a field name and a field type of the interface field.
  • the user-edited Excel report document is imported into the specified storage path of the system. Reading the data table name corresponding to the report document and each first interface field, and at the same time, reading each second interface field corresponding to the data table from the database according to the data table name, and each of the first An interface field is compared with each second interface field, or each second interface field is compared with each first interface field. If there is no second interface field that is the same as the first interface field, it indicates that the first interface field is a new field, so the newly added field is automatically built in the data table of the database.
  • the second interface field is an interface field that the user needs to delete, so in the table of the database, the preset SQL statement is invoked, and the field is deleted. .
  • the data table is deleted by using a preset SQL statement, such as a DROP TABLE statement, and then reconstructed by using a CREATE statement. To store a new data table in the database that completely matches each of the first interface fields in the Excel report document.
  • the field name of the first interface field in the Excel report document is the same as the field name of the second interface field in the data table, and the field type of the first interface field is different from the field type of the second interface field, it indicates that the user only
  • the type of the interface field is modified, so in the table of the database, it is determined whether the data of the field type of the second interface field can be converted into the data of the field type of the first interface field, and if so, the default SQL is used.
  • a statement such as a CAST statement or a CONVERT statement, modifies the field type. If the data of the field type of the second interface field cannot be converted to the data of the field type of the first interface field, an error message is issued.
  • the field type of the second interface field is an integer and the field type of the first interface field is a string type, it is determined that the integer data can be converted into data of a string type; if the field type of the second interface field is Floating point type, the field type of the first interface field is integer, the decimal point data loss occurs when the floating point data is converted into integer data, which reduces the precision of the original data storage, thus determining the floating point type. The data cannot be converted to integer data.
  • the foregoing S103 specifically includes:
  • the system sends a conflict alert to the end user a and the end user b respectively, prompting the user whether to merge the report documents.
  • the system merges the document 1 and the document 2, that is, summarizes all the interface fields and interface types in the document 1 and the document 2 in one report document.
  • the report document is imported into the database, so that the interface field maintained in the database is updated according to the same implementation principle of the above S103.
  • S104 Fill the updated interface field with a code template, so that the code template generates an interface code that matches the updated interface field.
  • the code template is a Velocity template.
  • the Velocity template is a Java-based engine framework that provides a template language that can be used on objects and variables defined in Java.
  • an xml file corresponding to the data table is obtained, and the xml file includes the label of each interface field.
  • Call the Velocity template use the ant task Anakia in the Velocity template to read the pre-generated xml file, and then automatically fill each interface field in the xml file into the Velocity template after reading, and generate the matching with the interface field. Interface code.
  • a Velocity template filled with each interface field is read, and an interface field in the Velocity template is transmitted into the Java project file, thereby generating a corresponding Java interface code. It can be seen that the interface structure of the generated Java interface code is the same as the interface structure defined in the Excel report document.
  • the interface field is exported to generate a report document, and the modified report file is imported, and the interface field is synchronously updated in the database according to the interface field modified by the user in the report document, so that the development is performed.
  • the personnel need not be limited by the visualization tools provided by the API management tool, and can flexibly input and modify the interface fields in the report document at any time, thereby improving the maintenance efficiency of the interface fields in the database; by filling the interface fields in the report document with the code
  • the code template can be used to automatically generate the interface code, which ensures that the defined interface document can be directly synchronized into the code. Therefore, the development efficiency of the developer is further improved compared with the existing API management tool.
  • FIG. 3 shows an implementation flow of an interface code generating method provided by an embodiment of the present application. As shown in FIG. 3, after the above S104, the method further includes step S105 and step S106, as follows:
  • S105 Store the interface code to obtain a code file, and generate a version number of the code file.
  • the version number is an identification number for the code version.
  • Each generated interface code and code file has a version number.
  • the version number is used to let developers know if the interface code they are calling is a version of their own. And, according to the version number, the user can query the function note corresponding to the version number from the record table, so that based on the interface code and the version number of the code file, it can be determined whether the function provided by the interface code is one of the required ones.
  • the code file is a Java project file.
  • the system reads a version number that is not allocated for use from the preset version of the version number, so that the version number is used as a version number of the interface code generated at the current time, and the system uses This version number is the version number of the code file corresponding to the interface code.
  • the system will generate the version number as the file name of the Java project file, and at the same time comment the version number in the interface code of the Java project file.
  • the interface details page displayed by the system each Java project file and its corresponding version number are displayed.
  • the developer by generating and displaying the version number of the code file, the developer is prompted by the version, so that when the interface is upgraded, the developer can intuitively understand the call by the version number displayed by the system.
  • the interface code is the latest version of the interface, to ensure that different developers can perform development operations based on the same interface code with the same version number, to avoid the inconsistency of the interface code version number.
  • the method further includes:
  • S401 Acquire an account right of the user when receiving a call instruction issued by the user based on the interface code.
  • the project information indicates the function used by the interface code file and the specific information of the software development project corresponding to the interface code file.
  • the project information can be information such as the person in charge of the project, members of the project team, and project introduction.
  • the interface information includes the comment content of the interface code and the interface code itself.
  • the user When it is detected that the user invokes the interface code to manage the information in the data table through the database interface corresponding to the interface code, or manages the project information and the interface information of the interface code, the user is authenticated. At this time, the management account currently used by the user is obtained, and the management account is matched from the preset account permission list, thereby determining the account authority corresponding to the management account. Wherein, when each management account is generated, the account authority corresponding to the management account is preset by the database administrator in the account permission list.
  • the account rights corresponding to the management account include the first authority and the second authority.
  • the account privilege list does not match the management account currently used by the user, the account privilege corresponding to the management account is a null value, or the account privilege corresponding to the management account is an illegal privilege, determining that the account privilege of the user is the above First permission.
  • the first authority indicates that the user is restricted to view and manage the association information of the interface code, and the association information of the interface code includes the interface information and the item information. Therefore, the system will not respond to any call instructions issued by the user.
  • the second authority indicates that the user is allowed to view and manage part of the association information or all the associated information of the interface code.
  • the second rights include view rights, partial management rights, and management rights.
  • FIG. 5 shows a specific implementation flow of the interface code generating method S403 according to another embodiment of the present application, which is described in detail as follows:
  • the foregoing interface code-based calling instruction includes an interface information viewing instruction, an interface information management instruction, and a project information management instruction, where the second authority includes a viewing authority, a partial management authority, and a management authority.
  • the account authority When it is confirmed from the account permission list that the account authority corresponding to the management account used by the user is the viewing permission, only the interface information viewing permission based on the interface code is opened to the user, and other management rights of the interface code are not opened.
  • the account authority is the viewing authority
  • the calling instruction received by the system is the interface information viewing instruction
  • the interface information of the interface code is displayed, so that the user is in the read-only state. The interface information can be viewed, and the interface information cannot be modified.
  • the response instruction is rejected, that is, the call instruction is not responded.
  • the account authority corresponding to the management account used by the user is part of the management authority, only the interface information management and viewing rights based on the interface code are opened to the user, and the project information management of the interface code is not opened. Permissions.
  • the account authority is part of the management authority, if the calling instruction received by the system is an interface information viewing instruction or an interface information management instruction, the interface information of the interface code is displayed after responding to the calling instruction. If the calling instruction received by the system is an interface information management instruction, the interface information of the interface code is modified and updated according to the specific information carried by the interface information management instruction.
  • the call instruction received by the system is a project information management instruction
  • the call instruction is rejected, that is, the call instruction is not responded.
  • the account authority corresponding to the management account used by the user is the management authority
  • all management rights based on the interface code are opened to the user, including the management of the interface information, the viewing authority, and the management of the project information. permission.
  • the call instruction received by the system responds to the call instruction regardless of whether the call instruction is an interface information view instruction, an interface information management instruction, or a project information management instruction.
  • the interface code generation method provided by the embodiment of the present application can make up for the inadequacies of the existing API management tools and improve the security of the interface code.
  • FIG. 6 is a structural block diagram of the interface code generating apparatus provided by the embodiment of the present application. For the convenience of description, only parts related to the embodiment of the present application are shown.
  • the apparatus includes:
  • the maintenance module 61 is configured to establish an interface field corresponding to the interface structure in a database based on a predefined interface structure.
  • the exporting module 62 is configured to export the interface field by using a report generation tool to generate a report document, and receive an interface field modification instruction issued by the user in the report document, and perform an interface field modification on the report document.
  • the update module 63 is configured to import the modified report document, and update the interface field in the database according to the modified report document.
  • the first generating module 64 is configured to fill the updated interface field to the code template, so that the code template generates an interface code that matches the updated interface field.
  • the interface code generating apparatus further includes:
  • a second generating module configured to store the interface code to obtain a code file, and generate a version number of the code file.
  • a display module for displaying a version number of the code file.
  • the updating module 63 includes:
  • a merge sub-module configured to issue a conflict alert prompt if two or more modified report documents are imported at the same time, and when the report document merge instruction is received, the two or more modified report documents are Perform the merge process.
  • the update submodule is configured to update the interface field in the database according to the merged report document.
  • the interface code generating apparatus further includes:
  • the obtaining module is configured to acquire the account authority of the user when receiving a call instruction by the user based on the interface code.
  • the first privilege module is configured to refuse to respond to the call instruction if the account privilege is the first privilege.
  • the second privilege module is configured to respond to the call instruction if the account privilege is the second privilege.
  • the second authority includes a view authority, a part of the management authority, and an administrative authority, where the call instruction includes an interface information view instruction, an interface information management instruction, and a project information management instruction, where the second permission module includes:
  • the first response submodule is configured to respond to the interface information viewing instruction if the account authority is the viewing permission.
  • the second response submodule is configured to respond to the interface information viewing instruction and the interface information management instruction if the account authority is a partial management authority.
  • the third response submodule is configured to respond to the interface information viewing instruction, the interface information management instruction, and the item information management instruction if the account authority is a management authority.
  • FIG. 7 is a schematic diagram of a terminal device according to an embodiment of the present application.
  • the terminal device 7 of this embodiment includes a processor 70 and a memory 71 in which computer readable instructions 72, such as an interface code generation program, executable on the processor 70 are stored.
  • the processor 70 executes the computer readable instructions 72 to implement the steps in the various interface code generation method embodiments described above, such as steps 101 through 104 shown in FIG.
  • the processor 70 when executing the computer readable instructions 72, implements the functions of the various modules/units in the various apparatus embodiments described above, such as the functions of the modules 61-64 shown in FIG.
  • the computer readable instructions 72 may be partitioned into one or more modules/units that are stored in the memory 71 and executed by the processor 70, To complete this application.
  • the one or more modules/units may be a series of computer readable instruction segments capable of performing a particular function for describing the execution of the computer readable instructions 72 in the terminal device 7.
  • the terminal device 7 may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server.
  • the terminal device may include, but is not limited to, the processor 70 and the memory 71. It will be understood by those skilled in the art that FIG. 7 is only an example of the terminal device 7, and does not constitute a limitation of the terminal device 7, and may include more or less components than those illustrated, or combine some components or different components.
  • the terminal device may further include an input/output device, a network access device, a bus, and the like.
  • the so-called processor 70 can be a central processing unit (Central Processing Unit, CPU), can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (Application Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, etc.
  • the general purpose processor may be a microprocessor or the processor or any conventional processor or the like.
  • the memory 71 may be an internal storage unit of the terminal device 7, such as a hard disk or a memory of the terminal device 7.
  • the memory 71 may also be an external storage device of the terminal device 7, for example, a plug-in hard disk provided on the terminal device 7, a smart memory card (SMC), and a secure digital (SD). Card, flash card, etc. Further, the memory 71 may also include both an internal storage unit of the terminal device 7 and an external storage device.
  • the memory 71 is configured to store the computer readable instructions and other programs and data required by the terminal device.
  • the memory 71 can also be used to temporarily store data that has been output or is about to be output.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
  • the integrated unit if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium.
  • a computer readable storage medium A number of instructions are included to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present application.
  • the foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like, which can store program codes. .

Abstract

The present invention is applicable to the technical field of computers, and a solution thereof provides an interface code generation method, apparatus, terminal device and a medium. The method comprises: establishing, on the basis of a pre-defined interface structure, an interface field corresponding to the interface structure in a database; exporting the interface field by using a report generation tool so as to generate a report document; receiving, in the report document, an interface field modification instruction sent by a user and performing interface field modification on the report document; importing the modified report document and updating the interface field in the database according to the modified report document; and filling the updated interface field into a code template so as to generate an interface code matching with the interface field. The solution allows a developer to escape the limitations of visualization tools and to be able to flexibly edit interface fields in a report document at any time, thus increasing maintenance efficiency of interface fields; since the defined interface document can be directly synchronized with codes for use, development efficiency of developers is improved.

Description

接口代码生成方法、装置、终端设备及介质Interface code generation method, device, terminal device and medium
本申请要求于2017年05月05日提交中国专利局、申请号为201710312852.8、发明名称为“接口代码生成方法及终端设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。The present application claims priority to Chinese Patent Application No. 200910312852.8, entitled "Interface Code Generation Method and Terminal Device", filed on May 5, 2017, the entire contents of which is incorporated herein by reference. .
技术领域Technical field
本申请属于计算机技术领域,尤其涉及一种接口代码生成方法、装置、终端设备及介质。The present application belongs to the field of computer technology, and in particular, to an interface code generation method, device, terminal device and medium.
背景技术Background technique
在前后端分离的WEB开发模式中,开发人员通常需要定义接口文档来规范其接口形式,如接口地址、参数、类型、含义等。为了使开发人员能够更为高效地管理接口文档,各种API管理工具应运而生。在利用API管理工具所特定提供的可视化工具录入并维护接口文档后,通过分析接口文档对应的接口结构,除了能够自动生成可重复利用的Mock数据之外,还可以自动校验真实接口的正确性,因此,API管理工具的出现,在一定程度上提高了开发人员的开发效率。In the WEB development mode separated from the front and the back, developers usually need to define interface documents to regulate their interface forms, such as interface address, parameters, types, meanings, and so on. In order to enable developers to manage interface documents more efficiently, various API management tools have emerged. After using the visualization tool provided by the API management tool to enter and maintain the interface document, by analyzing the interface structure corresponding to the interface document, in addition to automatically generating reusable Mock data, the correctness of the real interface can be automatically verified. Therefore, the emergence of API management tools has improved the development efficiency of developers to some extent.
然而,开发人员虽然能通过API管理工具所特定提供的可视化工具录入并维护接口文档,但定义好的接口文档却无法直接同步到代码中使用,因而难以再进一步地提高开发效率。However, although the developer can enter and maintain the interface document through the visualization tool provided by the API management tool, the defined interface document cannot be directly synchronized into the code, so it is difficult to further improve the development efficiency.
技术问题technical problem
有鉴于此,本申请实施例提供了一种接口代码生成方法、装置、终端设备及介质,以解决现有技术中定义好的接口文档无法直接同步到代码中使用,因而难以进一步地提高开发人员的开发效率的问题。In view of this, the embodiment of the present application provides an interface code generation method, device, terminal device, and medium, so as to solve the problem that the interface document defined in the prior art cannot be directly synchronized into the code, thereby making it difficult to further improve the developer. The problem of development efficiency.
技术解决方案Technical solution
本申请实施例的第一方面提供了一种接口代码生成方法,包括:A first aspect of the embodiment of the present application provides a method for generating an interface code, including:
基于预先定义的接口结构,在数据库中建立与所述接口结构对应的接口字段;Establishing an interface field corresponding to the interface structure in a database based on a predefined interface structure;
将所述接口字段通过报表生成工具导出,以生成报表文档,在所述报表文档中接收用户发出的接口字段修改指令,对所述报表文档进行接口字段修改;Exporting the interface field by using a report generation tool to generate a report document, and receiving an interface field modification instruction issued by the user in the report document, and modifying an interface field of the report document;
导入修改后的所述报表文档,并根据修改后的所述报表文档,对所述数据库中的接口字段进行更新;Importing the modified report document, and updating the interface field in the database according to the modified report document;
将更新后的所述接口字段填充至代码模板,以使所述代码模板生成与更新后的所述接口字段相匹配的接口代码。The updated interface field is populated with a code template such that the code template generates an interface code that matches the updated interface field.
本申请实施例的第二方面提供了一种接口代码生成装置,包括:A second aspect of the embodiments of the present application provides an interface code generating apparatus, including:
维护模块,用于基于预先定义的接口结构,在数据库中建立与所述接口结构对应的接口字段;a maintenance module, configured to establish, according to a predefined interface structure, an interface field corresponding to the interface structure in a database;
导出模块,用于将所述接口字段通过报表生成工具导出,以生成报表文档,在所述报表文档中接收用户发出的接口字段修改指令,对所述报表文档进行接口字段修改;An exporting module, configured to export the interface field by using a report generation tool to generate a report document, and receive an interface field modification instruction issued by the user in the report document, and perform an interface field modification on the report document;
更新模块,用于导入修改后的所述报表文档,并根据修改后的所述报表文档,对所述数据库中的接口字段进行更新;An update module, configured to import the modified report document, and update an interface field in the database according to the modified report document;
第一生成模块,用于将更新后的所述接口字段填充至代码模板,以使所述代码模板生成与更新后的所述接口字段相匹配的接口代码。And a first generating module, configured to fill the updated interface field with a code template, so that the code template generates an interface code that matches the updated interface field.
本申请实施例的第三方面提供了一种终端设备,包括存储器以及处理器,所述存储器中存储有可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现如第一方面所述的接口代码生成方法的步骤。A third aspect of the embodiments of the present application provides a terminal device, including a memory and a processor, where the computer stores computer readable instructions executable on the processor, the processor executing the computer The steps of the interface code generation method as described in the first aspect are implemented when the instruction is read.
本申请实施例的第四方面提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可读指令,所述计算机可读指令被处理器执行时实现如第一方面所述的接口代码生成方法的步骤。A fourth aspect of the embodiments of the present application provides a computer readable storage medium storing computer readable instructions, the computer readable instructions being executed by a processor to implement the first aspect as described in the first aspect The steps of the interface code generation method.
有益效果Beneficial effect
本申请实施例中,通过将接口字段导出以生成报表文档,对用户修改后的报表文档进行导入,并根据报表文档中用户所修改的接口字段,在数据库中实现接口字段的同步更新,使得开发人员无须受到API管理工具所特定提供的可视化工具的限制,能够灵活地在报表文档中随时录入并修改接口字段,提高了数据库中接口字段的维护效率;通过将报表文档中的接口字段填充至代码模板中,能够利用代码模板自动生成接口代码,保证了定义好的接口文档能够直接同步到代码中使用,因此,与现有的API管理工具相比,进一步地提高开发人员的开发效率。In the embodiment of the present application, the interface field is exported to generate a report document, and the modified report file is imported, and the interface field is synchronously updated in the database according to the interface field modified by the user in the report document, so that the development is performed. The personnel need not be limited by the visualization tools provided by the API management tool, and can flexibly input and modify the interface fields in the report document at any time, thereby improving the maintenance efficiency of the interface fields in the database; by filling the interface fields in the report document with the code In the template, the code template can be used to automatically generate the interface code, which ensures that the defined interface document can be directly synchronized into the code. Therefore, the development efficiency of the developer is further improved compared with the existing API management tool.
附图说明DRAWINGS
图1是本申请实施例提供的接口代码生成方法的实现流程图;1 is a flowchart of an implementation of an interface code generation method provided by an embodiment of the present application;
图2是本申请实施例提供的接口代码生成方法S103的具体实现流程图;2 is a specific implementation flowchart of an interface code generating method S103 provided by an embodiment of the present application;
图3是本申请另一实施例提供的接口代码生成方法的实现流程图;3 is a flowchart of an implementation of an interface code generating method according to another embodiment of the present application;
图4是本申请又一实施例提供的接口代码生成方法的实现流程图;4 is a flowchart of an implementation of an interface code generating method provided by another embodiment of the present application;
图5是本申请又一实施例提供的接口代码生成方法S403的具体实现流程图;FIG. 5 is a flowchart of a specific implementation of an interface code generating method S403 according to another embodiment of the present disclosure;
图6是本申请实施例提供的接口代码生成装置的结构框图;FIG. 6 is a structural block diagram of an interface code generating apparatus according to an embodiment of the present application;
图7是本申请实施例提供的终端设备的结构示意图。FIG. 7 is a schematic structural diagram of a terminal device according to an embodiment of the present application.
本发明的实施方式Embodiments of the invention
为了说明本申请所述的技术方案,下面通过具体实施例来进行说明。In order to explain the technical solutions described in the present application, the following description will be made by way of specific embodiments.
图1示出了本申请实施例提供的接口代码生成方法的实现流程,该方法流程包括步骤S101至S104。各步骤的具体实现原理如下:FIG. 1 shows an implementation flow of an interface code generating method provided by an embodiment of the present application, where the method flow includes steps S101 to S104. The specific implementation principles of each step are as follows:
S101:基于预先定义的接口结构,在数据库中建立与所述接口结构对应的接口字段。S101: Establish an interface field corresponding to the interface structure in a database based on a predefined interface structure.
本申请实施例中,接口是数据库与外部系统进行信息交换的共享边界。接口是一系列方法的声明,是一些方法特征的集合,一个接口只有方法的特征没有方法的实现,因此这些方法可以在不同的地方被不同的类实现,而这些实现可以具有不同的功能。外部系统通过调用数据库所提供的接口,并基于接口中各方法对应的参数,能够对这些方法进行实现,从而达到外部系统所需实现的功能。为了保证接口中各方法的参数有着相应存在于数据库中的字段,通过获取用户在数据库管理界面或配置文件中所预先定义的接口结构,确定数据库应当建立及维护的数据表及字段。其中,预先定义的接口结构包括表名、字段、类型、主键、外键以及索引等基本属性。In the embodiment of the present application, the interface is a shared boundary between the database and the external system for information exchange. An interface is a declaration of a series of methods. It is a collection of method features. An interface has only the features of the method and no method implementation. Therefore, these methods can be implemented in different places in different places, and these implementations can have different functions. The external system can implement these methods by calling the interface provided by the database and based on the parameters corresponding to each method in the interface, so as to achieve the functions required by the external system. In order to ensure that the parameters of each method in the interface have corresponding fields existing in the database, the data table and fields that the database should establish and maintain are determined by obtaining the interface structure predefined by the user in the database management interface or the configuration file. Among them, the predefined interface structure includes basic attributes such as table name, field, type, primary key, foreign key, and index.
根据预设的SQL语句生成模板,读取上述接口结构对应的各个基本属性,并将各个基本属性分别填充至该SQL语句生成模板,以输出相应的SQL执行语句。此后,系统执行该SQL执行语句,以该表名在数据库中创建一个新的数据表,并在该数据表中创建与各类型相匹配的字段,以及建立主键、外键、索引等。因此,基于预先定义的接口结构,在数据库中,实现了对与该接口结构对应的接口字段的维护。The template is generated according to the preset SQL statement, and each basic attribute corresponding to the interface structure is read, and each basic attribute is filled into the SQL statement generation template to output a corresponding SQL execution statement. Thereafter, the system executes the SQL execution statement, creates a new data table in the database with the table name, creates fields matching the types in the data table, and establishes primary keys, foreign keys, indexes, and the like. Therefore, based on the predefined interface structure, maintenance of the interface field corresponding to the interface structure is implemented in the database.
S102:将所述接口字段通过报表生成工具导出,以生成报表文档,在所述报表文档中接收用户发出的接口字段修改指令,对所述报表文档进行接口字段修改。S102: Export the interface field by using a report generation tool to generate a report document, and receive an interface field modification instruction sent by the user in the report document, and modify an interface field of the report document.
本申请实施例中,通过报表生成工具实现对数据库中接口字段的导出。报表生成工具包含但不限于基于Java的开源报表工具JasperReports、BI套件Pentaho、以JasperReports作为报表生成引擎且基于Web的报表解决方案OpenReports、Java类库Pentaho Reporting、Eclipse-based开放源代码报表系统BIRT以及基于Jakarta POI API的Excel报表生成工具等。优选地,本申请实施例中的报表生成工具为基于Jakarta POI API的Excel报表生成工具,该Excel报表生成工具也即JXLS框架。In the embodiment of the present application, the export of the interface field in the database is implemented by the report generation tool. Report generation tools include, but are not limited to, Java-based open source reporting tool JasperReports, BI suite Pentaho, JasperReports as a report generation engine and Web-based reporting solution OpenReports, Java class library Pentaho Reporting, Eclipse-based open source reporting system BIRT, and Excel report generation tool based on Jakarta POI API. Preferably, the report generation tool in the embodiment of the present application is based on Jakarta. The Excel report generation tool of the POI API, which is also the JXLS framework.
基于JXLS框架对数据库所维护的数据表进行处理,将数据库中的各接口字段作为一个java实体类,并将java实体类导出,以生成Excel报表文档。具体地,将数据表中的各个接口字段的字段名以及字段类型导出,将接口字段名导出为Excel报表文档的行名或列名,将具体的字段类型导出为报表文档中行或列所对应的字段内容。The data table maintained by the database is processed based on the JXLS framework, and each interface field in the database is regarded as a java entity class, and the java entity class is exported to generate an Excel report document. Specifically, the field name and the field type of each interface field in the data table are exported, and the interface field name is exported as a row name or a column name of the Excel report document, and the specific field type is exported as a row or column corresponding to the report document. Field content.
导出的Excel报表文档存储于系统中由用户所指定的存放路径。当用户想要在系统或在其他外部环境中查看数据库中各数据表的接口字段时,可通过传输并查看各数据表对应导出的Excel报表文档来实现。用户无需在数据库中输入指定语法规则的SQL语句即能直观地查看Excel报表文档所显示的接口字段以及具体的字段类型。同时,由于数据库要求较高的安全性,因而通过将接口字段导出至Excel报表文档供外部系统开发者查看,能够避免外部系统需要实时连接数据库才能查看表中接口字段,保证只有在必要时刻下才允许外部系统开发者连接数据库,因此提高了数据库的安全性。The exported Excel report document is stored in the storage path specified by the user in the system. When the user wants to view the interface fields of each data table in the database in the system or in other external environments, it can be realized by transmitting and viewing the exported Excel report documents corresponding to each data table. The user can visually view the interface fields displayed by the Excel report document and the specific field types without entering the SQL statement specifying the grammar rules in the database. At the same time, because the database requires high security, by exporting the interface fields to the Excel report document for external system developers to view, it is possible to avoid the external system needs to connect to the database in real time to view the interface fields in the table, and ensure that only when necessary. Allows external system developers to connect to the database, thus increasing the security of the database.
由于Excel报表文档具有可编辑性,故用户在查看了该Excel报表文档且需要对数据库中的接口字段进行修改时,可先在Excel报表文档中对各接口字段进行修改。其中,对接口字段的修改包括但不限于增加接口字段、删除接口字段以及对接口字段的字段名、字段类型等属性进行修改。当用户在Excel报表文档中执行上述修改操作时,在所述报表文档中,则接收到用户发出的接口字段修改指令,并根据该接口字段修改指令,直接对报表文档中的各接口字段进行修改。Since the Excel report document is editable, when the user views the Excel report document and needs to modify the interface field in the database, the interface field can be modified in the Excel report document. The modification of the interface field includes, but is not limited to, adding an interface field, deleting an interface field, and modifying attributes such as a field name and a field type of the interface field. When the user performs the above modification operation in the Excel report document, in the report document, the interface field modification instruction sent by the user is received, and the interface field in the report document is directly modified according to the interface field modification instruction. .
S103:导入修改后的所述报表文档,并根据修改后的所述报表文档,对所述数据库中的接口字段进行更新。S103: Import the modified report document, and update an interface field in the database according to the modified report document.
基于JXLS框架,将用户编辑后的Excel报表文档导入至系统的指定存储路径。读取报表文档所对应的数据表名以及各个第一接口字段,与此同时,根据该数据表名,从数据库中读取该数据表所实际对应的各个第二接口字段,并将每个第一接口字段分别与各第二接口字段进行对比,或者将每个第二接口字段分别与各第一接口字段进行对比。若不存在与第一接口字段相同的第二接口字段,则表示该第一接口字段为新增字段,故在数据库的该数据表中,自动构建该新增字段。若不存在与第二接口字段相同的第一接口字段,则表示该第二接口字段为用户需要删除的接口字段,故在数据库的该表中,调用预设的SQL语句,将该字段进行删除。或者,在Excel报表文档中的第一接口字段与数据库中该表的第二接口字段并非完全匹配时,利用预设的SQL语句,如DROP TABLE语句将该数据表删除后再利用CREATE语句进行重建,以在数据库中存储一张完全匹配Excel报表文档中各第一接口字段的新数据表。Based on the JXLS framework, the user-edited Excel report document is imported into the specified storage path of the system. Reading the data table name corresponding to the report document and each first interface field, and at the same time, reading each second interface field corresponding to the data table from the database according to the data table name, and each of the first An interface field is compared with each second interface field, or each second interface field is compared with each first interface field. If there is no second interface field that is the same as the first interface field, it indicates that the first interface field is a new field, so the newly added field is automatically built in the data table of the database. If there is no first interface field that is the same as the second interface field, the second interface field is an interface field that the user needs to delete, so in the table of the database, the preset SQL statement is invoked, and the field is deleted. . Alternatively, when the first interface field in the Excel report document does not exactly match the second interface field of the table in the database, the data table is deleted by using a preset SQL statement, such as a DROP TABLE statement, and then reconstructed by using a CREATE statement. To store a new data table in the database that completely matches each of the first interface fields in the Excel report document.
当Excel报表文档中的第一接口字段的字段名与数据表中的第二接口字段的字段名相同,且第一接口字段的字段类型与该第二接口字段的字段类型不同时,表示用户只对接口字段的类型进行了修改,故在数据库的该表中,判断第二接口字段的字段类型的数据能否转换为第一接口字段的字段类型的数据,若能,则利用预设的SQL语句,如CAST语句或CONVERT语句,对该字段类型进行修改。若第二接口字段的字段类型的数据无法转换为第一接口字段的字段类型的数据,则发出错误提示。When the field name of the first interface field in the Excel report document is the same as the field name of the second interface field in the data table, and the field type of the first interface field is different from the field type of the second interface field, it indicates that the user only The type of the interface field is modified, so in the table of the database, it is determined whether the data of the field type of the second interface field can be converted into the data of the field type of the first interface field, and if so, the default SQL is used. A statement, such as a CAST statement or a CONVERT statement, modifies the field type. If the data of the field type of the second interface field cannot be converted to the data of the field type of the first interface field, an error message is issued.
例如,若第二接口字段的字段类型为整型,第一接口字段的字段类型为字符串类型,则确定整型的数据能够转换为字符串类型的数据;若第二接口字段的字段类型为浮点型,第一接口字段的字段类型为整型,则将浮点型的数据转化为整型的数据时会出现小数点数据丢失的情况,降低了原数据存储的精度,因而确定浮点型的数据不能转换为整型的数据。For example, if the field type of the second interface field is an integer and the field type of the first interface field is a string type, it is determined that the integer data can be converted into data of a string type; if the field type of the second interface field is Floating point type, the field type of the first interface field is integer, the decimal point data loss occurs when the floating point data is converted into integer data, which reduces the precision of the original data storage, thus determining the floating point type. The data cannot be converted to integer data.
作为本申请的一个实施例,如图2所示,上述S103具体包括:As an embodiment of the present application, as shown in FIG. 2, the foregoing S103 specifically includes:
S201:若同一时刻导入两个以上修改后的所述报表文档,则发出冲突告警提示,并在接收到报表文档合并指令时,将所述两个以上修改后的所述报表文档进行合并处理。S201: If two or more modified report documents are imported at the same time, a conflict alert prompt is issued, and when the report document merge instruction is received, the two or more modified report documents are combined.
若同一时刻导入了两个以上修改后的报表文档,则表示在该时刻之前,多个用户均对系统导出的同一份报表文档做出了修改。例如,若系统导出的报表文档被传输至不同的两个终端A和B,分别为终端A和终端B上的文档1和文档2,以分别供终端用户a和终端用户b对报表文档中的接口字段进行查看以及管理,同时,终端用户a和终端用户b在互不知情的情况下均更新了报表文档中的接口字段,则二者将文档1和文档2同时导入系统时,系统无法确定使用哪个报表文档。这种情况下,系统分别向终端用户a和终端用户b发出冲突告警提示,提示用户是否需要对报表文档进行合并处理。在接收到任一用户发出的报表文档合并指令时,系统对文档1和文档2进行合并,即,把文档1和文档2中所有的接口字段以及接口类型汇总于一个报表文档中。If more than two modified report documents are imported at the same time, it means that before this moment, multiple users have modified the same report document exported by the system. For example, if the report document exported by the system is transmitted to two different terminals A and B, respectively, the document 1 and the document 2 on the terminal A and the terminal B are respectively provided to the terminal user a and the terminal user b in the report document. The interface field is viewed and managed. At the same time, the terminal user a and the terminal user b update the interface fields in the report document without knowing each other. When both the document 1 and the document 2 are simultaneously imported into the system, the system cannot determine. Which report document to use. In this case, the system sends a conflict alert to the end user a and the end user b respectively, prompting the user whether to merge the report documents. When receiving the report document merge instruction issued by any user, the system merges the document 1 and the document 2, that is, summarizes all the interface fields and interface types in the document 1 and the document 2 in one report document.
S202:根据合并后得到的报表文档,对所述数据库中的接口字段进行更新。S202: Update the interface field in the database according to the report document obtained after the merge.
基于接口字段以及接口类型汇总完毕后的报表文档,将该报表文档导入数据库,从而以上述S103相同的实现原理,对数据库中维护的接口字段进行更新。Based on the interface document and the report document after the interface type is summarized, the report document is imported into the database, so that the interface field maintained in the database is updated according to the same implementation principle of the above S103.
S104:将更新后的所述接口字段填充至代码模板,以使所述代码模板生成与更新后的所述接口字段相匹配的接口代码。S104: Fill the updated interface field with a code template, so that the code template generates an interface code that matches the updated interface field.
本申请实施例中,代码模板为Velocity模板。Velocity模板是一个基于Java的引擎框架,其提供的模板语言可以使用在Java中定义的对象和变量上。当数据库的数据表中所维护的接口字段与Excel报表文档的接口字段相同,且字段类型完全匹配时,获取数据表对应生成的一个xml文件,该xml文件中包含有各接口字段的标签。调用Velocity模板,利用Velocity模板中的ant任务Anakia,对预先生成的xml文件进行读取,从而在读取后自动将xml文件中的各接口字段填充至Velocity模板中,并生成与接口字段相匹配的接口代码。具体地,在生成的Java工程文件中,读取填充有各接口字段的Velocity模板,将Velocity模板中的接口字段传进该Java工程文件,从而生成相应的Java接口代码。由此可知,生成的Java接口代码的接口结构与Excel报表文档中所定义的接口结构相同。In the embodiment of the present application, the code template is a Velocity template. The Velocity template is a Java-based engine framework that provides a template language that can be used on objects and variables defined in Java. When the interface field maintained in the data table of the database is the same as the interface field of the Excel report document, and the field type is completely matched, an xml file corresponding to the data table is obtained, and the xml file includes the label of each interface field. Call the Velocity template, use the ant task Anakia in the Velocity template to read the pre-generated xml file, and then automatically fill each interface field in the xml file into the Velocity template after reading, and generate the matching with the interface field. Interface code. Specifically, in the generated Java project file, a Velocity template filled with each interface field is read, and an interface field in the Velocity template is transmitted into the Java project file, thereby generating a corresponding Java interface code. It can be seen that the interface structure of the generated Java interface code is the same as the interface structure defined in the Excel report document.
通过自动生成Java接口代码,开发人员无需在代码实现的过程中,在工程代码文件中重复定义一份关于接口的DTO (Data Transfer Object)代码。By automatically generating Java interface code, developers do not need to repeatedly define a DTO about the interface in the project code file during code implementation. (Data Transfer Object) code.
本申请实施例中,通过将接口字段导出以生成报表文档,对用户修改后的报表文档进行导入,并根据报表文档中用户所修改的接口字段,在数据库中实现接口字段的同步更新,使得开发人员无须受到API管理工具所特定提供的可视化工具的限制,能够灵活地在报表文档中随时录入并修改接口字段,提高了数据库中接口字段的维护效率;通过将报表文档中的接口字段填充至代码模板中,能够利用代码模板自动生成接口代码,保证了定义好的接口文档能够直接同步到代码中使用,因此,与现有的API管理工具相比,进一步地提高开发人员的开发效率。In the embodiment of the present application, the interface field is exported to generate a report document, and the modified report file is imported, and the interface field is synchronously updated in the database according to the interface field modified by the user in the report document, so that the development is performed. The personnel need not be limited by the visualization tools provided by the API management tool, and can flexibly input and modify the interface fields in the report document at any time, thereby improving the maintenance efficiency of the interface fields in the database; by filling the interface fields in the report document with the code In the template, the code template can be used to automatically generate the interface code, which ensures that the defined interface document can be directly synchronized into the code. Therefore, the development efficiency of the developer is further improved compared with the existing API management tool.
作为本申请的另一个实施例,图3示出了本申请实施例提供的接口代码生成方法的实现流程。如图3所示,在上述S104之后,该方法还包括步骤S105和步骤S106,具体如下:As another embodiment of the present application, FIG. 3 shows an implementation flow of an interface code generating method provided by an embodiment of the present application. As shown in FIG. 3, after the above S104, the method further includes step S105 and step S106, as follows:
S105:将所述接口代码进行存储,以得到代码文件,并生成所述代码文件的版本号。S105: Store the interface code to obtain a code file, and generate a version number of the code file.
版本号是代码版本的一个标识号。每一次生成的接口代码以及代码文件都有一个版本号。版本号用于使开发人员了解其所调用的接口代码是否为自己所需的一个版本。并且,根据该版本号,用户能够从记录表中查询该版本号对应的功能注释,从而基于接口代码以及代码文件的版本号,能够确定出该接口代码所提供的功能是否为自己所需的一个功能。The version number is an identification number for the code version. Each generated interface code and code file has a version number. The version number is used to let developers know if the interface code they are calling is a version of their own. And, according to the version number, the user can query the function note corresponding to the version number from the record table, so that based on the interface code and the version number of the code file, it can be determined whether the function provided by the interface code is one of the required ones. Features.
本申请实施例中,代码文件为Java工程文件。在每次接口代码生成时,系统从预设的版本号序列中,依次读取一个未被分配使用的版本号,从而以该版本号作为当前时刻所生成的接口代码的一个版本号,并利用该版本号作为该接口代码所对应的代码文件的版本号。In the embodiment of the present application, the code file is a Java project file. Each time the interface code is generated, the system reads a version number that is not allocated for use from the preset version of the version number, so that the version number is used as a version number of the interface code generated at the current time, and the system uses This version number is the version number of the code file corresponding to the interface code.
S106:对所述代码文件的版本号进行展示。S106: Display the version number of the code file.
一方面,系统将生成的版本号作为Java工程文件的文件名,同时将版本号注释于该Java工程文件的接口代码中。另一方面,在系统所显示的接口详情页面中,展示各Java工程文件及其对应的版本号。On the one hand, the system will generate the version number as the file name of the Java project file, and at the same time comment the version number in the interface code of the Java project file. On the other hand, in the interface details page displayed by the system, each Java project file and its corresponding version number are displayed.
本申请实施例中,通过生成并展示代码文件的版本号,对开发人员起到了版本提示的作用,使得开发人员在升级接口时,能够通过系统所展示的版本号,直观地了解到自己所调用的接口代码是否为最新版本的接口,保证不同开发人员能够基于版本号相同的接口代码,共同执行开发操作,避免接口代码版本号不一致的情况出现。In the embodiment of the present application, by generating and displaying the version number of the code file, the developer is prompted by the version, so that when the interface is upgraded, the developer can intuitively understand the call by the version number displayed by the system. Whether the interface code is the latest version of the interface, to ensure that different developers can perform development operations based on the same interface code with the same version number, to avoid the inconsistency of the interface code version number.
作为本申请的又一实施例,如图4所示,在上述S104之后,所述方法还包括:As another embodiment of the present application, as shown in FIG. 4, after the foregoing S104, the method further includes:
S401:当接收到用户发出基于所述接口代码的调用指令时,获取所述用户的账号权限。S401: Acquire an account right of the user when receiving a call instruction issued by the user based on the interface code.
在生成接口代码文件之后,获取为该接口代码文件所设置的项目信息以及接口信息。其中,项目信息表示该接口代码文件所用于实现的功能以及该接口代码文件所对应的软件开发项目的具体信息等。例如,该项目信息可以是项目的负责人、项目组成员以及项目介绍等信息。接口信息包括接口代码的注释内容以及接口代码本身。After the interface code file is generated, the project information and interface information set for the interface code file are obtained. The project information indicates the function used by the interface code file and the specific information of the software development project corresponding to the interface code file. For example, the project information can be information such as the person in charge of the project, members of the project team, and project introduction. The interface information includes the comment content of the interface code and the interface code itself.
当检测到用户对上述接口代码进行调用,以通过该接口代码所对应的数据库接口来管理数据表中的信息,或对该接口代码的项目信息以及接口信息进行管理时,对用户进行权限鉴定。此时,获取用户当前所使用的管理账号,从预设的账号权限列表中匹配出该管理账号,从而确定出该管理账号对应的账号权限。其中,在各管理账号生成时,该管理账号对应的账号权限同时由数据库管理人员预设于账号权限列表中。管理账号对应的账号权限包括第一权限以及第二权限。When it is detected that the user invokes the interface code to manage the information in the data table through the database interface corresponding to the interface code, or manages the project information and the interface information of the interface code, the user is authenticated. At this time, the management account currently used by the user is obtained, and the management account is matched from the preset account permission list, thereby determining the account authority corresponding to the management account. Wherein, when each management account is generated, the account authority corresponding to the management account is preset by the database administrator in the account permission list. The account rights corresponding to the management account include the first authority and the second authority.
若在账号权限列表中没有匹配到用户当前所使用的管理账号,该管理账号对应的账号权限为空值,或者,该管理账号对应的账号权限为非法权限,则确定该用户的账号权限为上述第一权限。If the account privilege list does not match the management account currently used by the user, the account privilege corresponding to the management account is a null value, or the account privilege corresponding to the management account is an illegal privilege, determining that the account privilege of the user is the above First permission.
S402:若所述账号权限为第一权限,则拒绝响应所述调用指令。S402: If the account authority is the first authority, refusing to respond to the calling instruction.
本申请实施例中,第一权限表示限制用户对接口代码的关联信息进行查看和管理,接口代码的关联信息包括接口信息和项目信息。因此,系统将不对该用户发出的任何调用指令作出响应。In the embodiment of the present application, the first authority indicates that the user is restricted to view and manage the association information of the interface code, and the association information of the interface code includes the interface information and the item information. Therefore, the system will not respond to any call instructions issued by the user.
S403:若所述账号权限为第二权限,则对所述调用指令进行响应。S403: If the account authority is the second authority, respond to the call instruction.
本申请实施例中,第二权限表示允许用户对接口代码的部分关联信息或全部关联信息进行查看和管理。其中,第二权限包括查看权限、部分管理权限以及管理权限。因而在不同类型的第二权限下,系统将对该用户发出的不同调用指令作出响应。In the embodiment of the present application, the second authority indicates that the user is allowed to view and manage part of the association information or all the associated information of the interface code. The second rights include view rights, partial management rights, and management rights. Thus, under different types of second permissions, the system will respond to different invocation commands issued by the user.
图5示出了本申请又一实施例提供的接口代码生成方法S403的具体实现流程,详述如下:FIG. 5 shows a specific implementation flow of the interface code generating method S403 according to another embodiment of the present application, which is described in detail as follows:
S501:若所述账号权限为所述查看权限,则对所述接口信息查看指令进行响应。S501: If the account right is the viewing authority, respond to the interface information viewing instruction.
本申请实施例中,上述基于接口代码的调用指令包括基于接口代码的接口信息查看指令、接口信息管理指令以及项目信息管理指令,上述第二权限包括查看权限、部分管理权限以及管理权限。In the embodiment of the present application, the foregoing interface code-based calling instruction includes an interface information viewing instruction, an interface information management instruction, and a project information management instruction, where the second authority includes a viewing authority, a partial management authority, and a management authority.
当从账号权限列表中确认出用户所使用的管理账号所对应的账号权限为查看权限时,仅对该用户开放基于接口代码的接口信息查看权限,而不开放接口代码的其他管理权限。在账号权限为查看权限的情况下,若系统所接收到的调用指令为接口信息查看指令,则对该调用指令进行响应后,将接口代码的接口信息进行展示,以使用户在只读状态下,能够查看该接口信息,而无法对该接口信息进行修改。When it is confirmed from the account permission list that the account authority corresponding to the management account used by the user is the viewing permission, only the interface information viewing permission based on the interface code is opened to the user, and other management rights of the interface code are not opened. In the case that the account authority is the viewing authority, if the calling instruction received by the system is the interface information viewing instruction, after responding to the calling instruction, the interface information of the interface code is displayed, so that the user is in the read-only state. The interface information can be viewed, and the interface information cannot be modified.
若系统所接收到的调用指令为接口信息管理指令或项目信息管理指令,则拒绝响应该调用指令,即不对该调用指令作出响应。If the calling instruction received by the system is an interface information management instruction or a project information management instruction, the response instruction is rejected, that is, the call instruction is not responded.
S502:若所述账号权限为部分管理权限,则对所述接口信息查看指令以及所述接口信息管理指令进行响应。S502: If the account authority is a partial management authority, respond to the interface information viewing instruction and the interface information management instruction.
当从账号权限列表中确认出用户所使用的管理账号所对应的账号权限为部分管理权限时,仅对该用户开放基于接口代码的接口信息管理以及查看权限,而不开放接口代码的项目信息管理权限。在账号权限为部分管理权限的情况下,若系统所接收到的调用指令为接口信息查看指令或接口信息管理指令,则对该调用指令进行响应后,将接口代码的接口信息进行展示。若系统所接收到的调用指令为接口信息管理指令,则根据接口信息管理指令所携带的具体信息,对接口代码的接口信息进行修改更新。When it is confirmed from the account permission list that the account authority corresponding to the management account used by the user is part of the management authority, only the interface information management and viewing rights based on the interface code are opened to the user, and the project information management of the interface code is not opened. Permissions. In the case that the account authority is part of the management authority, if the calling instruction received by the system is an interface information viewing instruction or an interface information management instruction, the interface information of the interface code is displayed after responding to the calling instruction. If the calling instruction received by the system is an interface information management instruction, the interface information of the interface code is modified and updated according to the specific information carried by the interface information management instruction.
若系统所接收到的调用指令为项目信息管理指令,则拒绝响应该调用指令,即不对该调用指令作出响应。If the call instruction received by the system is a project information management instruction, the call instruction is rejected, that is, the call instruction is not responded.
S503:若所述账号权限为管理权限,则对所述接口信息查看指令、所述接口信息管理指令以及所述项目信息管理指令进行响应。S503: If the account authority is a management authority, respond to the interface information viewing instruction, the interface information management instruction, and the item information management instruction.
当从账号权限列表中确认出用户所使用的管理账号所对应的账号权限为管理权限时,对该用户开放基于接口代码的所有管理权限,包括对接口信息管理、查看的权限以及对项目信息管理的权限。在账号权限为管理权限的情况下,无论系统所接收到的调用指令为接口信息查看指令、接口信息管理指令还是项目信息管理指令,都对该调用指令进行响应。When it is confirmed from the account permission list that the account authority corresponding to the management account used by the user is the management authority, all management rights based on the interface code are opened to the user, including the management of the interface information, the viewing authority, and the management of the project information. permission. In the case that the account authority is the management authority, the call instruction received by the system responds to the call instruction regardless of whether the call instruction is an interface information view instruction, an interface information management instruction, or a project information management instruction.
本申请实施例中,通过确认用户管理账号的是第一权限还是第二权限,以及在第二权限的情况下,再次确认用户是第二权限中哪一类权限,能够适当地对用户发出的基于接口代码的调用指令进行响应,降低了接口代码被非法泄密以及被非法用户所调用的可能性。由于现有API管理工具中缺乏权限维护策略,因而本申请实施例提供的接口代码生成方法能够弥补现有API管理工具的不足之处,提高接口代码的安全性。In the embodiment of the present application, by confirming whether the user management account is the first right or the second right, and in the case of the second right, reconfirming which type of the second right is the user can be appropriately issued to the user. The response based on the call instruction of the interface code reduces the possibility that the interface code is illegally leaked and called by an illegal user. The interface code generation method provided by the embodiment of the present application can make up for the inadequacies of the existing API management tools and improve the security of the interface code.
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should be understood that the size of the sequence of the steps in the above embodiments does not mean that the order of execution is performed. The order of execution of each process should be determined by its function and internal logic, and should not be construed as limiting the implementation process of the embodiments of the present application.
对应于上文实施例所述的接口代码生成方法,图6示出了本申请实施例提供的接口代码生成装置的结构框图,为了便于说明,仅示出了与本申请实施例相关的部分。Corresponding to the interface code generating method described in the above embodiment, FIG. 6 is a structural block diagram of the interface code generating apparatus provided by the embodiment of the present application. For the convenience of description, only parts related to the embodiment of the present application are shown.
参照图6,该装置包括:Referring to Figure 6, the apparatus includes:
维护模块61,用于基于预先定义的接口结构,在数据库中建立与所述接口结构对应的接口字段。The maintenance module 61 is configured to establish an interface field corresponding to the interface structure in a database based on a predefined interface structure.
导出模块62,用于将所述接口字段通过报表生成工具导出,以生成报表文档,在所述报表文档中接收用户发出的接口字段修改指令,对所述报表文档进行接口字段修改。The exporting module 62 is configured to export the interface field by using a report generation tool to generate a report document, and receive an interface field modification instruction issued by the user in the report document, and perform an interface field modification on the report document.
更新模块63,用于导入修改后的所述报表文档,并根据修改后的所述报表文档,对所述数据库中的接口字段进行更新。The update module 63 is configured to import the modified report document, and update the interface field in the database according to the modified report document.
第一生成模块64,用于将更新后的所述接口字段填充至代码模板,以使所述代码模板生成与更新后的所述接口字段相匹配的接口代码。The first generating module 64 is configured to fill the updated interface field to the code template, so that the code template generates an interface code that matches the updated interface field.
可选地,该接口代码生成装置还包括:Optionally, the interface code generating apparatus further includes:
第二生成模块,用于将所述接口代码进行存储,以得到代码文件,并生成所述代码文件的版本号。And a second generating module, configured to store the interface code to obtain a code file, and generate a version number of the code file.
展示模块,用于对所述代码文件的版本号进行展示。a display module for displaying a version number of the code file.
可选地,所述更新模块63包括:Optionally, the updating module 63 includes:
合并子模块,用于若同一时刻导入两个以上修改后的所述报表文档,则发出冲突告警提示,并在接收到报表文档合并指令时,将所述两个以上修改后的所述报表文档进行合并处理。a merge sub-module, configured to issue a conflict alert prompt if two or more modified report documents are imported at the same time, and when the report document merge instruction is received, the two or more modified report documents are Perform the merge process.
更新子模块,用于根据合并后得到的报表文档,对所述数据库中的接口字段进行更新。The update submodule is configured to update the interface field in the database according to the merged report document.
可选地,该接口代码生成装置还包括:Optionally, the interface code generating apparatus further includes:
获取模块,用于当接收到用户发出基于所述接口代码的调用指令时,获取所述用户的账号权限。The obtaining module is configured to acquire the account authority of the user when receiving a call instruction by the user based on the interface code.
第一权限模块,用于若所述账号权限为第一权限,则拒绝响应所述调用指令。The first privilege module is configured to refuse to respond to the call instruction if the account privilege is the first privilege.
第二权限模块,用于若所述账号权限为第二权限,则对所述调用指令进行响应。The second privilege module is configured to respond to the call instruction if the account privilege is the second privilege.
可选地,所述第二权限包括查看权限、部分管理权限以及管理权限,所述调用指令包括接口信息查看指令、接口信息管理指令以及项目信息管理指令,所述第二权限模块包括:Optionally, the second authority includes a view authority, a part of the management authority, and an administrative authority, where the call instruction includes an interface information view instruction, an interface information management instruction, and a project information management instruction, where the second permission module includes:
第一响应子模块,用于若所述账号权限为所述查看权限,则对所述接口信息查看指令进行响应。The first response submodule is configured to respond to the interface information viewing instruction if the account authority is the viewing permission.
第二响应子模块,用于若所述账号权限为部分管理权限,则对所述接口信息查看指令以及所述接口信息管理指令进行响应。The second response submodule is configured to respond to the interface information viewing instruction and the interface information management instruction if the account authority is a partial management authority.
第三响应子模块,用于若所述账号权限为管理权限,则对所述接口信息查看指令、所述接口信息管理指令以及所述项目信息管理指令进行响应。The third response submodule is configured to respond to the interface information viewing instruction, the interface information management instruction, and the item information management instruction if the account authority is a management authority.
图7是本申请一实施例提供的终端设备的示意图。如图7所示,该实施例的终端设备7包括:处理器70以及存储器71,所述存储器71中存储有可在所述处理器70上运行的计算机可读指令72,例如接口代码生成程序。所述处理器70执行所述计算机可读指令72时实现上述各个接口代码生成方法实施例中的步骤,例如图1所示的步骤101至104。或者,所述处理器70执行所述计算机可读指令72时实现上述各装置实施例中各模块/单元的功能,例如图6所示模块61至64的功能。FIG. 7 is a schematic diagram of a terminal device according to an embodiment of the present application. As shown in FIG. 7, the terminal device 7 of this embodiment includes a processor 70 and a memory 71 in which computer readable instructions 72, such as an interface code generation program, executable on the processor 70 are stored. . The processor 70 executes the computer readable instructions 72 to implement the steps in the various interface code generation method embodiments described above, such as steps 101 through 104 shown in FIG. Alternatively, the processor 70, when executing the computer readable instructions 72, implements the functions of the various modules/units in the various apparatus embodiments described above, such as the functions of the modules 61-64 shown in FIG.
示例性的,所述计算机可读指令72可以被分割成一个或多个模块/单元,所述一个或者多个模块/单元被存储在所述存储器71中,并由所述处理器70执行,以完成本申请。所述一个或多个模块/单元可以是能够完成特定功能的一系列计算机可读指令段,该指令段用于描述所述计算机可读指令72在所述终端设备7中的执行过程。Illustratively, the computer readable instructions 72 may be partitioned into one or more modules/units that are stored in the memory 71 and executed by the processor 70, To complete this application. The one or more modules/units may be a series of computer readable instruction segments capable of performing a particular function for describing the execution of the computer readable instructions 72 in the terminal device 7.
所述终端设备7可以是桌上型计算机、笔记本、掌上电脑及云端服务器等计算设备。所述终端设备可包括,但不仅限于处理器70和存储器71。本领域技术人员可以理解,图7仅仅是终端设备7的示例,并不构成对终端设备7的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如所述终端设备还可以包括输入输出设备、网络接入设备、总线等。The terminal device 7 may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server. The terminal device may include, but is not limited to, the processor 70 and the memory 71. It will be understood by those skilled in the art that FIG. 7 is only an example of the terminal device 7, and does not constitute a limitation of the terminal device 7, and may include more or less components than those illustrated, or combine some components or different components. For example, the terminal device may further include an input/output device, a network access device, a bus, and the like.
所称处理器70可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器 (Digital Signal Processor,DSP)、专用集成电路 (Application Specific Integrated Circuit,ASIC)、现成可编程门阵列 (Field-Programmable Gate Array,FPGA) 或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。The so-called processor 70 can be a central processing unit (Central Processing Unit, CPU), can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (Application Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, etc. The general purpose processor may be a microprocessor or the processor or any conventional processor or the like.
所述存储器71可以是所述终端设备7的内部存储单元,例如终端设备7的硬盘或内存。所述存储器71也可以是所述终端设备7的外部存储设备,例如所述终端设备7上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,所述存储器71还可以既包括所述终端设备7的内部存储单元也包括外部存储设备。所述存储器71用于存储所述计算机可读指令以及所述终端设备所需的其他程序和数据。所述存储器71还可以用于暂时地存储已经输出或者将要输出的数据。The memory 71 may be an internal storage unit of the terminal device 7, such as a hard disk or a memory of the terminal device 7. The memory 71 may also be an external storage device of the terminal device 7, for example, a plug-in hard disk provided on the terminal device 7, a smart memory card (SMC), and a secure digital (SD). Card, flash card, etc. Further, the memory 71 may also include both an internal storage unit of the terminal device 7 and an external storage device. The memory 71 is configured to store the computer readable instructions and other programs and data required by the terminal device. The memory 71 can also be used to temporarily store data that has been output or is about to be output.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。The integrated unit, if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application, in essence or the contribution to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium. A number of instructions are included to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like, which can store program codes. .
以上所述,以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围。The above embodiments are only used to explain the technical solutions of the present application, and are not limited thereto; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still The technical solutions described in the embodiments are modified, or the equivalents of the technical features are replaced by the equivalents. The modifications and substitutions of the embodiments do not depart from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims (20)

  1. 一种接口代码生成方法,其特征在于,包括:An interface code generation method, comprising:
    基于预先定义的接口结构,在数据库中建立与所述接口结构对应的接口字段;Establishing an interface field corresponding to the interface structure in a database based on a predefined interface structure;
    将所述接口字段通过报表生成工具导出,以生成报表文档,在所述报表文档中接收用户发出的接口字段修改指令,对所述报表文档进行接口字段修改;Exporting the interface field by using a report generation tool to generate a report document, and receiving an interface field modification instruction issued by the user in the report document, and modifying an interface field of the report document;
    导入修改后的所述报表文档,并根据修改后的所述报表文档,对所述数据库中的接口字段进行更新;Importing the modified report document, and updating the interface field in the database according to the modified report document;
    将更新后的所述接口字段填充至代码模板,以使所述代码模板生成与更新后的所述接口字段相匹配的接口代码。The updated interface field is populated with a code template such that the code template generates an interface code that matches the updated interface field.
  2. 如权利要求1所述的接口代码生成方法,其特征在于,还包括:The interface code generating method according to claim 1, further comprising:
    将所述接口代码进行存储,以得到代码文件,并生成所述代码文件的版本号;Storing the interface code to obtain a code file and generating a version number of the code file;
    对所述代码文件的版本号进行展示。The version number of the code file is displayed.
  3. 如权利要求1或2所述的接口代码生成方法,其特征在于,所述导入修改后的所述报表文档,并根据修改后的所述报表文档,对所述数据库中的接口字段进行更新,包括:The interface code generating method according to claim 1 or 2, wherein the imported report document is imported, and an interface field in the database is updated according to the modified report document. include:
    若同一时刻导入两个以上修改后的所述报表文档,则发出冲突告警提示,并在接收到报表文档合并指令时,将所述两个以上修改后的所述报表文档进行合并处理;If two or more modified report documents are imported at the same time, a conflict alert prompt is issued, and when the report document merge instruction is received, the two or more modified report documents are combined and processed;
    根据合并后得到的报表文档,对所述数据库中的接口字段进行更新。According to the report document obtained after the merge, the interface field in the database is updated.
  4. 如权利要求1所述的接口代码生成方法,其特征在于,还包括:The interface code generating method according to claim 1, further comprising:
    当接收到用户发出基于所述接口代码的调用指令时,获取所述用户的账号权限;Obtaining an account right of the user when receiving a call instruction issued by the user based on the interface code;
    若所述账号权限为第一权限,则拒绝响应所述调用指令;If the account authority is the first authority, refusing to respond to the calling instruction;
    若所述账号权限为第二权限,则对所述调用指令进行响应。And if the account authority is the second authority, responding to the calling instruction.
  5. 如权利要求4所述的接口代码生成方法,其特征在于,所述第二权限包括查看权限、部分管理权限以及管理权限,所述若所述账号权限为第二权限,则对所述调用指令进行响应,包括:The interface code generating method according to claim 4, wherein the second authority comprises a viewing authority, a partial management authority, and a management authority, and if the account authority is a second authority, the calling instruction is Respond to include:
    若所述账号权限为所述查看权限,则对所述接口信息查看指令进行响应;And if the account authority is the viewing permission, responding to the interface information viewing instruction;
    若所述账号权限为部分管理权限,则对所述接口信息查看指令以及所述接口信息管理指令进行响应;And if the account authority is part of the management authority, responding to the interface information viewing instruction and the interface information management instruction;
    若所述账号权限为管理权限,则对所述接口信息查看指令、所述接口信息管理指令以及所述项目信息管理指令进行响应。And if the account authority is a management authority, responding to the interface information viewing instruction, the interface information management instruction, and the item information management instruction.
  6. 一种接口代码生成装置,其特征在于,包括:An interface code generating device, comprising:
    维护模块,用于基于预先定义的接口结构,在数据库中建立与所述接口结构对应的接口字段;a maintenance module, configured to establish, according to a predefined interface structure, an interface field corresponding to the interface structure in a database;
    导出模块,用于将所述接口字段通过报表生成工具导出,以生成报表文档,在所述报表文档中接收用户发出的接口字段修改指令,对所述报表文档进行接口字段修改;An exporting module, configured to export the interface field by using a report generation tool to generate a report document, and receive an interface field modification instruction issued by the user in the report document, and perform an interface field modification on the report document;
    更新模块,用于导入修改后的所述报表文档,并根据修改后的所述报表文档,对所述数据库中的接口字段进行更新;An update module, configured to import the modified report document, and update an interface field in the database according to the modified report document;
    第一生成模块,用于将更新后的所述接口字段填充至代码模板,以使所述代码模板生成与更新后的所述接口字段相匹配的接口代码。And a first generating module, configured to fill the updated interface field with a code template, so that the code template generates an interface code that matches the updated interface field.
  7. 根据权利要求6所述的接口代码生成装置,其特征在于,还包括:The interface code generating apparatus according to claim 6, further comprising:
    第二生成模块,用于将所述接口代码进行存储,以得到代码文件,并生成所述代码文件的版本号;a second generating module, configured to store the interface code to obtain a code file, and generate a version number of the code file;
    展示模块,用于对所述代码文件的版本号进行展示。a display module for displaying a version number of the code file.
  8. 根据权利要求6或7所述的接口代码生成装置,其特征在于,所述更新模块包括:The interface code generating apparatus according to claim 6 or 7, wherein the updating module comprises:
    合并子模块,用于若同一时刻导入两个以上修改后的所述报表文档,则发出冲突告警提示,并在接收到报表文档合并指令时,将所述两个以上修改后的所述报表文档进行合并处理;a merge sub-module, configured to issue a conflict alert prompt if two or more modified report documents are imported at the same time, and when the report document merge instruction is received, the two or more modified report documents are Merge processing;
    更新子模块,用于根据合并后得到的报表文档,对所述数据库中的接口字段进行更新。The update submodule is configured to update the interface field in the database according to the merged report document.
  9. 根据权利要求6所述的接口代码生成装置,其特征在于,还包括:The interface code generating apparatus according to claim 6, further comprising:
    获取模块,用于当接收到用户发出基于所述接口代码的调用指令时,获取所述用户的账号权限;An obtaining module, configured to acquire an account right of the user when receiving a calling instruction by the user based on the interface code;
    第一权限模块,用于若所述账号权限为第一权限,则拒绝响应所述调用指令;a first privilege module, configured to refuse to respond to the call instruction if the account privilege is the first privilege;
    第二权限模块,用于若所述账号权限为第二权限,则对所述调用指令进行响应。The second privilege module is configured to respond to the call instruction if the account privilege is the second privilege.
  10. 根据权利要求9所述的接口代码生成装置,其特征在于,所述第二权限包括查看权限、部分管理权限以及管理权限,所述调用指令包括接口信息查看指令、接口信息管理指令以及项目信息管理指令,所述第二权限模块包括:The interface code generating apparatus according to claim 9, wherein the second authority comprises a viewing authority, a partial management authority, and a management authority, and the calling instruction comprises an interface information viewing instruction, an interface information management instruction, and a project information management. The second privilege module includes:
    第一响应子模块,用于若所述账号权限为所述查看权限,则对所述接口信息查看指令进行响应;a first response submodule, configured to respond to the interface information viewing instruction if the account authority is the viewing permission;
    第二响应子模块,用于若所述账号权限为部分管理权限,则对所述接口信息查看指令以及所述接口信息管理指令进行响应;a second response submodule, configured to respond to the interface information viewing instruction and the interface information management instruction if the account authority is a partial management authority;
    第三响应子模块,用于若所述账号权限为管理权限,则对所述接口信息查看指令、所述接口信息管理指令以及所述项目信息管理指令进行响应。The third response submodule is configured to respond to the interface information viewing instruction, the interface information management instruction, and the item information management instruction if the account authority is a management authority.
  11. 一种终端设备,其特征在于,包括存储器以及处理器,所述存储器中存储有可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现如下步骤:A terminal device, comprising: a memory and a processor, wherein the memory stores computer readable instructions executable on the processor, and the processor implements the following steps when the computer readable instructions are executed :
    基于预先定义的接口结构,在数据库中建立与所述接口结构对应的接口字段;Establishing an interface field corresponding to the interface structure in a database based on a predefined interface structure;
    将所述接口字段通过报表生成工具导出,以生成报表文档,在所述报表文档中接收用户发出的接口字段修改指令,对所述报表文档进行接口字段修改;Exporting the interface field by using a report generation tool to generate a report document, and receiving an interface field modification instruction issued by the user in the report document, and modifying an interface field of the report document;
    导入修改后的所述报表文档,并根据修改后的所述报表文档,对所述数据库中的接口字段进行更新;Importing the modified report document, and updating the interface field in the database according to the modified report document;
    将更新后的所述接口字段填充至代码模板,以使所述代码模板生成与更新后的所述接口字段相匹配的接口代码。The updated interface field is populated with a code template such that the code template generates an interface code that matches the updated interface field.
  12. 根据权利要求11所述的终端设备,其特征在于,所述处理器执行所述计算机可读指令时,还实现如下步骤:The terminal device according to claim 11, wherein when the processor executes the computer readable instructions, the following steps are further implemented:
    将所述接口代码进行存储,以得到代码文件,并生成所述代码文件的版本号;Storing the interface code to obtain a code file and generating a version number of the code file;
    对所述代码文件的版本号进行展示。The version number of the code file is displayed.
  13. 根据权利要求11或12所述的终端设备,其特征在于,所述导入修改后的所述报表文档,并根据修改后的所述报表文档,对所述数据库中的接口字段进行更新,包括:The terminal device according to claim 11 or 12, wherein the importing the modified report document and updating the interface field in the database according to the modified report document comprises:
    若同一时刻导入两个以上修改后的所述报表文档,则发出冲突告警提示,并在接收到报表文档合并指令时,将所述两个以上修改后的所述报表文档进行合并处理;If two or more modified report documents are imported at the same time, a conflict alert prompt is issued, and when the report document merge instruction is received, the two or more modified report documents are combined and processed;
    根据合并后得到的报表文档,对所述数据库中的接口字段进行更新。According to the report document obtained after the merge, the interface field in the database is updated.
  14. 根据权利要求11所述的终端设备,其特征在于,所述处理器执行所述计算机可读指令时,还实现如下步骤:The terminal device according to claim 11, wherein when the processor executes the computer readable instructions, the following steps are further implemented:
    当接收到用户发出基于所述接口代码的调用指令时,获取所述用户的账号权限;Obtaining an account right of the user when receiving a call instruction issued by the user based on the interface code;
    若所述账号权限为第一权限,则拒绝响应所述调用指令;If the account authority is the first authority, refusing to respond to the calling instruction;
    若所述账号权限为第二权限,则对所述调用指令进行响应。And if the account authority is the second authority, responding to the calling instruction.
  15. 根据权利要求14所述的终端设备,其特征在于,所述第二权限包括查看权限、部分管理权限以及管理权限,所述若所述账号权限为第二权限,则对所述调用指令进行响应,包括:The terminal device according to claim 14, wherein the second authority comprises a viewing authority, a partial management authority, and a management authority, and if the account authority is a second authority, responding to the calling instruction ,include:
    若所述账号权限为所述查看权限,则对所述接口信息查看指令进行响应;And if the account authority is the viewing permission, responding to the interface information viewing instruction;
    若所述账号权限为部分管理权限,则对所述接口信息查看指令以及所述接口信息管理指令进行响应;And if the account authority is part of the management authority, responding to the interface information viewing instruction and the interface information management instruction;
    若所述账号权限为管理权限,则对所述接口信息查看指令、所述接口信息管理指令以及所述项目信息管理指令进行响应。And if the account authority is a management authority, responding to the interface information viewing instruction, the interface information management instruction, and the item information management instruction.
  16. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可读指令,其特征在于,所述计算机可读指令被至少一个处理器执行时实现如下步骤:A computer readable storage medium storing computer readable instructions, wherein the computer readable instructions, when executed by at least one processor, implement the following steps:
    基于预先定义的接口结构,在数据库中建立与所述接口结构对应的接口字段;Establishing an interface field corresponding to the interface structure in a database based on a predefined interface structure;
    将所述接口字段通过报表生成工具导出,以生成报表文档,在所述报表文档中接收用户发出的接口字段修改指令,对所述报表文档进行接口字段修改;Exporting the interface field by using a report generation tool to generate a report document, and receiving an interface field modification instruction issued by the user in the report document, and modifying an interface field of the report document;
    导入修改后的所述报表文档,并根据修改后的所述报表文档,对所述数据库中的接口字段进行更新;Importing the modified report document, and updating the interface field in the database according to the modified report document;
    将更新后的所述接口字段填充至代码模板,以使所述代码模板生成与更新后的所述接口字段相匹配的接口代码。The updated interface field is populated with a code template such that the code template generates an interface code that matches the updated interface field.
  17. 根据权利要求16所述的计算机可读存储介质,其特征在于,所述计算机可读指令被至少一个处理器执行时,还实现如下步骤:The computer readable storage medium of claim 16, wherein when the computer readable instructions are executed by at least one processor, the steps of:
    将所述接口代码进行存储,以得到代码文件,并生成所述代码文件的版本号;Storing the interface code to obtain a code file and generating a version number of the code file;
    对所述代码文件的版本号进行展示。The version number of the code file is displayed.
  18. 根据权利要求16或17所述的计算机可读存储介质,其特征在于,所述导入修改后的所述报表文档,并根据修改后的所述报表文档,对所述数据库中的接口字段进行更新,包括:The computer readable storage medium according to claim 16 or 17, wherein said importing said modified report document, and updating an interface field in said database according to said modified report document ,include:
    若同一时刻导入两个以上修改后的所述报表文档,则发出冲突告警提示,并在接收到报表文档合并指令时,将所述两个以上修改后的所述报表文档进行合并处理;If two or more modified report documents are imported at the same time, a conflict alert prompt is issued, and when the report document merge instruction is received, the two or more modified report documents are combined and processed;
    根据合并后得到的报表文档,对所述数据库中的接口字段进行更新。According to the report document obtained after the merge, the interface field in the database is updated.
  19. 根据权利要求16所述的计算机可读存储介质,其特征在于,所述计算机可读指令被至少一个处理器执行时,还实现如下步骤:The computer readable storage medium of claim 16, wherein when the computer readable instructions are executed by at least one processor, the steps of:
    当接收到用户发出基于所述接口代码的调用指令时,获取所述用户的账号权限;Obtaining an account right of the user when receiving a call instruction issued by the user based on the interface code;
    若所述账号权限为第一权限,则拒绝响应所述调用指令;If the account authority is the first authority, refusing to respond to the calling instruction;
    若所述账号权限为第二权限,则对所述调用指令进行响应。And if the account authority is the second authority, responding to the calling instruction.
  20. 根据权利要求19所述的计算机可读存储介质,其特征在于,所述第二权限包括查看权限、部分管理权限以及管理权限,所述若所述账号权限为第二权限,则对所述调用指令进行响应,包括:The computer readable storage medium according to claim 19, wherein the second authority comprises a viewing authority, a partial management authority, and a management authority, and if the account authority is a second authority, the calling The command responds, including:
    若所述账号权限为所述查看权限,则对所述接口信息查看指令进行响应;And if the account authority is the viewing permission, responding to the interface information viewing instruction;
    若所述账号权限为部分管理权限,则对所述接口信息查看指令以及所述接口信息管理指令进行响应;And if the account authority is part of the management authority, responding to the interface information viewing instruction and the interface information management instruction;
    若所述账号权限为管理权限,则对所述接口信息查看指令、所述接口信息管理指令以及所述项目信息管理指令进行响应。And if the account authority is a management authority, responding to the interface information viewing instruction, the interface information management instruction, and the item information management instruction.
PCT/CN2018/083549 2017-05-05 2018-04-18 Interface code generation method, apparatus, terminal device and medium WO2018201895A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710312852.8A CN108268253B (en) 2017-05-05 2017-05-05 Interface code generation method and terminal equipment
CN201710312852.8 2017-05-05

Publications (1)

Publication Number Publication Date
WO2018201895A1 true WO2018201895A1 (en) 2018-11-08

Family

ID=62771645

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/083549 WO2018201895A1 (en) 2017-05-05 2018-04-18 Interface code generation method, apparatus, terminal device and medium

Country Status (2)

Country Link
CN (1) CN108268253B (en)
WO (1) WO2018201895A1 (en)

Families Citing this family (28)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109062801B (en) * 2018-08-01 2021-09-14 四川长虹电器股份有限公司 Automatic conversion system for software interface
CN109614102A (en) * 2018-10-09 2019-04-12 平安科技(深圳)有限公司 Code automatic generation method, device, electronic equipment and storage medium
CN109726213B (en) * 2018-12-10 2021-11-19 阿里巴巴(中国)有限公司 Program code conversion method, device, medium and computing equipment
CN109828963A (en) * 2018-12-14 2019-05-31 中国平安人寿保险股份有限公司 Method of data synchronization, device, system, computer and readable storage medium storing program for executing
CN109933573B (en) * 2019-01-30 2021-06-01 北京融链科技有限公司 Database service updating method, device and system
CN109918433B (en) * 2019-01-31 2024-05-07 平安科技(深圳)有限公司 Message storage method and device based on universal data interface and computer equipment
CN110109656A (en) * 2019-03-25 2019-08-09 平安科技(深圳)有限公司 Interface analogy method, device, computer equipment and storage medium
CN110175022B (en) * 2019-04-25 2023-10-13 平安科技(深圳)有限公司 Method and device for automatically generating POJO class, storage medium and computer equipment
CN110262782A (en) * 2019-05-10 2019-09-20 平安科技(深圳)有限公司 The interface comparison method and device of software systems
CN110262783B (en) * 2019-05-22 2023-08-08 深圳华科云动力科技有限公司 Interface generation method and device and terminal equipment
CN110377514A (en) * 2019-07-12 2019-10-25 中汇信息技术(上海)有限公司 Management method, device, electronic equipment and the storage medium of software component
CN112256252B (en) * 2019-07-22 2023-09-26 腾讯科技(深圳)有限公司 Interface generation method and device, storage medium and electronic equipment
CN110474970B (en) * 2019-07-31 2022-03-01 澳克多普有限公司 Code synchronization method, device and system
CN110955451B (en) * 2019-12-06 2023-07-25 中国银行股份有限公司 Method and device for changing online interface
CN111125064B (en) * 2019-12-24 2023-08-29 中国建设银行股份有限公司 Method and device for generating database schema definition statement
CN111126008B (en) * 2019-12-25 2023-05-26 广东南方海岸科技服务有限公司 Code generation method and device based on XSD, computer equipment and storage medium
CN111459466B (en) * 2020-03-31 2023-10-20 广州酷狗计算机科技有限公司 Code generation method, device, equipment and storage medium
CN111695328B (en) * 2020-06-16 2023-01-24 深圳前海微众银行股份有限公司 Method, device, equipment and storage medium for generating simulation test message
CN111782650B (en) * 2020-06-28 2024-04-05 京东科技控股股份有限公司 Dynamic data warehousing method and device, electronic equipment and storage medium
CN112380281A (en) * 2020-10-30 2021-02-19 中国人寿保险股份有限公司 Platform layer code generation method and device, electronic equipment and storage medium
CN112463261A (en) * 2020-11-20 2021-03-09 北京达佳互联信息技术有限公司 Interface calling method and device
CN112947963A (en) * 2021-02-26 2021-06-11 平安普惠企业管理有限公司 Interface operation and maintenance method and device, computer equipment and storage medium
CN113095039A (en) * 2021-03-09 2021-07-09 智慧芽信息科技(苏州)有限公司 Processing method, device and server for indexing file custom field
CN112947911A (en) * 2021-04-26 2021-06-11 平安普惠企业管理有限公司 Interface script generation method, device, equipment and storage medium
CN113282457B (en) * 2021-05-25 2022-11-22 浪潮通用软件有限公司 Method, device and medium for maintaining heterogeneous system integration interface information
CN114153909A (en) * 2021-11-26 2022-03-08 北京人大金仓信息技术股份有限公司 Database table structure translation method and device based on Velocity template engine
CN114168119B (en) * 2021-12-07 2024-04-05 北京百度网讯科技有限公司 Code file editing method, device, electronic equipment and storage medium
CN114003293B (en) * 2021-12-30 2022-03-08 云账户技术(天津)有限公司 Interface management method, device, electronic equipment and readable storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103136097A (en) * 2011-11-29 2013-06-05 神州数码信息系统有限公司 Method of software testing simulator frame construction
CN104375814A (en) * 2013-08-14 2015-02-25 腾讯科技(深圳)有限公司 Generation method and device of an interface document
CN105404527A (en) * 2015-09-24 2016-03-16 国网山东省电力公司 Interface configuration method and system based on SAP (System Applications and Products in Data Processing) platform
US20160080397A1 (en) * 2014-09-12 2016-03-17 Steven V. Bacastow Method and System for Forensic Data Tracking

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103136097A (en) * 2011-11-29 2013-06-05 神州数码信息系统有限公司 Method of software testing simulator frame construction
CN104375814A (en) * 2013-08-14 2015-02-25 腾讯科技(深圳)有限公司 Generation method and device of an interface document
US20160080397A1 (en) * 2014-09-12 2016-03-17 Steven V. Bacastow Method and System for Forensic Data Tracking
CN105404527A (en) * 2015-09-24 2016-03-16 国网山东省电力公司 Interface configuration method and system based on SAP (System Applications and Products in Data Processing) platform

Also Published As

Publication number Publication date
CN108268253A (en) 2018-07-10
CN108268253B (en) 2020-01-03

Similar Documents

Publication Publication Date Title
WO2018201895A1 (en) Interface code generation method, apparatus, terminal device and medium
US11063744B2 (en) Document flow tracking using blockchain
KR102209737B1 (en) Methods and systems for providing verifiable, auditable, and immutable inputs to smart contracts
US8856532B2 (en) Digital signatures of composite resource documents
KR20200011435A (en) Parameterizable Smart Contract
TW202024953A (en) Data structure reading and updating method and device and electronic equipment
CN111427561A (en) Service code generation method and device, computer equipment and storage medium
US11907390B2 (en) Method and apparatus for visual construction of knowledge graph system
CN115129716A (en) Data management method, equipment and storage medium for industrial big data
CN111638908A (en) Interface document generation method and device, electronic equipment and medium
CN108255967B (en) Method and device for calling storage process, storage medium and terminal
WO2023167761A1 (en) Debugging data privacy pipelines using sample data
WO2023167737A1 (en) Granting entitlements to log data generated by a data privacy pipeline to facilitate debugging
CN111881209A (en) Data synchronization method and device for heterogeneous database, electronic equipment and medium
US11900269B2 (en) Method and apparatus for managing knowledge base, device and medium
WO2023167756A1 (en) Initiating data privacy pipelines using reusable templates
CN116244682A (en) Database access method, device, equipment and storage medium
US11900347B2 (en) Computing system for configurable off-chain storage for blockchains
CN114816361A (en) Method, device, equipment, medium and program product for generating splicing project
CN106547626B (en) Method for balancing server in peer-to-peer architecture and server
US20240161078A1 (en) Computing system for configurable off-chain storage for blockchains
CN115269880B (en) Privacy calculation auditing method and device based on knowledge graph
EP4254244A1 (en) Data asset sharing
US20240004850A1 (en) Systems and methods for a stateless blockchain overlay layer
KR20240005957A (en) Method and system for quantum resistant hashing scheme

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18794510

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 18/02/2020)

122 Ep: pct application non-entry in european phase

Ref document number: 18794510

Country of ref document: EP

Kind code of ref document: A1