CN114357334A - Model access method and device, storage medium and computer equipment - Google Patents
Model access method and device, storage medium and computer equipment Download PDFInfo
- Publication number
- CN114357334A CN114357334A CN202111663878.XA CN202111663878A CN114357334A CN 114357334 A CN114357334 A CN 114357334A CN 202111663878 A CN202111663878 A CN 202111663878A CN 114357334 A CN114357334 A CN 114357334A
- Authority
- CN
- China
- Prior art keywords
- model
- name
- access
- user
- models
- 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
Links
- 230000004044 response Effects 0.000 claims description 6
- 238000004590 computer program Methods 0.000 claims description 4
- 238000004891 communication Methods 0.000 description 13
- 238000000034 method Methods 0.000 description 8
- 238000010586 diagram Methods 0.000 description 6
- 230000003993 interaction Effects 0.000 description 2
- 210000003666 Nerve Fibers, Myelinated Anatomy 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 239000003365 glass fiber Substances 0.000 description 1
- 230000000977 initiatory Effects 0.000 description 1
- 230000002452 interceptive Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000006011 modification reaction Methods 0.000 description 1
- 230000003287 optical Effects 0.000 description 1
- 238000009877 rendering Methods 0.000 description 1
Images
Abstract
The embodiment of the application discloses a model access method, a model access device, a model access storage medium and computer equipment, and relates to the field of computers. The method of the present application comprises: receiving an access request through a restful interface; the access request carries a user identifier, a model name, a service capability name and a service parameter; determining a target model in a model set according to the model name; wherein a plurality of models in the set of models share the restful interface; calling the class object indicated by the service capability name in the target model by using a reflection mechanism; and returning a calling result obtained by the class object responding to the service parameter to the user indicated by the user identifier, so that the method and the device can save the time of model development and expansion links, avoid model expansion from increasing a large number of interfaces, improve the development efficiency and ensure code reuse.
Description
Technical Field
The present application relates to the field of computers, and in particular, to a model access method, apparatus, storage medium, and computer device.
Background
The method solves the problem of model access realization in a function development link of software research and development based on a model. Generally, the software function development link based on the model involves model access, and the business capability of the model is provided through a group of interfaces. If the model adds new service capability, a new interface needs to be correspondingly added, so that the problems that the interfaces of the model are dispersed and the expansion is complex exist.
Disclosure of Invention
The embodiment of the application provides a model access method, a model access device, a storage medium and computer equipment, and can solve the problem that in the prior art, operation is complex when business capability expansion is performed on a model. The technical scheme is as follows:
in a first aspect, an embodiment of the present application provides a model access method, where the method includes:
receiving an access request through a restful interface; the access request carries a user identifier, a model name, a service capability name and a service parameter;
determining a target model in a model set according to the model name; wherein a plurality of models in the set of models share the restful interface;
calling the class object indicated by the service capability name in the target model by using a reflection mechanism;
and returning the calling result of the class object obtained by responding to the service parameter to the user indicated by the user identification.
In a second aspect, an embodiment of the present application provides an apparatus for accessing a model, where the apparatus includes:
the receiving and sending unit is used for receiving the access request through a restful interface; the access request carries a user identifier, a model name, a service capability name and a service parameter;
the determining unit is used for determining a target model in a model set according to the model name; wherein a plurality of models in the set of models share the restful interface;
a reflection unit, configured to call, by using a reflection mechanism, the class object indicated by the service capability name in the target model;
and the transceiver unit is further configured to return a call result obtained by the class object in response to the service parameter to the user indicated by the user identifier.
In a third aspect, embodiments of the present application provide a computer storage medium storing a plurality of instructions adapted to be loaded by a processor and to perform the above-mentioned method steps.
In a fourth aspect, an embodiment of the present application provides a computer device, which may include: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to perform the above-mentioned method steps.
The beneficial effects brought by the technical scheme provided by some embodiments of the application at least comprise:
the model service capability is provided outwards through a uniform restful interface, when the model service capability is called, the model name, the service capability name and the service parameter are transmitted through an access request, and the model service capability is dynamically called based on a reflection mechanism, so that the model service capability is accessed. When a new model is added or a new service capability is added to the model, the number of restful interfaces of the model is only 1. Therefore, the method and the device can realize the expansion development based on the model service capacity, avoid configuring a restful interface for each new service capacity, save the time of model development and expansion links, avoid increasing a large number of interfaces by model expansion, improve the development efficiency and ensure code reuse.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a schematic diagram of a network architecture provided in an embodiment of the present application;
FIG. 2 is a flow chart of a model access method provided by an embodiment of the present application;
FIG. 3 is a schematic diagram of a set of models provided by an embodiment of the present application;
FIG. 4 is a schematic diagram of a model access device according to the present application;
fig. 5 is a schematic structural diagram of a computer device provided in the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more clear, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
It should be noted that the model access method provided in the present application is generally executed by a computer device, and accordingly, the model access device is generally disposed in the computer device.
Fig. 1 shows an exemplary system architecture of an access device that can be applied to the access method of the model or the model of the present application.
As shown in fig. 1, the system architecture may include: computer device 101 and server 102. Communication between computer device 101 and server 102 may be via a network, which is the medium used to provide the communication links between the various elements described above. The network may include various types of wired or wireless communication links, such as: the wired communication link includes an optical fiber, a twisted pair wire, or a coaxial cable, etc., and the WIreless communication link includes a bluetooth communication link, a WIreless-FIdelity (Wi-Fi) communication link, or a microwave communication link, etc.
A distributed cache is deployed in the server 102, and a model set including a plurality of models is stored in the distributed cache and is managed by a model manager. The computer device 101 can call the business capabilities of the respective models based on the restful interface provided uniformly by the set of models.
It should be noted that the computer device 101 and the server 102 may be hardware or software. When the computer device 101 and the server 102 are hardware, they may be implemented as a distributed server cluster composed of a plurality of servers, or may be implemented as a single server. When the computer device 101 and the server 102 are software, they may be implemented as a plurality of software or software modules (for example, for providing distributed services), or may be implemented as a single software or software module, and are not limited in this regard.
Various communication client applications may be installed on the computer device of the present application, for example: video recording application, video playing application, voice interaction application, search application, instant messaging tool, mailbox client, social platform software, etc.
The computer device may be hardware or software. When the computer device is hardware, it may be various computer devices having a display screen, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like. When the computer device is software, the above listed computer devices may be installed. Which may be implemented as multiple software or software modules (e.g., to provide distributed services) or as a single software or software module, and is not particularly limited herein.
When the computer equipment is hardware, the computer equipment can also be provided with display equipment and a camera, the display equipment can display various equipment capable of realizing the display function, and the camera is used for collecting video streams; for example: the display device may be a cathode ray tube (CR) display, a light-emitting diode (LED) display, an electronic ink screen, a Liquid Crystal Display (LCD), a Plasma Display Panel (PDP), or the like. The user can utilize the display device on the computer device to view the displayed information such as characters, pictures, videos and the like.
It should be understood that the number of computer devices, networks, and servers in FIG. 1 is illustrative only. Any number of computer devices, networks, and servers are possible, as desired for an implementation.
The following describes the access method of the model provided by the embodiment of the present application in detail with reference to fig. 2. The model access device in the embodiment of the present application may be a computer device shown in fig. 1.
Referring to fig. 2, a schematic flow chart of a model access method is provided in an embodiment of the present application. As shown in fig. 2, the method of the embodiment of the present application may include the steps of:
s201, receiving an access request through a restful interface.
Wherein the access request is for accessing a business capability of the model, the business capability being provided by a class object in the model. The model is an example of providing business capability to the outside, and the model provides the business capability to the outside through a uniformly set restful interface. For example: the service model is provided with user data which provides the service capability of a newly added user, the service capability of a deleted user or the service capability of a modified user, and the like, and the data structure of the model is self-defined. The access request carries a user identifier, a model name, a service capability name and a service parameter, the user identifier represents the identity of a user initiating the access request, the model name represents the name of the called target model, the service capability name represents the name of a class object included in the called target model, and the service parameter represents a field and an attribute value transmitted to the class object. The format of the access request may be a URL (Uniform Resource Locator).
For example: when a service capability of a newly added user is requested to the model, an access request is expressed as { vipAddress }/sv/model/system _ user/savetReturn, and service parameters carried by the access request are expressed as: { "username": Zhang III "," gid ": afadccdc525856522060f9b9c9362a3 b", "sex": 1 }; wherein, system _ user represents the model name, and saverturn represents the business capability name.
In one or more possible embodiments, before S201, the computer device creates a model and adds the created model to the model set, and the creating may be:
configuring attribute information of the model; wherein the attribute information includes: model name, category, entity affiliation, type ID, and type name;
configuring model project information of a model in an itemized manner based on a model configuration page, and storing the model project information into a database; the model configuration page comprises model item tables, one row of each model item table is an entry, and a user can perform interaction operation on the model configuration page to add, delete, modify or adjust the positions of the entries in the model item tables.
Configuring model capability extension information in an entry mode based on a business capability extension page, and storing the model capability extension information into the database; the service expansion capability page comprises expansion information tables, one row of each expansion information table is an entry, one entry corresponds to one service capability, and a user can execute interactive operation on the model configuration page to add, delete, modify or adjust the positions of the entries in the model item table, so that the expansion of the service capability is realized. Adding the model to a set of models to which a model manager belongs.
S202, determining a target model in the model set according to the model name.
The model set comprises a plurality of models, different models have different model names, the target model is determined in the plurality of models according to the model name obtained by analysis in the S201, and the plurality of models are all provided with uniform restful interfaces.
For example, the model set is managed by the model manager, the model set comprises a model A (model name A) and a model B (model name B), both the model A and the model B can provide business capabilities of adding user information, updating the user information, inquiring the user information and deleting the user information, the model manager receives an access request from a visitor, analyzes the access request to obtain the model name A, and determines the model A as a target model in the model set.
In one or more possible embodiments, the present application utilizes a white list mechanism to check the identity of a caller, where the checking process includes:
judging whether the user identification is located in a preset white list, if so, executing the determination of a target model in a model set according to the model name;
if not, the user indicated by the user identifier is denied access, and an access failure response can be returned to the user.
In one or more possible embodiments, the present application performs flow control on the model to improve the response speed of the model. The flow control method comprises the following steps:
monitoring the number of access requests on the target model, and if the number of the access requests is larger than a first number threshold, rejecting access of all users; or
And counting the access times within the preset time length, and if the access times are greater than a second number threshold, rejecting the user indicated by the user identifier to access.
The computer device may periodically monitor or count the number of access requests and the number of accesses, and the first number threshold and the second number threshold may be determined according to actual needs, which is not limited in this application.
And S203, calling the class object indicated by the service capability name in the target model by using a reflection mechanism.
The reflection mechanism refers to that the program can acquire self information during running. In java, as long as the name of a class object is given, all information of the class object can be obtained through a reflection mechanism, that is, the specified class object is dynamically obtained, and the content in the class object is dynamically called. The method and the device call the class object indicated by the service capability name when the class object is in the running state. For example: according to the example in S201, the determined class objects are bizentitylmodel manager and saverturn, and the fields and attribute values included in the service parameters are introduced into the class objects.
And S204, returning a calling result obtained by the class object responding to the service parameter to the user indicated by the user identifier.
The class object acquires the service parameters in the running state, obtains a calling result based on the service parameters, and then returns the calling result to the caller. Optionally, each model in the model set may be deployed in a distributed cache to improve the response speed of the model.
According to the method and the device, the service capability of the model is provided outwards through the unified restful interface, when the service capability of the model is called, the name of the model, the name of the service capability and the service parameter are transmitted through the access request, and the service capability of the model is dynamically called based on the reflection mechanism, so that the access of the service capability of the model is realized. When a new model is added or a new service capability is added to the model, the number of restful interfaces of the model is only 1. Therefore, the method and the device can realize the expansion development based on the model service capacity, avoid configuring a restful interface for each new service capacity, save the time of model development and expansion links, avoid increasing a large number of interfaces by model expansion, improve the development efficiency and ensure code reuse.
The following are embodiments of the apparatus of the present application that may be used to perform embodiments of the method of the present application. For details which are not disclosed in the embodiments of the apparatus of the present application, reference is made to the embodiments of the method of the present application.
Referring to fig. 4, a schematic structural diagram of an access device of a model provided in an exemplary embodiment of the present application is shown, which is hereinafter referred to as a device 4. The apparatus 4 may be implemented as all or part of a computer device in software, hardware or a combination of both. The device 4 comprises: a transceiver 401, a determination unit 402, and a reflection unit 403.
A transceiving unit 401, configured to receive an access request through a restful interface; the access request carries a user identifier, a model name, a service capability name and a service parameter;
a determining unit 402, configured to determine a target model in a model set according to the model name; wherein a plurality of models in the set of models share the restful interface;
a reflection unit 403, configured to invoke, in the target model, a class object indicated by the service capability name by using a reflection mechanism;
the transceiving unit 401 is further configured to return, to the user indicated by the user identifier, an invocation result obtained by the class object in response to the service parameter.
In one or more possible embodiments, the method further comprises:
the configuration unit is used for configuring attribute information of the model; wherein the attribute information includes: model name, category, entity affiliation, type ID, and type name;
configuring model project information of a model in an itemized manner based on a model configuration page, and storing the model project information into a database;
configuring model capability extension information in an entry mode based on a business capability extension page, and storing the model capability extension information into the database;
adding the model to a set of models to which a model manager belongs.
In one or more possible embodiments, the method further comprises:
the user verification unit is used for judging whether the user identification is positioned in a preset white list or not, and if so, executing the determination of the target model in the model set according to the model name;
if not, the user indicated by the user identification is denied access.
In one or more possible embodiments, the method further comprises:
the flow control unit is used for monitoring the number of the access requests on the target model, and if the number of the access requests is larger than a first number threshold, access of all users is refused; or
And counting the access times within the preset time length, and if the access times are greater than a second number threshold, rejecting the user indicated by the user identifier to access.
In one or more possible embodiments, the set of models is deployed in a distributed cache.
It should be noted that, when the apparatus 4 provided in the above embodiment executes the model access method, only the division of the above functional modules is illustrated, and in practical applications, the above function distribution may be completed by different functional modules according to needs, that is, the internal structure of the device may be divided into different functional modules to complete all or part of the above functions. In addition, the model access device and the model access method provided by the above embodiments belong to the same concept, and details of implementation processes thereof are referred to in the method embodiments and are not described herein again.
The above-mentioned serial numbers of the embodiments of the present application are merely for description and do not represent the merits of the embodiments.
An embodiment of the present application further provides a computer storage medium, where the computer storage medium may store a plurality of instructions, where the instructions are suitable for being loaded by a processor and executing the method steps in the embodiment shown in fig. 2, and a specific execution process may refer to a specific description of the embodiment shown in fig. 2, which is not described herein again.
The present application further provides a computer program product storing at least one instruction, which is loaded and executed by the processor to implement the model access method according to the above embodiments.
Referring to fig. 5, a schematic structural diagram of a computer device is provided in an embodiment of the present application. As shown in fig. 5, the computer device 500 may include: at least one processor 501, at least one network interface 504, a user interface 503, memory 505, at least one communication bus 502.
Wherein a communication bus 502 is used to enable connective communication between these components.
The user interface 503 may include a Display screen (Display) and a Camera (Camera), and the optional user interface 503 may also include a standard wired interface and a wireless interface.
The network interface 504 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface), among others.
The Memory 505 may include a Random Access Memory (RAM) or a Read-Only Memory (Read-Only Memory). Optionally, the memory 505 includes a non-transitory computer-readable medium. The memory 505 may be used to store instructions, programs, code sets, or instruction sets. The memory 505 may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the various method embodiments described above, and the like; the storage data area may store data and the like referred to in the above respective method embodiments. The memory 505 may alternatively be at least one memory device located remotely from the processor 501. As shown in fig. 5, the memory 505, which is a type of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and an application program.
In the computer device 500 shown in fig. 5, the user interface 503 is mainly used as an interface for providing input for a user, and acquiring data input by the user; the processor 501 may be configured to call the application program stored in the memory 505 and specifically execute the method shown in fig. 2, and the specific process may refer to fig. 2 and is not described herein again.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a read-only memory or a random access memory.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present application and is not to be construed as limiting the scope of the present application, so that the present application is not limited thereto, and all equivalent variations and modifications can be made to the present application.
Claims (10)
1. A method for accessing a model, comprising:
receiving an access request through a restful interface; the access request carries a user identifier, a model name, a service capability name and a service parameter;
determining a target model in a model set according to the model name; wherein a plurality of models in the set of models share the restful interface;
calling the class object indicated by the service capability name in the target model by using a reflection mechanism;
and returning the calling result of the class object obtained by responding to the service parameter to the user indicated by the user identification.
2. The method of claim 1, further comprising:
configuring attribute information of the model; wherein the attribute information includes: model name, category, entity affiliation, type ID, and type name;
configuring model project information of a model in an itemized manner based on a model configuration page, and storing the model project information into a database;
configuring model capability extension information in an entry mode based on a business capability extension page, and storing the model capability extension information into the database;
adding the model to a set of models to which a model manager belongs.
3. The method of claim 1 or 2, further comprising:
judging whether the user identification is located in a preset white list, if so, executing the determination of a target model in a model set according to the model name;
if not, the user indicated by the user identification is denied access.
4. The method of claim 3, further comprising:
monitoring the number of access requests on the target model, and if the number of the access requests is larger than a first number threshold, rejecting access of all users; or
And counting the access times within the preset time length, and if the access times are greater than a second number threshold, rejecting the user indicated by the user identifier to access.
5. The method of claim 1, 2 or 4, wherein the set of models is deployed in a distributed cache.
6. An apparatus for accessing a model, comprising:
the receiving and sending unit is used for receiving the access request through a restful interface; the access request carries a user identifier, a model name, a service capability name and a service parameter;
the determining unit is used for determining a target model in a model set according to the model name; wherein a plurality of models in the set of models share the restful interface;
a reflection unit, configured to call, by using a reflection mechanism, the class object indicated by the service capability name in the target model;
and the transceiver unit is further configured to return a call result obtained by the class object in response to the service parameter to the user indicated by the user identifier.
7. The apparatus of claim 6, further comprising:
the configuration unit is used for configuring attribute information of the model; wherein the attribute information includes: model name, category, entity affiliation, type ID, and type name;
configuring model project information of a model in an itemized manner based on a model configuration page, and storing the model project information into a database;
configuring model capability extension information in an entry mode based on a business capability extension page, and storing the model capability extension information into the database;
adding the model to a set of models to which a model manager belongs.
8. The apparatus of claim 6 or 7, further comprising:
the user verification unit is used for judging whether the user identification is positioned in a preset white list or not, and if so, executing the determination of the target model in the model set according to the model name;
if not, the user indicated by the user identification is denied access.
9. A computer storage medium, characterized in that it stores a plurality of instructions adapted to be loaded by a processor and to perform the method steps according to any of claims 1 to 5.
10. A computer device, comprising: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to perform the method steps of any of claims 1 to 5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111663878.XA CN114357334A (en) | 2021-12-31 | 2021-12-31 | Model access method and device, storage medium and computer equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111663878.XA CN114357334A (en) | 2021-12-31 | 2021-12-31 | Model access method and device, storage medium and computer equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114357334A true CN114357334A (en) | 2022-04-15 |
Family
ID=81106112
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111663878.XA Pending CN114357334A (en) | 2021-12-31 | 2021-12-31 | Model access method and device, storage medium and computer equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114357334A (en) |
-
2021
- 2021-12-31 CN CN202111663878.XA patent/CN114357334A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107451109B (en) | Report generation method and system | |
US11175796B2 (en) | Menu management method, server, and system | |
CN109068153B (en) | Video playing method and device and computer readable storage medium | |
WO2021082649A1 (en) | List update method and apparatus, readable medium, and electronic device | |
CN108363741B (en) | Big data unified interface method, device, equipment and storage medium | |
WO2021023149A1 (en) | Method and apparatus for dynamically returning message | |
CN111125107A (en) | Data processing method, device, electronic equipment and medium | |
CN113010238A (en) | Permission determination method, device and system for micro application call interface | |
CN110781373B (en) | List updating method and device, readable medium and electronic equipment | |
CN112650804B (en) | Big data access method, device, system and storage medium | |
CN114357334A (en) | Model access method and device, storage medium and computer equipment | |
CN107347024A (en) | A kind of method and apparatus for storing Operation Log | |
CN111343172A (en) | Network access authority dynamic processing method and device | |
CN109213815B (en) | Method, device, server terminal and readable medium for controlling execution times | |
CN113726855B (en) | Service aggregation method, device, electronic equipment and computer-readable storage medium | |
CN109542646A (en) | Method and apparatus for calling application programming interface | |
CN113760886B (en) | Method, apparatus, device and computer readable medium for providing data service | |
CN115268401A (en) | Calling method and device of controller method instance, storage medium and server | |
CN115757613A (en) | Method and device for managing main data, storage medium and server | |
CN116701520A (en) | Page display method, device, server and storage medium | |
CN113821519A (en) | Data processing method and field-driven design architecture | |
CN114928608A (en) | Multimedia resource processing method, device, equipment and storage medium | |
CN114969179A (en) | Adaptation method and device for Dameng database, storage medium and computer equipment | |
CN112835581A (en) | Terminal capability calling method, device, equipment and storage medium | |
CN114202046A (en) | SAP system-based method, device, equipment and medium for generating two-dimensional code |
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 |