Data execution method and device, computer equipment and storage medium
By receiving data execution requests from the business system and parsing the configuration file to obtain and verify the target class name and method, the problem of code redundancy and low execution efficiency in traditional methods is solved, achieving efficient and flexible method execution and system expansion.
Patent Information
- Application Number
- CN202510694316.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-27
- Publication Date
- 2025-10-28
AI Technical Summary
In traditional business systems, implementing multiple subclasses based on the same parent class and dynamically calling their methods results in code redundancy, high maintenance costs, low execution efficiency, and insufficient system flexibility. This is especially problematic in scenarios with high-frequency expansion or real-time requirements, where it is difficult to quickly respond to changes in business needs.
By receiving data execution requests, parsing class name information and determining whether a matching target class name exists in the configuration file, after legality verification, the target class is obtained, and target methods that conform to the naming rules are selected for execution, thus avoiding hard-coding modifications to the main module code.
It improves the execution efficiency and flexibility of the target method, reduces code maintenance costs, and enhances the system's scalability and business responsiveness.
Smart Images

Figure CN120848985A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology and can be applied to fields such as fintech and digital healthcare, and in particular to data execution methods, devices, computer equipment and storage media. Background Technology
[0002] In traditional business system development, when multiple subclasses need to be implemented based on the same parent class and their methods dynamically called, each subclass usually needs to be explicitly referenced in the main module. This leads to redundant code and high maintenance costs in the main module. Specifically, the main module needs to hard-code the import path and instantiation logic of the subclasses. When adding a new subclass, the main module code must be manually modified, which not only increases the development workload but also makes it easy to introduce errors due to human error. In addition, the efficiency of dynamically loading and executing subclass methods is limited by hard-coded dependencies, resulting in low execution efficiency of subclass methods, making it difficult to adapt to scenarios with high-frequency expansion or high real-time requirements. This tightly coupled design makes the system inflexible and unable to quickly respond to changes in business needs.
[0003] For example, in loan approval systems in the financial sector, different loan products (such as personal consumer loans and corporate mortgage loans) require differentiated risk assessment logic through subclasses. Traditionally, the main module needs to reference each loan product's subclass individually, and adding a new loan product necessitates modifying the main module's code, leading to extended development cycles and decreased system stability. If new loan products (such as supply chain finance loans) need to be launched quickly, traditional methods cannot efficiently support this due to high code coupling, potentially causing missed market opportunities.
[0004] Therefore, there is an urgent need for an efficient modular design method to eliminate hard-coded dependencies between main modules and subclasses, improve system scalability and method execution efficiency, thereby reducing maintenance costs and enhancing business responsiveness. Summary of the Invention
[0005] The purpose of this application is to provide a data execution method, apparatus, computer device, and storage medium to solve the technical problem of low execution efficiency of subclass methods in existing business system development models where multiple subclasses need to be implemented based on the same parent class and their methods are dynamically called.
[0006] Firstly, a data execution method is provided, including:
[0007] Receive a data execution request triggered by a user; wherein the data execution request carries class name information;
[0008] The main module reads the configuration file based on a preset configuration; wherein, the configuration file stores a pre-configured list of class names;
[0009] The class name information is parsed from the data execution request, and it is determined whether there is a target class name that matches the class name information in the class name list in the configuration file;
[0010] If so, perform a validity check on the target class name;
[0011] If the target class name passes the validity verification, the target class corresponding to the target class name is obtained based on the preset acquisition method;
[0012] All methods defined under the target class are filtered to obtain target methods that conform to preset naming rules;
[0013] The target method is then executed.
[0014] Secondly, a data execution device is provided, comprising:
[0015] A receiving module is used to receive data execution requests triggered by users; wherein the data execution request carries class name information;
[0016] A reading module is used to read a configuration file based on a preset main module; wherein, the configuration file stores a pre-configured list of class names;
[0017] The first judgment module is used to parse the class name information from the data execution request and determine whether there is a target class name that matches the class name information in the class name list in the configuration file;
[0018] The verification module is used to verify the legality of the target class name if the condition is met.
[0019] The first acquisition module is used to acquire the target class corresponding to the target class name based on a preset acquisition method if the target class name passes the validity verification.
[0020] The filtering module is used to filter all methods defined under the target class to obtain target methods that conform to preset naming rules;
[0021] The execution module is used to perform execution processing on the target method.
[0022] Thirdly, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described data execution method.
[0023] Fourthly, a computer-readable storage medium is provided, which stores a computer program that, when executed by a processor, implements the steps of the above-described data execution method.
[0024] In the above-described data execution method, apparatus, computer device, and storage medium, a data execution request triggered by a user is first received; wherein the data execution request carries class name information; then, a configuration file is read based on a preset main module; wherein the configuration file stores a pre-configured list of class names; subsequently, the class name information is parsed from the data execution request, and it is determined whether there is a target class name matching the class name information in the class name list in the configuration file; if so, the target class name is validated for legality; if the target class name passes the validity validation, the target class corresponding to the target class name is obtained based on a preset acquisition method; subsequently, all methods defined under the target class are filtered to obtain target methods that conform to preset naming rules; finally, the target methods are executed. Upon receiving a user-triggered data execution request, this application reads the configuration file using the main module, parses the class name information from the data execution request, and checks if a target class name matching the class name information exists in the class name list in the configuration file. If it does, the target class name undergoes validity verification. If the target class name passes the validity verification, the target class corresponding to the target class name is retrieved based on the retrieval method. Subsequently, all methods defined under the target class are filtered to obtain target methods that conform to preset naming rules. Finally, the target methods are executed. Based on the above data execution process, this application pre-configures the class name list in the configuration file, then uses the main module to read the class name list in the configuration file and determine the target class matching the user-input class name information. It then accesses the target class matching the target class based on the retrieval method, thus dynamically filtering out target methods that conform to the naming rules from all methods defined under the target class for direct execution. This ensures that during the execution of the target method corresponding to the target class, the method name and execution are determined at runtime, eliminating the need for hard coding and requiring no additional modification to the main module code. This effectively improves the execution efficiency and flexibility of the target method. Attached Figure Description
[0025] To more clearly illustrate the solutions in this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0026] Figure 1 This is an exemplary system architecture diagram to which this application can be applied;
[0027] Figure 2 This is a flowchart of one embodiment of the data execution method according to this application;
[0028] Figure 3 This is a schematic diagram of a structure of an embodiment of the data execution apparatus according to this application;
[0029] Figure 4 This is a schematic diagram of the structure of one embodiment of the computer device according to this application. Detailed Implementation
[0030] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the terminology used herein in the specification of the application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "comprising" and "having," and any variations thereof, in the specification, claims, and foregoing drawings of this application, are intended to cover non-exclusive inclusion. The terms "first," "second," etc., in the specification, claims, or foregoing drawings of this application are used to distinguish different objects, not to describe a particular order.
[0031] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0032] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
[0033] like Figure 1 As shown, system architecture 100 may include terminal device 101, network 102, and server 103. Terminal device 101 may be a laptop 1011, tablet 1012, or mobile phone 1013. Network 102 is used as a medium to provide a communication link between terminal device 101 and server 103. Network 102 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.
[0034] Users can use terminal device 101 to interact with server 103 via network 102 to receive or send messages, etc. Various communication client applications can be installed on terminal device 101, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social media platform software, etc.
[0035] Terminal device 101 can be various electronic devices with a display screen and support web browsing. In addition to laptops 1011, tablets 1012, or mobile phones 1013, terminal device 101 can also be an e-book reader, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 player (Moving Picture Experts Group Audio Layer IV), a laptop computer, and a desktop computer, etc.
[0036] Server 103 can be a server that provides various services, such as a backend server that provides support for the pages displayed on terminal device 101.
[0037] It should be noted that the data execution method provided in the embodiments of this application is generally executed by a server / terminal device, and correspondingly, the data execution device is generally located in the server / terminal device.
[0038] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0039] Continue to refer to Figure 2 A flowchart illustrating an embodiment of the data execution method according to this application is shown. The order of steps in the flowchart can be changed, and some steps can be omitted, depending on different requirements. The data execution method provided by this application embodiment can be applied to any scenario requiring data execution, and therefore can be applied to products in these scenarios. The data execution method includes the following steps:
[0040] Step S201: Receive a data execution request triggered by the user; wherein the data execution request carries class name information.
[0041] In this embodiment, the data execution method runs on an electronic device (e.g., Figure 1The server / terminal device shown can receive user-triggered data execution requests via wired or wireless connections. It should be noted that the aforementioned wireless connection methods include, but are not limited to, 3G / 4G / 5G connections, WiFi connections, Bluetooth connections, WiMAX connections, Zigbee connections, UWB (ultra-wideband) connections, and other currently known or future-developed wireless connection methods. The execution entity of this application is specifically a data execution system, which can be simply referred to as the system. The aforementioned data execution request is a user-triggered request to execute a method of the class corresponding to the aforementioned class name information. This application can be applied to data (class method) execution business scenarios corresponding to newly added business classes in the financial and medical fields. The aforementioned class name information can be a newly added business class input by the user.
[0042] For example, in the financial sector, the newly added business class corresponding to the above class name information could be `PersonalAutoInsurancePremium`. The corresponding method for this business class includes: `calculate_premium(age, driving_history, vehicle_value)`. The newly added function for this business class is dynamic premium calculation rules. The user requirement is: insurance companies need to dynamically adjust the premium calculation logic based on different customer types (e.g., individuals, businesses) or insurance product types (e.g., auto insurance, health insurance). The function includes: calculating premiums based on the age, driving record, and vehicle value of individual auto insurance customers.
[0043] In the medical field, the newly added business class corresponding to the above class name information could be ElderlyHealthCheck. The corresponding method for this business class includes: recommend_tests(age, medical_history, lifestyle). The newly added function for this business class is dynamic health check items. User requirements are: hospitals need to dynamically recommend health check items (such as basic physical examinations and cancer screenings) based on patients' age, gender, and medical history. Functionality includes: recommending electrocardiograms, bone density tests, and other items for elderly patients.
[0044] Step S202: Read the configuration file based on the preset main module; wherein the configuration file stores a pre-configured list of class names.
[0045] In this embodiment, the pre-configured list of class names can be obtained by reading the configuration file mentioned above in the main module.
[0046] The main module and configuration file interact through a read-parse-use process, achieving separation between code and configuration files. This design improves the system's maintainability and scalability. Specifically, the relationship between the main module and configuration file includes: 1. Decoupling Design: Dynamics: The main module determines which classes to load through the configuration file, allowing for functional expansion without code modification. Flexibility: The configuration file can be modified independently of the code (e.g., adding / deleting class names), suitable for production environment adjustments. 2. Dependencies: The main module depends on the configuration file: The main module requires the configuration file to exist and be in the correct format; otherwise, exceptions may be thrown (e.g., file not found, incorrect format). The configuration file defines behavior: The content of the configuration file directly determines the dynamic behavior of the main module (e.g., which classes to load, initialization parameters, etc.). 3. Data Flow: Unidirectional data flow: Configuration file → Main module (the main module reads and parses, without modifying the configuration file). Data Structure Mapping: The list of class names in the configuration file must match the actual class names existing in the main module; otherwise, dynamic loading will fail. 4. Error Handling: The main module needs to handle exceptions: such as file read failure, incorrect configuration format, non-existent class names, etc., which must be caught and handled using try-except statements. Configuration files should be standardized: A clear format (such as JSON Schema or YAML comments) should be agreed upon to reduce parsing errors in the main module. 5. Extensibility. Support for multi-environment configuration: Configuration files can be adapted to development / production environments through different configuration files. Support for complex configurations: Configuration files can be expanded to include parameters beyond class names (such as initialization parameters and dependencies) for further use by the main module.
[0047] Furthermore, the construction process of the aforementioned configuration file will be described in more detail in subsequent specific embodiments of this application, and will not be elaborated upon here.
[0048] Furthermore, by configuring the class name in the configuration file, and then reading the class name from the configuration file in the main module to access the class, and by standardizing the naming format of the class methods, the class methods can be dynamically extracted and executed directly. With this approach, each time a new implementation class is added, only the associated class name needs to be added to the configuration file, without modifying the code in the main module.
[0049] Step S203: Parse the class name information from the data execution request, and determine whether there is a target class name matching the class name information in the class name list in the configuration file.
[0050] In this embodiment, the class name information carried in the data execution request can be obtained by parsing the aforementioned data execution request. Furthermore, the class name information can be matched against all class names contained in the class name list in the configuration file, and the matching result can be used to determine whether a target class name matching the class name information exists in the class name list. Specifically, if the matching result is successful, it is determined that a target class name matching the class name information exists in the class name list in the configuration file; otherwise, if the matching result is unsuccessful, it is determined that a target class name matching the class name information does not exist in the class name list in the configuration file.
[0051] Step S204: If yes, perform a validity verification on the target class name.
[0052] In this embodiment, the specific implementation process of validating the target class name will be described in more detail in subsequent embodiments of this application, and will not be elaborated on here.
[0053] Step S205: If the target class name passes the validity verification, the target class corresponding to the target class name is obtained based on the preset acquisition method.
[0054] In this embodiment, the specific implementation process of obtaining the target class corresponding to the target class name based on the preset acquisition method will be described in more detail in subsequent specific embodiments of this application, and will not be elaborated on here.
[0055] Step S206: Filter all methods defined under the target class to obtain target methods that conform to the preset naming rules.
[0056] In this embodiment, the inspect module can be used to examine all methods defined under the target class and filter out methods whose names begin with a specific prefix (such as run_step), thus obtaining the target methods that conform to the naming rules.
[0057] Step S207: Perform execution processing on the target method.
[0058] In this embodiment, the specific implementation process of executing the target method described above will be further described in detail in subsequent specific embodiments of this application, and will not be elaborated on here.
[0059] This application first receives a user-triggered data execution request, wherein the data execution request carries class name information; then, it reads a configuration file based on a preset main module, wherein the configuration file stores a pre-configured list of class names; next, it parses the class name information from the data execution request and determines whether there is a target class name matching the class name information in the class name list in the configuration file; if so, it performs a validity verification on the target class name; if the target class name passes the validity verification, it obtains the target class corresponding to the target class name based on a preset acquisition method; subsequently, it filters all methods defined under the target class to obtain target methods that conform to preset naming rules; finally, it executes the target methods. Upon receiving a user-triggered data execution request, this application reads the configuration file using the main module, parses the class name information from the data execution request, and checks if a target class name matching the class name information exists in the class name list in the configuration file. If it does, the target class name undergoes validity verification. If the target class name passes the validity verification, the target class corresponding to the target class name is retrieved based on the retrieval method. Subsequently, all methods defined under the target class are filtered to obtain target methods that conform to preset naming rules. Finally, the target methods are executed. Based on the above data execution process, this application pre-configures the class name list in the configuration file, then uses the main module to read the class name list in the configuration file and determine the target class matching the user-input class name information. It then accesses the target class matching the target class based on the retrieval method, thus dynamically filtering out target methods that conform to the naming rules from all methods defined under the target class for direct execution. This ensures that during the execution of the target method corresponding to the target class, the method name and execution are determined at runtime, eliminating the need for hard coding and requiring no additional modification to the main module code. This effectively improves the execution efficiency and flexibility of the target method.
[0060] In some alternative implementations, prior to step S202, the electronic device may also perform the following steps:
[0061] Get the predefined parent class, and get the subclass that meets the preset loading requirements corresponding to the parent class.
[0062] In this embodiment, a parent class is predefined based on actual business needs. All subclasses inherit from this parent class and follow a unified naming convention and method specification. The parent class can be an abstract base class (if it's necessary to force subclasses to implement certain methods). The parent class can provide some common functionalities (such as logging, initialization methods, etc.). The naming conventions include: methods that need to be executed in the subclass must be named with a specific prefix (e.g., run_step). For example, run_step1, run_step2, etc., to facilitate subsequent filtering and invocation. Furthermore, the aforementioned subclasses can be classes configured by relevant personnel based on actual business needs that may require dynamic loading. Each subclass inherits from the parent class and implements its own business logic methods. Subclasses can be distributed across different modules for easy modular management.
[0063] Obtain the subclass name of the subclass, and generate a corresponding list of class names based on the subclass name.
[0064] In this embodiment, the names of the subclasses can be obtained by querying the names of the subclasses, and all subclass names can be integrated to generate a corresponding class name list. Furthermore, other business classes can be added to the class name list as needed to update the list.
[0065] Get the preset initial file.
[0066] In this embodiment, the initial file can be a blank file constructed using JSON or YAML format, which is easy for humans to read and edit.
[0067] The list of class names is stored in the initial file to obtain the configuration file.
[0068] In this embodiment, the configuration file can be constructed by storing the above-mentioned class name list in the initial file, and the required class name list can be easily read in subsequent use based on the configuration file.
[0069] The configuration file is stored based on a preset storage method.
[0070] In this embodiment, the above storage method includes storing the above configuration file in the project root directory or a specific configuration directory, and the path needs to be consistent with the main module code.
[0071] This application obtains a predefined parent class and corresponding subclasses that meet preset loading requirements. Then, it obtains the subclass names of these subclasses and generates a list of corresponding class names based on them. Next, it obtains a preset initial file and stores the class name list within the initial file to obtain the configuration file. Subsequently, the configuration file is stored using a preset storage method. This application achieves intelligent and efficient construction of the required configuration file by obtaining a predefined parent class and corresponding subclasses that meet preset loading requirements, then obtaining the subclass names of these subclasses, generating a list of corresponding class names based on them, and storing the list of class names in a preset initial file. This improves the efficiency and intelligence of configuration file generation. Furthermore, the storage processing based on the storage method ensures the security and intelligence of configuration file storage.
[0072] In some optional implementations of this embodiment, step S204 includes the following steps:
[0073] Get the pre-defined class name whitelist.
[0074] In this embodiment, a list of valid class names is defined based on actual business data processing needs and used as a class name whitelist. For example, WHITELIST = ['EmailHandler', 'SmsHandler'].
[0075] Determine whether the target class name exists in the class name whitelist.
[0076] In this embodiment, the target class name can be matched with all class names in the class name whitelist. If a specified class name matching the target class name exists in the class name whitelist, the target class name is determined to exist in the class name whitelist. If no specified class name matching the target class name exists in the class name whitelist, the target class name is determined not to exist in the class name whitelist.
[0077] If the target class name exists in the class name whitelist, then the target class name is determined to have passed the validity verification.
[0078] In this embodiment, if the target class name is detected to exist in the class name whitelist, it indicates that the target class name is a legal class name, and thus the target class name is determined to have passed the legality verification.
[0079] If the target class name does not exist in the class name whitelist, then the target class name is determined to have failed the validity verification.
[0080] In this embodiment, if the target class name is detected to be outside the class name whitelist, it indicates that the target class name is not a valid class name, and thus the target class name fails the validity verification. Additionally, a warning log can be recorded and the class can be skipped.
[0081] This application obtains a preset class name whitelist; then determines whether the target class name exists in the class name whitelist; if the target class name exists in the class name whitelist, the target class name is determined to have passed the validity verification; otherwise, the target class name is determined to have failed the validity verification. By using a class name whitelist, this application can achieve efficient and accurate validity verification of target class names, improving the processing efficiency and intelligence of validity verification, and ensuring the accuracy of the obtained validity verification results. Furthermore, the method corresponding to the target class name will only be executed when the target class name passes the validity verification, effectively improving the standardization and intelligence of processing user-triggered data execution requests.
[0082] In some alternative implementations, step S205 includes the following steps:
[0083] Call the default import method.
[0084] In this embodiment, the aforementioned preset import method can specifically be the importlib.import_module() method.
[0085] Based on the import method, the specified module corresponding to the target class name is imported.
[0086] In this embodiment, the module containing the target class corresponding to the target class name can be imported using the above-described import method, i.e., the specified module.
[0087] Call the preset retrieval method.
[0088] In this embodiment, the above-mentioned acquisition method can specifically adopt the getattr() method.
[0089] Based on the acquisition method, a class object corresponding to the target class name is obtained from the specified module.
[0090] In this embodiment, the class object corresponding to the target class name is obtained from the specified module imported above, based on the target class name, using the above-described acquisition method.
[0091] The class object is used as the target class.
[0092] In this embodiment, the validity of the aforementioned class object can be verified by checking whether the class object is None or whether an AttributeError is thrown. If the class object is not None and no AttributeError is thrown, the validity of the class object is verified, and the class object is then used as the target class. If the aforementioned class object is None or an AttributeError is thrown, it indicates that the class name of the class object does not exist, and an error log is recorded and the class object is skipped.
[0093] This application achieves modular import by invoking a preset import method; importing a specified module corresponding to the target class name based on the import method; then invoking a preset retrieval method; and retrieving a class object corresponding to the target class name from the specified module based on the retrieval method; subsequently, using the class object as the target class. This modular import method effectively avoids space pollution, improves the intelligence of target class retrieval, and enhances code maintainability.
[0094] In some optional implementations, the step of obtaining the target class corresponding to the target class name based on a preset acquisition method may further include: obtaining the target class corresponding to the target class name using Python's built-in `globals()` method. The `globals()` method returns a dictionary of the current global namespace, containing all imported classes and functions. If the class has already been imported into the current module, the class object can be directly obtained from `globals()` using the class name (a string).
[0095] In some alternative implementations, step S207 includes the following steps:
[0096] The target method is verified based on a preset signature verification strategy.
[0097] In this embodiment, the aforementioned signature verification strategy is a pre-built strategy used to distinguish whether the parameters passed when calling or executing a method conform to the method signature requirements. The strategy includes: using inspect.signature() to parse the parameter list of the method, obtaining the parameter names and default values, and verifying whether the passed parameters conform to the method signature before calling or executing the method. If the parameters conform to the method signature, the method is executed; otherwise, an exception is thrown or a warning is logged.
[0098] Specifically, signature verification of the target method can be performed based on the strategy content of the aforementioned signature verification strategy, and a signature verification result of the target method can be obtained. The signature verification result includes whether the target method passes signature verification or fails signature verification.
[0099] If the target method passes signature verification, then the preset target acquisition method is invoked.
[0100] In this embodiment, if the target method is detected to have passed signature verification, the getattr() method, i.e., the target acquisition method, will be called.
[0101] Obtain the method name of the target method.
[0102] In this embodiment, the method name of the target method can be obtained by performing a name query on the target method.
[0103] Based on the method name, the target method is executed through the target acquisition method.
[0104] In this embodiment, by using the target acquisition method described above, namely the getattr() method, the corresponding target method can be called by the method name, that is, the target method can be executed.
[0105] This application performs signature verification on the target method based on a preset signature verification strategy. If the target method passes the signature verification, a preset target acquisition method is invoked. Then, the method name of the target method is obtained. Subsequently, based on the method name, the target method is executed using the target acquisition method. Before executing the target method, this application intelligently performs signature verification on the target method based on the signature verification strategy. When the target method passes the signature verification, the preset target acquisition method is invoked. Then, based on the obtained method name, the target method is executed using the target acquisition method. This method effectively ensures that the dynamically invoked target method exists and its parameters match, avoids errors during the execution of the target method, and effectively improves the security of the target method's execution.
[0106] In some optional implementations of this embodiment, after step S207, the electronic device may further perform the following steps:
[0107] Obtain the preset exception handling strategy.
[0108] In this embodiment, the above-mentioned exception handling strategy is a pre-built strategy to prevent program crashes caused by non-existent methods. This strategy can be used to catch AttributeError (method not found) and TypeError (method signature mismatch).
[0109] The execution process of the target method is subjected to exception capture based on the exception handling strategy, and the corresponding exception capture result is obtained.
[0110] In this embodiment, based on the aforementioned exception handling strategy, exceptions can be captured during the execution of the target method. Specifically, this captures instances where the method name is missing or the method signature does not match, and generates corresponding exception capture results. The content of these exception capture results may include whether an exception exists or not. Specifically, if an exception such as a missing method name and / or a mismatched method signature exists during the execution of the target method, an exception capture result indicating the existence of an exception will be generated. Conversely, if neither a missing method name nor a mismatched method signature exists during the execution of the target method, an exception capture result indicating the absence of an exception will be generated.
[0111] Determine whether the exception capture result indicates the existence of an exception.
[0112] In this embodiment, the presence of an anomaly can be determined by parsing the above-mentioned anomaly capture results.
[0113] If so, record the exception information generated during the execution process, and display the corresponding prompt information based on the exception information.
[0114] In this embodiment, if the detected exception capture result indicates the presence of an exception, the exception information generated during the execution of the target method will be recorded, such as a non-existent method name or a mismatched method signature (e.g., incorrect number or type of parameters). Correspondingly, if the exception information indicates a non-existent method name, an AttributeError message will be generated to indicate an invalid method name. If the exception information indicates a mismatched method signature, a TypeError message will be generated to indicate incorrect parameters.
[0115] The abnormal information is recorded in a pre-created log.
[0116] In this embodiment, the aforementioned log is a pre-created log file used to store exception information. Recording this exception information facilitates subsequent analysis.
[0117] This application obtains a preset exception handling strategy; then, based on the exception handling strategy, it captures exceptions during the execution of the target method to obtain corresponding exception capture results; subsequently, it determines whether the exception capture results indicate the existence of an exception; if so, it records the exception information generated during the execution process and displays corresponding prompt information based on the exception information; and then records the exception information in a pre-created log. During the execution of the target method, this application intelligently captures exceptions during the execution process based on the exception handling strategy, and when an exception capture result indicates the existence of an exception, it automatically records the exception information generated during the execution process, displays corresponding prompt information based on the exception information, and records the exception information in a pre-created log. This enables automatic and intelligent recording of exception information during the execution of the target method, facilitating subsequent collaboration and troubleshooting of the target method, thereby improving the maintainability and debuggability of the target method.
[0118] In some optional implementations of this embodiment, after step S207, the electronic device may further perform the following steps:
[0119] After completing the execution processing of the target method, the execution result of the target method is obtained.
[0120] In this embodiment, after completing the execution processing of the target method described above, the execution result of the target method can be recorded. The execution result of the target method may include whether the method execution was successful or failed.
[0121] Call the default logging library.
[0122] In this embodiment, the selection of the aforementioned log library is not specifically limited and can be determined based on actual business needs. For example, a standard library or a third-party library can be used. If the project has simple logging requirements, a standard library is chosen. However, if a more user-friendly default configuration (such as automatic output to the console or automatic file rotation) is required, a third-party library is selected.
[0123] The execution result of the target method, the target class name, and the target method are integrated to obtain the target log content corresponding to the class name information.
[0124] In this embodiment, the logging module can be used to record the loaded target class name and the called target method. Then, according to a preset information sorting order, the recorded execution result of the target method, the target class name, and the target method can be sequentially integrated to generate target log content containing key information corresponding to the aforementioned class name information. The specific order of information sorting is not limited and can be set according to actual business needs.
[0125] The target log content is stored in the log library.
[0126] In this embodiment, the target log content can be stored in a specified directory within the log database to complete the storage processing of the target log content.
[0127] This application, after completing the execution of the target method, obtains the execution result of the target method; then calls a preset log library; subsequently, it integrates the execution result of the target method, the target class name, and the target method to obtain target log content corresponding to the class name information; and finally stores the target log content in the log library. This application, after completing the execution of the target method, obtains the execution result of the target method, automatically integrates the execution result, the target class name, and the target method to obtain target log content corresponding to the class name information, and stores the target log content in the log library. This achieves intelligent recording of key information during the method execution process, facilitating subsequent debugging and problem investigation, and improving code maintainability and debuggability.
[0128] In some alternative implementations, the user information obtained is subject to user consent and complies with relevant laws and policies.
[0129] Furthermore, any software tools or components not belonging to our company that appear in the embodiments of this application are merely illustrative examples and do not represent actual use.
[0130] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0131] It should be emphasized that, to further ensure the privacy and security of the above configuration file, the configuration file can also be stored in a node of a blockchain.
[0132] The blockchain referred to in this application is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Essentially, a blockchain is a decentralized database, a chain of data blocks linked together using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include an underlying blockchain platform, a platform product service layer, and an application service layer.
[0133] The embodiments of this application can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence (AI) is the theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results.
[0134] Foundational technologies for artificial intelligence generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies mainly encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.
[0135] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by instructing related hardware with computer-readable instructions. These computer-readable instructions can be stored in a computer-readable storage medium. When executed, the program can include the processes of the embodiments of the above methods. The aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, optical disk, or read-only memory (ROM), or random access memory (RAM).
[0136] It should be understood that although the steps in the flowcharts of the accompanying figures are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the accompanying figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0137] Further reference Figure 3As a response to the above Figure 2 To implement the method shown, this application provides an embodiment of a data execution apparatus, which is similar to... Figure 2 Corresponding to the method embodiments shown, this device can be specifically applied to various electronic devices.
[0138] like Figure 3 As shown, the data execution device 300 described in this embodiment includes: a receiving module 301, a reading module 302, a first judgment module 303, a verification module 304, a first acquisition module 305, a filtering module 306, and an execution module 307. Wherein:
[0139] The receiving module 301 is used to receive a data execution request triggered by a user; wherein the data execution request carries class name information;
[0140] The reading module 302 is used to read the configuration file based on the preset main module; wherein, the configuration file stores a pre-configured list of class names;
[0141] The first judgment module 303 is used to parse the class name information from the data execution request and determine whether there is a target class name that matches the class name information in the class name list in the configuration file.
[0142] Verification module 304 is used to perform legality verification on the target class name if the condition is met.
[0143] The first acquisition module 305 is used to acquire the target class corresponding to the target class name based on a preset acquisition method if the target class name passes the validity verification.
[0144] The filtering module 306 is used to filter all methods defined under the target class to obtain target methods that conform to preset naming rules;
[0145] The execution module 307 is used to perform execution processing on the target method.
[0146] In this embodiment, the operations performed by the above modules or units correspond one-to-one with the steps of the data execution method in the aforementioned embodiments, and will not be repeated here.
[0147] In some optional implementations of this embodiment, the data execution device further includes:
[0148] The second acquisition module is used to acquire a predefined parent class and a subclass that corresponds to the parent class and meets the preset loading requirements.
[0149] The generation module is used to obtain the subclass name of the subclass and generate a corresponding class name list based on the subclass name;
[0150] The third acquisition module is used to acquire the preset initial file;
[0151] The first storage module is used to store the list of class names into the initial file to obtain the configuration file;
[0152] The second storage module is used to store the configuration file based on a preset storage method.
[0153] In this embodiment, the operations performed by the above modules or units correspond one-to-one with the steps of the data execution method in the aforementioned embodiments, and will not be repeated here.
[0154] In some optional implementations of this embodiment, the verification module 304 includes:
[0155] The first submodule is used to obtain a preset whitelist of class names;
[0156] The judgment submodule is used to determine whether the target class name exists in the class name whitelist;
[0157] The first determination submodule is used to determine that the target class name passes the legality verification if the target class name exists in the class name whitelist.
[0158] The second determination submodule is used to determine that the target class name has failed the legality verification if the target class name does not exist in the class name whitelist.
[0159] In this embodiment, the operations performed by the above modules or units correspond one-to-one with the steps of the data execution method in the aforementioned embodiments, and will not be repeated here.
[0160] In some optional implementations of this embodiment, the first acquisition module 305 includes:
[0161] The first submodule is used to invoke the preset import method;
[0162] Import submodule, used to import a specified module corresponding to the target class name based on the import method;
[0163] The second submodule is used to invoke the preset retrieval method;
[0164] The second acquisition submodule is used to acquire a class object corresponding to the target class name from the specified module based on the acquisition method.
[0165] A submodule is defined to use the class object as the target class.
[0166] In this embodiment, the operations performed by the above modules or units correspond one-to-one with the steps of the data execution method in the aforementioned embodiments, and will not be repeated here.
[0167] In some optional implementations of this embodiment, the execution module 307 includes:
[0168] The verification submodule is used to perform signature verification on the target method based on a preset signature verification strategy.
[0169] The third calling submodule is used to call the preset target acquisition method if the target method passes the signature verification.
[0170] The third acquisition submodule is used to acquire the method name of the target method;
[0171] An execution submodule is used to execute the target method based on the method name and the target acquisition method.
[0172] In this embodiment, the operations performed by the above modules or units correspond one-to-one with the steps of the data execution method in the aforementioned embodiments, and will not be repeated here.
[0173] In some optional implementations of this embodiment, the data execution device further includes:
[0174] The fourth acquisition module is used to acquire preset exception handling strategies;
[0175] The capture module is used to capture exceptions in the execution process of the target method based on the exception handling strategy, and obtain the corresponding exception capture results.
[0176] The second judgment module is used to determine whether the anomaly capture result indicates the existence of an anomaly.
[0177] The processing module is used to record any exceptions generated during the execution process and display corresponding prompts based on the exception information.
[0178] The recording module is used to record the abnormal information into a pre-created log.
[0179] In this embodiment, the operations performed by the above modules or units correspond one-to-one with the steps of the data execution method in the aforementioned embodiments, and will not be repeated here.
[0180] In some optional implementations of this embodiment, the data execution device further includes:
[0181] The fifth acquisition module is used to acquire the execution result of the target method after completing the execution processing of the target method;
[0182] The calling module is used to invoke the preset log library;
[0183] An integration module is used to integrate the execution result of the target method, the target class name, and the target method to obtain the target log content corresponding to the class name information.
[0184] The third storage module is used to store the target log content into the log library.
[0185] In this embodiment, the operations performed by the above modules or units correspond one-to-one with the steps of the data execution method in the aforementioned embodiments, and will not be repeated here.
[0186] To address the aforementioned technical problems, embodiments of this application also provide a computer device. Please refer to [link / reference needed]. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.
[0187] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected via a system bus. It should be noted that only the computer device 4 with components 41-43 is shown in the figure; however, it should be understood that it is not required to implement all the shown components, and more or fewer components can be implemented alternatively. Those skilled in the art will understand that the computer device described here is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.
[0188] The computer device can be a desktop computer, laptop, handheld computer, or cloud server, etc. The computer device can interact with the user via a keyboard, mouse, remote control, touchpad, or voice control.
[0189] The memory 41 includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 41 may be an internal storage unit of the computer device 4, such as the hard disk or memory of the computer device 4. In other embodiments, the memory 41 may also be an external storage device of the computer device 4, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the computer device 4. Of course, the memory 41 may include both the internal storage unit and its external storage device of the computer device 4. In this embodiment, the memory 41 is typically used to store the operating system and various application software installed on the computer device 4, such as computer-readable instructions for data execution methods. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or will be output.
[0190] In some embodiments, the processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 42 is typically used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to execute computer-readable instructions stored in the memory 41 or to process data, for example, to execute computer-readable instructions of the data execution method.
[0191] The network interface 43 may include a wireless network interface or a wired network interface, which is typically used to establish communication connections between the computer device 4 and other electronic devices.
[0192] Compared with the prior art, the embodiments of this application have the following beneficial effects:
[0193] In this embodiment, a user-triggered data execution request is first received, wherein the data execution request carries class name information. Then, a configuration file is read based on a preset main module, wherein the configuration file stores a pre-configured list of class names. Next, the class name information is parsed from the data execution request, and it is determined whether a target class name matching the class name information exists in the class name list in the configuration file. If so, the target class name undergoes validity verification. If the target class name passes the validity verification, the target class corresponding to the target class name is obtained based on a preset acquisition method. Subsequently, all methods defined under the target class are filtered to obtain target methods that conform to preset naming rules. Finally, the target methods are executed. Upon receiving a user-triggered data execution request, this application reads the configuration file using the main module, parses the class name information from the data execution request, and checks if a target class name matching the class name information exists in the class name list in the configuration file. If it does, the target class name undergoes validity verification. If the target class name passes the validity verification, the target class corresponding to the target class name is retrieved based on the retrieval method. Subsequently, all methods defined under the target class are filtered to obtain target methods that conform to preset naming rules. Finally, the target methods are executed. Based on the above data execution process, this application pre-configures the class name list in the configuration file, then uses the main module to read the class name list in the configuration file and determine the target class matching the user-input class name information. It then accesses the target class matching the target class based on the retrieval method, thus dynamically filtering out target methods that conform to the naming rules from all methods defined under the target class for direct execution. This ensures that during the execution of the target method corresponding to the target class, the method name and execution are determined at runtime, eliminating the need for hard coding and requiring no additional modification to the main module code. This effectively improves the execution efficiency and flexibility of the target method.
[0194] This application also provides another embodiment, namely, providing a computer-readable storage medium storing computer-readable instructions that can be executed by at least one processor to cause the at least one processor to perform the steps of the data execution method described above.
[0195] Compared with the prior art, the embodiments of this application have the following main advantages:
[0196] In this embodiment, a user-triggered data execution request is first received, wherein the data execution request carries class name information. Then, a configuration file is read based on a preset main module, wherein the configuration file stores a pre-configured list of class names. Next, the class name information is parsed from the data execution request, and it is determined whether a target class name matching the class name information exists in the class name list in the configuration file. If so, the target class name undergoes validity verification. If the target class name passes the validity verification, the target class corresponding to the target class name is obtained based on a preset acquisition method. Subsequently, all methods defined under the target class are filtered to obtain target methods that conform to preset naming rules. Finally, the target methods are executed. Upon receiving a user-triggered data execution request, this application reads the configuration file using the main module, parses the class name information from the data execution request, and checks if a target class name matching the class name information exists in the class name list in the configuration file. If it does, the target class name undergoes validity verification. If the target class name passes the validity verification, the target class corresponding to the target class name is retrieved based on the retrieval method. Subsequently, all methods defined under the target class are filtered to obtain target methods that conform to preset naming rules. Finally, the target methods are executed. Based on the above data execution process, this application pre-configures the class name list in the configuration file, then uses the main module to read the class name list in the configuration file and determine the target class matching the user-input class name information. It then accesses the target class matching the target class based on the retrieval method, thus dynamically filtering out target methods that conform to the naming rules from all methods defined under the target class for direct execution. This ensures that during the execution of the target method corresponding to the target class, the method name and execution are determined at runtime, eliminating the need for hard coding and requiring no additional modification to the main module code. This effectively improves the execution efficiency and flexibility of the target method.
[0197] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0198] Obviously, the embodiments described above are only some embodiments of this application, not all embodiments. The accompanying drawings show preferred embodiments of this application, but do not limit the patent scope of this application. This application can be implemented in many different forms; rather, the purpose of providing these embodiments is to provide a more thorough and comprehensive understanding of the disclosure of this application. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing specific embodiments, or make equivalent substitutions for some of the technical features. Any equivalent structures made using the content of this application's specification and drawings, directly or indirectly applied to other related technical fields, are similarly within the scope of patent protection of this application.
Claims
1. A data execution method, characterized in that, Includes the following steps: Receive a data execution request triggered by a user; wherein the data execution request carries class name information; The main module reads the configuration file based on a preset configuration; wherein, the configuration file stores a pre-configured list of class names; The class name information is parsed from the data execution request, and it is determined whether there is a target class name that matches the class name information in the class name list in the configuration file; If so, perform a validity check on the target class name; If the target class name passes the validity verification, the target class corresponding to the target class name is obtained based on the preset acquisition method; All methods defined under the target class are filtered to obtain target methods that conform to preset naming rules; The target method is then executed.
2. The data execution method according to claim 1, characterized in that, Before the step of reading the configuration file based on the preset main module, the following is also included: Get the predefined parent class, and get the subclass that meets the preset loading requirements corresponding to the parent class; Obtain the subclass name of the subclass, and generate a corresponding list of class names based on the subclass name; Get the preset initial file; The list of class names is stored in the initial file to obtain the configuration file; The configuration file is stored based on a preset storage method.
3. The data execution method according to claim 1, characterized in that, The step of validating the target class name specifically includes: Retrieve the preset class name whitelist; Determine whether the target class name exists in the class name whitelist; If the target class name exists in the class name whitelist, then the target class name is determined to have passed the validity verification. If the target class name does not exist in the class name whitelist, then the target class name is determined to have failed the validity verification.
4. The data execution method according to claim 1, characterized in that, The step of obtaining the target class corresponding to the target class name based on a preset acquisition method specifically includes: Call the preset import method; Based on the import method, import the specified module corresponding to the target class name; Call the preset retrieval method; Based on the acquisition method, a class object corresponding to the target class name is obtained from the specified module; The class object is used as the target class.
5. The data execution method according to claim 1, characterized in that, The steps for executing the target method specifically include: The target method is verified based on a preset signature verification strategy. If the target method passes signature verification, then the preset target acquisition method is invoked; Obtain the method name of the target method; Based on the method name, the target method is executed through the target acquisition method.
6. The data execution method according to claim 1, characterized in that, Following the step of performing the processing on the target method, the method further includes: Obtain the preset exception handling strategy; Based on the aforementioned exception handling strategy, exceptions are captured during the execution of the target method, and corresponding exception capture results are obtained. Determine whether the anomaly capture result indicates the presence of an anomaly; If so, record the exception information generated during the execution process, and display the corresponding prompt information based on the exception information; The abnormal information is recorded in a pre-created log.
7. The data execution method according to claim 1, characterized in that, Following the step of performing the processing on the target method, the method further includes: After completing the execution processing of the target method, the execution result of the target method is obtained; Call the default logging library; The execution result of the target method, the target class name, and the target method are integrated to obtain the target log content corresponding to the class name information; The target log content is stored in the log library.
8. A data execution device, characterized in that, include: A receiving module is used to receive data execution requests triggered by users; wherein the data execution request carries class name information; A reading module is used to read a configuration file based on a preset main module; wherein, the configuration file stores a pre-configured list of class names; The first judgment module is used to parse the class name information from the data execution request and determine whether there is a target class name that matches the class name information in the class name list in the configuration file; The verification module is used to verify the legality of the target class name if the condition is met. The first acquisition module is used to acquire the target class corresponding to the target class name based on a preset acquisition method if the target class name passes the validity verification. The filtering module is used to filter all methods defined under the target class to obtain target methods that conform to preset naming rules; The execution module is used to perform execution processing on the target method.
9. A computer device, characterized in that, The device includes a memory and a processor, wherein the memory stores computer-readable instructions, and the processor executes the computer-readable instructions to implement the steps of the data execution method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the data execution method as described in any one of claims 1 to 7.