[go: up one dir, main page]

CN118200407A - Method and device for generating message codes, computer equipment and readable storage medium - Google Patents

Method and device for generating message codes, computer equipment and readable storage medium Download PDF

Info

Publication number
CN118200407A
CN118200407A CN202410609302.2A CN202410609302A CN118200407A CN 118200407 A CN118200407 A CN 118200407A CN 202410609302 A CN202410609302 A CN 202410609302A CN 118200407 A CN118200407 A CN 118200407A
Authority
CN
China
Prior art keywords
message
data field
code
code file
configuration
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410609302.2A
Other languages
Chinese (zh)
Inventor
黎贝思
劳永安
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
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 Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202410609302.2A priority Critical patent/CN118200407A/en
Publication of CN118200407A publication Critical patent/CN118200407A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/06Notations for structuring of protocol data, e.g. abstract syntax notation one [ASN.1]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/26Special purpose or proprietary protocols or architectures

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application relates to a method, a device, a computer readable storage medium and a computer program product for generating message codes, which relate to the technical field of computers and can be used in the technical field of finance or other related fields. The method comprises the following steps: determining a data domain identifier of a message data domain contained in a message to be generated according to a message interaction protocol of the message to be generated in the financial field; determining the configuration record type of the message data field according to the data field identification; acquiring configuration element information of a message data field by adopting a configuration record query mode corresponding to a configuration record type; generating a code file aiming at a message data field by adopting a preset message code template and configuration element information; and obtaining the code file of the message to be generated according to the code file of the message data field. By adopting the method, the writing efficiency of the message codes can be improved.

Description

Method and device for generating message codes, computer equipment and readable storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a computer device, a computer readable storage medium, and a computer program product for generating a message code.
Background
Along with the gradual transformation of the traditional single-body application system to the distributed micro-service architecture, the interaction mode among each micro-service group becomes a focus of attention gradually. The micro service communication protocols provided by the current systems are different, and the system has no compatibility, especially the message structure of the interface design of the basic service layer of various businesses is different, the elements of the message data field are various, and in the research and development process of the message generation, the initialization and assignment are usually carried out on each field in the message by manually writing codes.
However, depending on the manner of manually writing codes, the meaning of representation and the manner of value of each field in each data field need to be checked from top to bottom according to the structural order of the messages. Once a message with a complex structure and more fields is encountered, the code writing efficiency is low and errors are easy to occur, so that the research and development efficiency of a development team is affected.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a method, an apparatus, a computer device, a computer readable storage medium, and a computer program product for generating a message code that can improve the efficiency of writing the message code.
In a first aspect, the present application provides a method for generating a message code, including:
determining a data domain identifier of a message data domain contained in a message to be generated according to a message interaction protocol of the message to be generated in the financial field;
Determining the configuration record type of the message data field according to the data field identification;
Acquiring configuration element information of the message data field by adopting a configuration record query mode corresponding to the configuration record type;
Generating a code file aiming at the message data field by adopting a preset message code template and the configuration element information;
And obtaining the code file of the message to be generated according to the code file of the message data field.
In one embodiment, the determining, according to the data field identifier, a configuration record type of the packet data field includes:
In a preset code file catalog, retrieving a code file containing a data domain entity class corresponding to the data domain identifier;
Under the condition that the retrieval is successful, determining the configuration record type of the message data field as a first type;
And under the condition of failure in retrieval, determining the configuration record type of the message data field as a second type.
In one embodiment, the obtaining the configuration element information of the packet data domain by adopting a configuration record query manner corresponding to the configuration record type includes:
Under the condition that the configuration record type of the message data field is the first type, obtaining configuration element information of the message data field according to the code file containing the data field entity class corresponding to the data field identifier;
And under the condition that the configuration record type of the message data field is the second type, acquiring configuration element information of the message data field corresponding to the data field identification from a preset record file.
In one embodiment, the obtaining the configuration element information of the packet data domain according to the code file including the data domain entity class corresponding to the data domain identifier includes:
dynamically compiling the code file containing the data domain entity class corresponding to the data domain identifier;
and in the dynamic compiling process, extracting entity class information containing the data domain entity class corresponding to the data domain identifier to obtain configuration element information of the message data domain.
In one embodiment, the generating a code file for the message data field by using a preset message code template and the configuration element information includes:
Replacing the placeholders in the preset message code template with the corresponding configuration element information to obtain candidate code files;
And normalizing the candidate code file to obtain a code file aiming at the message data field.
In one embodiment, the generating a code file for the message data field by using a preset message code template and the configuration element information includes:
determining the data field type of the message data field corresponding to the data field identification; the data field type comprises an input data field and an output data field;
determining a corresponding target preset message code template according to the data field type;
And generating a code file aiming at the message data field by adopting the target preset message code template and the configuration element information.
In one embodiment, the obtaining the code file of the message to be generated according to the code file of the message data field includes:
Acquiring a message header code and a message Wen Weibu code of the message to be generated according to the message interaction protocol of the message to be generated;
And merging the message header code, the message Wen Weibu code and the code file of the message data field in sequence according to the message interaction protocol of the message to be generated to obtain the code file of the message to be generated.
In a second aspect, the present application further provides a device for generating a message code, including:
the data domain determining module is used for determining a data domain identifier of a message data domain contained in a message to be generated according to a message interaction protocol of the message to be generated in the financial field;
The record type determining module is used for determining the configuration record type of the message data field according to the data field identification;
The configuration element acquisition module is used for acquiring configuration element information of the message data field by adopting a configuration record query mode corresponding to the configuration record type;
the first code generation module is used for generating a code file aiming at the message data field by adopting a preset message code template and the configuration element information;
And the second code generation module is used for obtaining the code file of the message to be generated according to the code file of the message data field.
In a third aspect, the present application also provides a computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:
determining a data domain identifier of a message data domain contained in a message to be generated according to a message interaction protocol of the message to be generated in the financial field;
Determining the configuration record type of the message data field according to the data field identification;
Acquiring configuration element information of the message data field by adopting a configuration record query mode corresponding to the configuration record type;
Generating a code file aiming at the message data field by adopting a preset message code template and the configuration element information;
And obtaining the code file of the message to be generated according to the code file of the message data field.
In a fourth aspect, the present application also provides a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
determining a data domain identifier of a message data domain contained in a message to be generated according to a message interaction protocol of the message to be generated in the financial field;
Determining the configuration record type of the message data field according to the data field identification;
Acquiring configuration element information of the message data field by adopting a configuration record query mode corresponding to the configuration record type;
Generating a code file aiming at the message data field by adopting a preset message code template and the configuration element information;
And obtaining the code file of the message to be generated according to the code file of the message data field.
In a fifth aspect, the application also provides a computer program product comprising a computer program which, when executed by a processor, performs the steps of:
determining a data domain identifier of a message data domain contained in a message to be generated according to a message interaction protocol of the message to be generated in the financial field;
Determining the configuration record type of the message data field according to the data field identification;
Acquiring configuration element information of the message data field by adopting a configuration record query mode corresponding to the configuration record type;
Generating a code file aiming at the message data field by adopting a preset message code template and the configuration element information;
And obtaining the code file of the message to be generated according to the code file of the message data field.
The method, the device, the computer equipment, the computer readable storage medium and the computer program product for generating the message code comprise the steps of firstly, determining a data field identifier of a message data field contained in a message to be generated according to a message interaction protocol of the message to be generated in the financial field, and automatically determining a corresponding data field according to the message interaction protocol to meet the communication requirement and specification; then, according to the data field identification, determining the configuration record type of the message data field, and further obtaining the configuration information of the message data field more accurately and rapidly; then, a configuration record query mode corresponding to the configuration record type is adopted to acquire the configuration element information of the message data field, so that the configuration element information can be quickly and accurately applied in the code generation process, and errors and omission possibly occurring when codes are manually written are avoided; then, a code file aiming at a message data field is generated by adopting a preset message code template and configuration element information, so that the development efficiency can be greatly improved, the workload of manually writing codes is reduced, and meanwhile, the generated codes are ensured to meet the requirements and specifications of a communication protocol; finally, the code file of the message to be generated is obtained according to the code file of the message data field, and the generated code file is consistent with the message interaction protocol, so that the message data can be processed correctly, and the requirement of communication between systems is met. In the method, the configuration information and the generated codes are automatically acquired, so that the workload of manually writing the codes is reduced, errors and problems caused by human factors are avoided, the development and integration progress of the system is accelerated, the research and development efficiency of a team is improved, and the requirements of complex systems in the financial field are better met.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the related art, the drawings that are needed in the description of the embodiments of the present application or the related technologies will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and other related drawings may be obtained according to these drawings without inventive effort to those of ordinary skill in the art.
FIG. 1 is a flow chart of a method for generating a message code in one embodiment;
FIG. 2 is a flow chart of a configuration element information acquisition step in one embodiment;
FIG. 3 is a flow chart illustrating a method for generating a message code according to another embodiment;
FIG. 4 is a block diagram of a message code generating device in one embodiment;
fig. 5 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
It should be noted that, the user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the present application are both information and data authorized by the user or sufficiently authorized by each party, and the collection, use and processing of the related data are required to meet the related regulations. The collected information is information and data authorized by a user or fully authorized by each party, and the processing of the related data such as collection, storage, use, processing, transmission, provision, disclosure, application and the like all obeys the related laws and regulations and standards of related countries and regions, necessary security measures are taken, no prejudice to the public order colloquial is avoided, and corresponding operation entrance is provided for the user to select authorization or rejection.
In one embodiment, as shown in fig. 1, a method for generating a message code is provided, where the method is applied to a terminal for illustrating, it is understood that the method may also be applied to a server, and may also be applied to a system including the terminal and the server, and implemented through interaction between the terminal and the server. The terminal may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, and the like. The server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing cloud computing service. In this embodiment, the method includes the steps of:
step S101, determining a data field identification of a message data field contained in the message to be generated according to a message interaction protocol of the message to be generated in the financial field.
The terminal needs to analyze a message interaction protocol of a message to be generated in the financial field, and obtains contents in aspects of a structure, a field definition, a message format and the like of the protocol. On the basis of analyzing the message interaction protocol, each data domain related in the message and the corresponding data domain identification thereof are identified and extracted. The data field identification may be determined based on field name, location, field alias, etc. for uniquely identifying each data field in the message. The terminal may also automatically sort the identified data field identification information into records for later use, for example by storing the information in a data structure, such as a dictionary, array or database.
Step S102, according to the data field identification, the configuration record type of the message data field is determined.
The terminal queries and determines the configuration record type of the message data field according to the data field identification. Namely, how to record the configuration element information in the message data field is recorded, and then acquiring the configuration element information in the message data field in a corresponding mode according to different configuration record types.
Step S103, adopting a configuration record query mode corresponding to the configuration record type to acquire the configuration element information of the message data field.
Illustratively, the configuration record types may include a static configuration record type and a dynamic configuration record type, where the static configuration record type may directly obtain configuration element information from a predefined data source, and the dynamic configuration record type needs to compile a corresponding data field code, so as to obtain the corresponding configuration element information by a reflection mechanism or the like.
Step S104, a code file aiming at a message data field is generated by adopting a preset message code template and configuration element information.
Illustratively, the terminal needs to first select an appropriate template before generating the code file using the preset message code template. The selection of the template should be based on the characteristics of the message data field, the service requirements, the system architecture, and other factors. Different message data fields may require different code templates. In the process of generating the code file, the terminal needs to apply the acquired configuration element information to the code template, namely, the configuration element information of the data field is filled in the corresponding code position, so as to ensure that the generated code file can correctly process the message data field. For example, the configuration element information may be represented using placeholders or variables in a template, and then the actual configuration element values are populated into the corresponding locations, generating a code file for the message data field.
Step S105, according to the code file of the message data field, the code file of the message to be generated is obtained.
The terminal first needs to combine the generated code files of each data field according to the structure sequence of the message, so as to ensure that the processing logic and the code segments of each data field can be correctly integrated into the code file of the message to be generated. When generating the code file of the message to be generated, the terminal also needs to add corresponding message header and tail information according to the requirements of the message interaction protocol. Such information may include a start identifier, an end identifier, a message length, a check code, etc. of the message. The addition of the header and trailer information of the message can be realized by a preset template or a manual writing mode. Finally, the terminal needs to process an abnormal situation, for example, if the value of a certain data field is null or exceeds the allowable range, corresponding abnormal processing logic needs to be added, so as to ensure that the generated message accords with the expected format and specification.
In the method for generating the message code, firstly, according to the message interaction protocol of the message to be generated in the financial field, the data domain identification of the message data domain contained in the message to be generated is determined, and according to the message interaction protocol, the corresponding data domain can be automatically determined, so that the communication requirement and specification are met; then, according to the data field identification, determining the configuration record type of the message data field, and further obtaining the configuration information of the message data field more accurately and rapidly; then, a configuration record query mode corresponding to the configuration record type is adopted to acquire the configuration element information of the message data field, so that the configuration element information can be quickly and accurately applied in the code generation process, and errors and omission possibly occurring when codes are manually written are avoided; then, a code file aiming at a message data field is generated by adopting a preset message code template and configuration element information, so that the development efficiency can be greatly improved, the workload of manually writing codes is reduced, and meanwhile, the generated codes are ensured to meet the requirements and specifications of a communication protocol; finally, the code file of the message to be generated is obtained according to the code file of the message data field, and the generated code file is consistent with the message interaction protocol, so that the message data can be processed correctly, and the requirement of communication between systems is met. In the method, the configuration information and the generated codes are automatically acquired, so that the workload of manually writing the codes is reduced, errors and problems caused by human factors are avoided, the development and integration progress of the system is accelerated, the research and development efficiency of a team is improved, and the requirements of complex systems in the financial field are better met.
In an exemplary embodiment, the step S102 determines the configuration record type of the packet data domain according to the data domain identifier, and further includes: in a preset code file catalog, retrieving a code file containing a data domain entity class corresponding to the data domain identifier; under the condition that the retrieval is successful, determining the configuration record type of the message data field as a first type; and in case of failure in retrieval, determining the configuration record type of the message data field as a second type.
In an exemplary embodiment, when determining the configuration record type of the message data field, the terminal first searches a preset code file directory for whether a code file of a data field entity class corresponding to the data field identifier is included, that is, by traversing a file system or matching file names. If a matching data field entity class code file can be found, it is stated that the data field is of a first type (i.e., the dynamic configuration record type above) and is otherwise of a second type (i.e., the static configuration record type above). It should be noted that, before the data domain entity class code file queried in the embodiment is a system transformation, a code file of a message data domain is generated, and after transformation, configuration element information of the message data domain can be determined by means of the code file before transformation, so as to generate the code file after transformation.
In this embodiment, through the first type, the configuration element information can be dynamically obtained according to the data domain entity class in the code file directory, so that the method has higher flexibility and expandability, and can adapt to the configuration requirement with frequent or complex change. The second type can pre-store the configuration element information in a file or a database, so that the work of configuration management and maintenance is simplified, and the method is suitable for the condition that the configuration information is relatively fixed or does not change frequently. In an embodiment, firstly, searching the dynamic type configuration information is tried, if the dynamic type configuration information is successful, the dynamic type configuration information is directly obtained, and manual configuration is not needed; if the message fails, the message is converted into a static type, so that unnecessary manual configuration operation is avoided, and the efficiency of generating the message is improved.
In an exemplary embodiment, as shown in fig. 2, the step S103 may be implemented by using a configuration record query manner corresponding to a configuration record type to obtain configuration element information of a message data field, and further include the following steps:
Step S201, under the condition that the configuration record type of the message data field is the first type, the configuration element information of the message data field is obtained according to a code file containing the data field entity class corresponding to the data field identification;
Step S202, under the condition that the configuration record type of the message data field is the second type, acquiring configuration element information of the message data field corresponding to the data field identification from a preset record file.
In an exemplary embodiment, when the configuration record type of the packet data domain is the first type, the terminal obtains a code file containing a data domain entity class corresponding to the data domain identifier, then loads the data domain entity class corresponding to the data domain identifier by compiling the code file containing the data domain entity class corresponding to the data domain identifier, and then obtains configuration element information of the data domain from the data domain entity class. In the case that the configuration record type of the message data field is the second type, loading configuration element information corresponding to the data field identification from a preset record file by the terminal, wherein the preset record file may be a configuration file, a database table or other record files; and then, the terminal extracts configuration element information corresponding to the data domain identifier from the loaded preset record file.
In this embodiment, by acquiring the configuration element information in different manners according to the first type and the second type, the efficiency and flexibility of acquiring the configuration information can be improved, so as to increase the speed of generating the message.
In an exemplary embodiment, the step S201 obtains the configuration element information of the data field of the message according to the code file including the data field entity class corresponding to the data field identifier, and further includes: dynamically compiling a code file containing a data domain entity class corresponding to the data domain identifier; and in the dynamic compiling process, extracting entity class information containing the entity class of the data domain corresponding to the data domain identifier to obtain the configuration element information of the message data domain.
First, the terminal determines a corresponding data domain entity class code file according to the data domain identifier, and dynamically compiles the file. Dynamic compilation may be accomplished through a compiler API or other dynamic compilation tool that compiles source code files into executable method class files. In the dynamic compiling process, the terminal may extract entity class information, such as class name, field name, data type, annotation information, etc., containing the data domain entity class corresponding to the data domain identifier through a reflection mechanism or other modes. In the process of extracting the entity class information, the configuration element information corresponding to the data domain identifier is obtained at the same time, namely, the configuration element information is obtained by analyzing the field annotation of the entity class or other modes, such as field names, data types, value ranges, verification rules and the like.
In this embodiment, according to the code file including the data domain entity class corresponding to the data domain identifier, the configuration element information of the message data domain is obtained by dynamic compiling, so as to achieve accurate and efficient configuration information acquisition.
In an exemplary embodiment, the step S104 generates a code file for the message data field by using a preset message code template and configuration element information, and further includes: replacing placeholders in a preset message code template with corresponding configuration element information to obtain candidate code files; and carrying out standardization processing on the candidate code files to obtain the code files aiming at the message data fields.
The terminal may replace the placeholder in the preset message code template with corresponding configuration element information to obtain the candidate code file, which may be implemented by a string replacement or a template engine. Placeholders are typically marks or variables that represent configuration element information that needs to be populated. And then, the terminal performs normalization processing on the generated candidate code file to obtain a code file aiming at the message data field. The normalization process may include code formatting (including line feed, indentation, etc.), naming specifications, annotation addition, etc. to ensure that the generated code file meets the coding specifications and standards of the system, facilitating user view management.
In this embodiment, by combining the preset message code template with the configuration element information, a code file for the message data field can be automatically generated, so that the workload of manually writing codes is reduced, and the development efficiency is improved. Because the code generation process is automatic and is based on the replacement of the configuration element information, human errors and negligence can be reduced, and the accuracy and the stability of the code are improved. By normalizing the candidate code file, the generated code file has good readability, maintainability and consistency, and is beneficial to understanding and modifying the subsequent codes.
In an exemplary embodiment, the step S104 generates a code file for the message data field by using a preset message code template and configuration element information, and further includes: determining a data field type of a message data field corresponding to the data field identification; the data field type includes an input data field and an output data field; determining a corresponding target preset message code template according to the data field type; and generating a code file aiming at the message data field by adopting a target preset message code template and configuration element information.
The terminal determines the data field type according to the characteristics and the purpose of the message data field corresponding to the data field identification. The data field types generally include both input data field and output data field types. The input data field is used for receiving data transferred by an external system, and the output data field is used for transferring data to the external system. And the terminal selects a corresponding target preset message code template according to the determined data field type. Different code templates are usually designed for the input data field and the output data field respectively to meet different requirements and characteristics of the input data field and the output data field in the message interaction process. And then, the terminal generates a code file aiming at the message data field according to the selected target preset message code template and the configuration element information. In the generation process, the configuration element information needs to be applied to the template, and the generated code file is ensured to accord with the corresponding data field type and the specification of the preset template.
In this embodiment, by selecting the target preset message code template according to the data field type, it can be ensured that the generated code file is matched with the characteristics and purposes of the data field, and higher accuracy and applicability are provided. By using the preset message code templates designed for different data field types, the generated code files can be ensured to have consistent structures and styles, and the quality and maintainability of codes are improved, so that the code generation speed is accelerated, and the development efficiency is improved.
In an exemplary embodiment, the step S105 obtains the code file of the message to be generated according to the code file of the message data field, and further includes: according to a message interaction protocol of a message to be generated, a message header code and a message Wen Weibu code of the message to be generated are obtained; and merging the message header code, the message Wen Weibu code and the code file of the message data field in sequence according to the message interaction protocol of the message to be generated to obtain the code file of the message to be generated.
The terminal obtains corresponding message header and trailer codes from a preset template or configuration file according to a message interaction protocol of the message to be generated. The header code of the message generally includes a start flag, length information, etc. of the message, and the tail code of the message includes an end flag, check code, etc. of the message. And then, the terminal sequentially combines the acquired message header codes, the code files of the message data fields and the message tail codes according to the sequence of the message interaction protocol to obtain the code files of the message to be generated. The merging process may be implemented by simple text splicing or processing by a template engine.
In this embodiment, the header code and the trailer code of the message are obtained according to the preset message interaction protocol, so that the generated code file of the message to be generated is ensured to be consistent with the standard message format, and the readability and maintainability of the code are enhanced. The message head codes, the code files of the message data fields and the message tail codes are automatically combined according to the sequence of the message interaction protocol, so that the requirement of manual intervention is reduced, and the automation degree and the efficiency of code generation are improved. In the process of merging the code files, the generated code files of the message to be generated can be subjected to standardization processing, including code formatting, naming standards and the like, so that the generated code files have consistent formats and styles, and the quality and maintainability of codes are improved.
In another exemplary embodiment, as shown in fig. 3, the present application provides a method for generating a message code, which includes the following steps:
Step S301, determining a data field identification of a message data field contained in the message to be generated according to a message interaction protocol of the message to be generated in the financial field.
In step S302, in the preset code file directory, a code file containing a data domain entity class corresponding to the data domain identifier is retrieved.
Step S303, under the condition that the retrieval is successful, determining the configuration record type of the message data field as a first type; and in case of failure in retrieval, determining the configuration record type of the message data field as a second type.
Step S304, dynamically compiling a code file containing a data domain entity class corresponding to the data domain identifier under the condition that the configuration record type of the message data domain is a first type; and in the dynamic compiling process, extracting entity class information containing the entity class of the data domain corresponding to the data domain identifier to obtain the configuration element information of the message data domain.
Step S305, obtaining the configuration element information of the message data field corresponding to the data field identification from the preset record file under the condition that the configuration record type of the message data field is the second type.
Step S306, determining the data field type of the message data field corresponding to the data field identification; the data field types include an input data field and an output data field.
Step S307, according to the data field type, determining a corresponding target preset message code template.
Step S308, replacing the placeholder in the target preset message code template with corresponding configuration element information to obtain a candidate code file.
Step S309, the candidate code files are normalized to obtain code files for the message data field.
Step S310, according to the message interaction protocol of the message to be generated, the message head code and the message tail code of the message to be generated are obtained.
Step S311, merging the code files of the message header code, the message Wen Weibu code and the message data field in sequence according to the message interaction protocol of the message to be generated, and obtaining the code file of the message to be generated.
Illustratively, in the preset record file storing the configuration element information of the second type of message data field, the recorded configuration element information includes information such as a data field identifier, a field name included in the data field, a type of each field, a description of each field, a maximum length of each field, a necessity of each field, and the like.
For a first type of code file, such as a Java file, the terminal dynamically compiles the obtained data domain Java file, reads Class information into a JVM (Java Virtual Machine ) through a Class loader for linking and initializing, and finally obtains attribute fields and related comments of each data domain through a reflection mechanism, thereby obtaining an input data domain element list and an output data domain element list and forming an assignment code.
When the code is generated, a template engine such as FREEMARKER can be adopted, a code file can be dynamically generated according to a configured code program template (including a basic input communication area assignment method, an output communication area assignment method and the like), input and output data domain element list and assignment content are input, and formatting output is carried out.
In the embodiment, the data domain assignment code can be automatically assembled by configuring the message protocol and the structure, so that a developer can efficiently complete message assignment conversion development under a small amount of configuration and operation, and the development efficiency is improved. Meanwhile, the processing and related annotation of all message elements are reserved, and the integrity and accuracy of message assignment conversion processing are ensured. In particular, in the financial field, the traditional single-body type application system is gradually transformed into a distributed micro-service architecture, micro-service communication protocols provided by each micro-service group are different and have no compatibility, especially, message structures of interfaces of various business foundation service layers are different, message communication area elements are various, in the process of conversion and butt research and development, key message elements required by the micro-services of the different business foundation service layers are simply configured, then the method is used for automatically generating a packaging method for assembling the messages required by the micro-services of the downstream business foundation service layers according to the configuration, and finally, the codes are transplanted into projects, so that the process of quickly completing message assignment conversion and development is achieved, and the input time cost of developers in the aspect is greatly reduced.
It should be understood that, although the steps in the flowcharts related to the embodiments described above are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a message code generating device for realizing the above related message code generating method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in the embodiment of the generating device of one or more message codes provided below may refer to the limitation of the generating method of the message codes hereinabove, and will not be repeated herein.
In an exemplary embodiment, as shown in fig. 4, there is provided a message code generating apparatus, including: a data field determining module 401, a record type determining module 402, a configuration element obtaining module 403, a first code generating module 404, and a second code generating module 405, wherein:
the data domain determining module 401 is configured to determine a data domain identifier of a message data domain included in a message to be generated according to a message interaction protocol of the message to be generated in the financial field;
a record type determining module 402, configured to determine a configuration record type of the packet data domain according to the data domain identifier;
a configuration element obtaining module 403, configured to obtain configuration element information of the message data field by adopting a configuration record query mode corresponding to the configuration record type;
A first code generating module 404, configured to generate a code file for a message data field by using a preset message code template and configuration element information;
The second code generating module 405 is configured to obtain a code file of the message to be generated according to the code file of the message data field.
In one embodiment, the record type determining module 402 is further configured to retrieve, in a preset code file directory, a code file including a data domain entity class corresponding to the data domain identifier; under the condition that the retrieval is successful, determining the configuration record type of the message data field as a first type; and in case of failure in retrieval, determining the configuration record type of the message data field as a second type.
In one embodiment, the above-mentioned configuration element obtaining module 403 is further configured to obtain, when the configuration record type of the message data field is the first type, configuration element information of the message data field according to a code file including a data field entity class corresponding to the data field identifier; and under the condition that the configuration record type of the message data field is the second type, acquiring configuration element information of the message data field corresponding to the data field identification from a preset record file.
In one embodiment, the configuration element obtaining module 403 is further configured to dynamically compile a code file including a data domain entity class corresponding to the data domain identifier; and in the dynamic compiling process, extracting entity class information containing the entity class of the data domain corresponding to the data domain identifier to obtain the configuration element information of the message data domain.
In one embodiment, the first code generating module 404 is further configured to replace a placeholder in a preset message code template with corresponding configuration element information to obtain a candidate code file; and carrying out standardization processing on the candidate code files to obtain the code files aiming at the message data fields.
In one embodiment, the first code generating module 404 is further configured to determine a data field type of the message data field corresponding to the data field identifier; the data field type includes an input data field and an output data field; determining a corresponding target preset message code template according to the data field type; and generating a code file aiming at the message data field by adopting a target preset message code template and configuration element information.
In one embodiment, the second code generating module 405 is further configured to obtain a message header code and a message Wen Weibu code of the message to be generated according to a message interaction protocol of the message to be generated; and merging the message header code, the message Wen Weibu code and the code file of the message data field in sequence according to the message interaction protocol of the message to be generated to obtain the code file of the message to be generated.
All or part of the modules in the message code generating device can be realized by software, hardware and a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one exemplary embodiment, a computer device is provided, which may be a terminal, and an internal structure diagram thereof may be as shown in fig. 5. The computer device includes a processor, a memory, an input/output interface, a communication interface, a display unit, and an input means. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The input/output interface of the computer device is used to exchange information between the processor and the external device. The Communication interface of the computer device is used for conducting wired or wireless Communication with an external terminal, and the wireless Communication can be realized through WIFI, a mobile cellular network, near field Communication (NEAR FIELD Communication) or other technologies. The computer program, when executed by a processor, implements a method of generating message code. The display unit of the computer device is used for forming a visual picture, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, can also be a key, a track ball or a touch pad arranged on the shell of the computer equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by those skilled in the art that the structure shown in FIG. 5 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements may be applied, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In an embodiment, there is also provided a computer device comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the method embodiments described above when the computer program is executed.
In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when executed by a processor, carries out the steps of the method embodiments described above.
In an embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
It should be noted that, the user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the present application are both information and data authorized by the user or sufficiently authorized by each party, and the collection, use and processing of the related data are required to meet the related regulations.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided herein may include at least one of non-volatile memory and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (RESISTIVE RANDOM ACCESS MEMORY, reRAM), magneto-resistive Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (PHASE CHANGE Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in various forms such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc. The databases referred to in the embodiments provided herein may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processor referred to in the embodiments provided in the present application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computation, an artificial intelligence (ARTIFICIAL INTELLIGENCE, AI) processor, or the like, but is not limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the present application.
The foregoing examples illustrate only a few embodiments of the application and are described in detail herein without thereby limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of the application should be assessed as that of the appended claims.

Claims (11)

1. The method for generating the message code is characterized by comprising the following steps:
determining a data domain identifier of a message data domain contained in a message to be generated according to a message interaction protocol of the message to be generated in the financial field;
Determining the configuration record type of the message data field according to the data field identification;
Acquiring configuration element information of the message data field by adopting a configuration record query mode corresponding to the configuration record type;
Generating a code file aiming at the message data field by adopting a preset message code template and the configuration element information;
And obtaining the code file of the message to be generated according to the code file of the message data field.
2. The method according to claim 1, wherein determining the configuration record type of the message data field according to the data field identifier comprises:
In a preset code file catalog, retrieving a code file containing a data domain entity class corresponding to the data domain identifier;
Under the condition that the retrieval is successful, determining the configuration record type of the message data field as a first type;
And under the condition of failure in retrieval, determining the configuration record type of the message data field as a second type.
3. The method according to claim 2, wherein the obtaining the configuration element information of the packet data field by using a configuration record query manner corresponding to the configuration record type includes:
Under the condition that the configuration record type of the message data field is the first type, obtaining configuration element information of the message data field according to the code file containing the data field entity class corresponding to the data field identifier;
And under the condition that the configuration record type of the message data field is the second type, acquiring configuration element information of the message data field corresponding to the data field identification from a preset record file.
4. The method according to claim 3, wherein the obtaining the configuration element information of the message data field according to the code file containing the data field entity class corresponding to the data field identifier includes:
dynamically compiling the code file containing the data domain entity class corresponding to the data domain identifier;
and in the dynamic compiling process, extracting entity class information containing the data domain entity class corresponding to the data domain identifier to obtain configuration element information of the message data domain.
5. The method of claim 1, wherein generating a code file for the message data field using a preset message code template and the configuration element information comprises:
Replacing the placeholders in the preset message code template with the corresponding configuration element information to obtain candidate code files;
And normalizing the candidate code file to obtain a code file aiming at the message data field.
6. The method of claim 1, wherein generating a code file for the message data field using a preset message code template and the configuration element information comprises:
determining the data field type of the message data field corresponding to the data field identification; the data field type comprises an input data field and an output data field;
determining a corresponding target preset message code template according to the data field type;
And generating a code file aiming at the message data field by adopting the target preset message code template and the configuration element information.
7. The method according to any one of claims 1 to 6, wherein the obtaining the code file of the message to be generated according to the code file of the message data field includes:
Acquiring a message header code and a message Wen Weibu code of the message to be generated according to the message interaction protocol of the message to be generated;
And merging the message header code, the message Wen Weibu code and the code file of the message data field in sequence according to the message interaction protocol of the message to be generated to obtain the code file of the message to be generated.
8. A device for generating a message code, the device comprising:
the data domain determining module is used for determining a data domain identifier of a message data domain contained in a message to be generated according to a message interaction protocol of the message to be generated in the financial field;
The record type determining module is used for determining the configuration record type of the message data field according to the data field identification;
The configuration element acquisition module is used for acquiring configuration element information of the message data field by adopting a configuration record query mode corresponding to the configuration record type;
the first code generation module is used for generating a code file aiming at the message data field by adopting a preset message code template and the configuration element information;
And the second code generation module is used for obtaining the code file of the message to be generated according to the code file of the message data field.
9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 7 when the computer program is executed.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 7.
11. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 7.
CN202410609302.2A 2024-05-16 2024-05-16 Method and device for generating message codes, computer equipment and readable storage medium Pending CN118200407A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410609302.2A CN118200407A (en) 2024-05-16 2024-05-16 Method and device for generating message codes, computer equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410609302.2A CN118200407A (en) 2024-05-16 2024-05-16 Method and device for generating message codes, computer equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN118200407A true CN118200407A (en) 2024-06-14

Family

ID=91397077

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410609302.2A Pending CN118200407A (en) 2024-05-16 2024-05-16 Method and device for generating message codes, computer equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN118200407A (en)

Similar Documents

Publication Publication Date Title
CN111984659B (en) Data updating method, device, computer equipment and storage medium
CN106648569B (en) Target serialization realization method and device
CN111240772A (en) Data processing method and device based on block chain and storage medium
CN119645534A (en) File processing method, device and computer equipment
CN117010358A (en) Message card generation method, device, computer equipment and storage medium
CN118012873A (en) Data table operation method, device, computer equipment and storage medium
CN115934098B (en) Physical model configuration method, device and computer-readable storage medium
CN118200407A (en) Method and device for generating message codes, computer equipment and readable storage medium
CN117827902A (en) Service data processing method, device, computer equipment and storage medium
CN117271478A (en) Data migration methods, devices, storage media and electronic equipment
CN112632266B (en) Data writing method and device, computer equipment and readable storage medium
CN115934669A (en) Three-dimensional tile storage and distribution method and device
US9471569B1 (en) Integrating information sources to create context-specific documents
CN119557331B (en) Business resource retrieval method, device, computer equipment and readable storage medium based on AI big model
CN118278377B (en) A data management method and system based on document template matching
KR101737575B1 (en) Method and device for verifying data based on sql sentences generated automatically
CN118839350B (en) Code repair method, device, equipment and medium
CN115390912B (en) Resource discovery method, device, computer equipment and storage medium
CN114610688B (en) Log aggregation method, device, computer equipment and storage medium
CN112181407A (en) Service implementation processing method, device, system, electronic equipment and storage medium
CN118133799A (en) User file template integration method, device, equipment and storage medium
CN119759316A (en) Method, device, computer equipment and storage medium for generating requirement specification
CN119271266A (en) Java annotation conversion method, device, electronic device and storage medium
CN119441269A (en) A method, device, equipment and medium for generating SQL for expressing blood relationship
CN117931707A (en) System for realizing service arrangement parameter self-adapting processing based on metadata under micro-service architecture

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination