CN111552505B - Data export method and device - Google Patents

Data export method and device Download PDF

Info

Publication number
CN111552505B
CN111552505B CN201910111470.8A CN201910111470A CN111552505B CN 111552505 B CN111552505 B CN 111552505B CN 201910111470 A CN201910111470 A CN 201910111470A CN 111552505 B CN111552505 B CN 111552505B
Authority
CN
China
Prior art keywords
entity
class
user role
user
creating
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.)
Active
Application number
CN201910111470.8A
Other languages
Chinese (zh)
Other versions
CN111552505A (en
Inventor
许锋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Gree Electric Appliances Inc of Zhuhai
Original Assignee
Gree Electric Appliances Inc of Zhuhai
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Gree Electric Appliances Inc of Zhuhai filed Critical Gree Electric Appliances Inc of Zhuhai
Priority to CN201910111470.8A priority Critical patent/CN111552505B/en
Publication of CN111552505A publication Critical patent/CN111552505A/en
Application granted granted Critical
Publication of CN111552505B publication Critical patent/CN111552505B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention discloses a data export method and a data export device. Wherein, the method comprises the following steps: obtaining derived content according to the user role; packaging the exported content to obtain an entity; and converting the entity into a data format to be exported to obtain a table. The invention solves the technical problem of large service code demand caused by the fact that the creation of each role requires the service code to create an API interface.

Description

Data export method and device
Technical Field
The invention relates to the field of electronic technology application, in particular to a data export method and a data export device.
Background
Most of the existing web projects are divided into multiple user roles, the contents of the derived reports of different roles are different, and even the structures of the derived reports are different. The prior method comprises the following steps: each role creates an API interface to interact with the front-end.
Aiming at the problem that the requirement of service codes is large because each role needs to be created to create an API (application program interface), an effective solution is not provided at present.
Disclosure of Invention
The embodiment of the invention provides a data export method and a data export device, which at least solve the technical problem of large service code demand caused by the fact that each role needs to be created to create an API (application program interface).
According to an aspect of an embodiment of the present invention, there is provided a data export method, including: obtaining derived content according to the user role; packaging the exported content to obtain an entity; and converting the entity into a data format to be exported to obtain a table.
Optionally, the obtaining of the derived content according to the user role includes: creating an implementation class of a universal interface according to the user role, wherein the implementation class is used for storing all fields of the table; derived content is obtained according to the implementation class.
Further, optionally, creating the implementation class of the generic interface according to the user role includes: acquiring action behaviors of each user role; acquiring the public behavior of the user role according to the action behavior; storing the common behavior in a universal interface; and creating a class of the universal interface according to the user role, and determining the class as a realization class.
Optionally, converting the entity into a data format to be exported, and obtaining the table includes: acquiring Chinese description in an entity through self-defined annotation; and generating a table according to the Chinese description.
Further, optionally, obtaining the chinese description in the entity through the custom annotation includes: acquiring each field and value in the entity according to a pre-stored mapping relation; and generating a table from each field and number in the entity in a preset mode.
Optionally, the method further includes: determining a form control module for an API interface for interacting with a front end; the interface method of the table port is displayed.
Further, optionally, the method further includes: when the form port is called, the input parameters are obtained, wherein whether the user logs in is checked, whether the user has the authority access is checked under the condition that the user logs in, and after the user information is checked to pass, the user information is input into an interface method, and the form information is returned to the form port
Optionally, the method further includes: and determining a factory class, wherein the factory class is used for creating the behavior instance according to the user role of the login user.
According to another aspect of the embodiments of the present invention, there is also provided a data exporting apparatus, including: the acquisition module is used for acquiring the export content according to the user role; the encapsulation module is used for encapsulating the exported content to obtain an entity; and the export module is used for converting the entity into a data format to be exported to obtain a table.
Optionally, the obtaining module includes: the system comprises a creating unit, a generating unit and a processing unit, wherein the creating unit is used for creating an implementation class of a universal interface according to a user role, and the implementation class is used for storing all fields of a table; an obtaining unit configured to obtain the derived content according to the implementation class.
Further, optionally, the creating unit includes: the first creating subunit is used for acquiring the action behavior of each user role; the obtaining subunit is used for obtaining the public behavior of the user role according to the action behavior; the storage subunit is used for storing the public behaviors into the universal interface; and the second creating subunit is used for creating the class of the universal interface according to the user role and determining the class as the implementation class.
In the embodiment of the invention, the export content is acquired according to the user role by defining a universal interface of the role; packaging the exported content to obtain an entity; the entity is converted into a data format to be exported to obtain a table, so that an interface can dynamically adapt to service logic according to different user roles, and the purpose of front-end and back-end decoupling is achieved, the technical effect of reducing the service code demand is achieved, and the technical problem of large service code demand caused by the fact that each role needs to be created by a service code to create an API interface is solved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
FIG. 1 is a flow chart diagram of a data export method according to an embodiment of the invention;
FIG. 2 is a schematic flow chart diagram of another data export method according to an embodiment of the invention;
fig. 3 is a schematic diagram of a data deriving apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example 1
In accordance with an embodiment of the present invention, there is provided a data export method embodiment, it is noted that the steps illustrated in the flowchart of the figure may be performed in a computer system such as a set of computer executable instructions, and that while a logical order is illustrated in the flowchart, in some cases the steps illustrated or described may be performed in an order different than here.
Fig. 1 is a schematic flow chart of a data export method according to an embodiment of the present invention, as shown in fig. 1, the method includes the following steps:
step S102, obtaining derived content according to user roles;
specifically, the data export method provided by the embodiment of the present application may be applied to an application scenario of a dining room self-service food ordering system — multidimensional report settlement, where the user role may at least include: a general office manager, a canteen manager, a workshop manager, a department manager, and general staff.
Because the roles of the users are different, the contents of the reports derived by different roles are different, even the structures of the derived reports are different, and in the embodiment of the application, a general interface is arranged and contains action behaviors owned by all the roles of the users.
Step S104, packaging the exported content to obtain an entity;
specifically, the result is inquired from the database according to the user role with the corresponding authority, and the result is packaged into the self-defined entity ExcelEntity.
And step S106, converting the entity into a data format to be exported to obtain a table.
Specifically, the spring aop self-defined annotation is used for obtaining the Chinese description of the ExcelEntity field, and the Chinese description is used as the column header of the report. The method comprises the steps of generating an excel file by using POI, and acquiring each field and numerical value of excelEntiy by using reflection.
In the embodiment of the invention, the export content is acquired according to the user role by defining a universal interface of the role; packaging the exported content to obtain an entity; the entity is converted into a data format to be exported to obtain a table, so that an interface can dynamically adapt to service logic according to different user roles, and the purpose of front-end and back-end decoupling is achieved, the technical effect of reducing the service code demand is achieved, and the technical problem of large service code demand caused by the fact that each role needs to be created by a service code to create an API interface is solved.
Optionally, the step S102 of obtaining the derived content according to the user role includes:
step S1021, creating an implementation class of the universal interface according to the user role, wherein the implementation class is used for storing all fields of the table;
in step S1022, the export content is obtained according to the implementation class.
Specifically, a class for implementing common interface is defined for each role, for example, the class CanteenImpl for implementing the canteen administrator, and then the method for defining the interface is completed according to the actual service logic.
Further, optionally, the creating of the implementation class of the generic interface according to the user role in step S1021 includes:
step1, acquiring the action behaviors of each user role;
step2, acquiring the public behavior of the user role according to the action behavior;
step3, storing the public behavior into a universal interface;
step4, creating the class of the universal interface according to the user role, and determining the class as the implementation class.
Specifically, the action behaviors of the participants are analyzed, the public behavior of the user role is obtained, and then the public behavior is put into a common interface. For example: and exporting the report.
Optionally, in step S106, converting the entity into a data format to be exported, and obtaining the table includes: acquiring Chinese description in an entity through self-defined annotation; and generating a table according to the Chinese description.
Further, optionally, obtaining the chinese description in the entity through the custom annotation includes: acquiring each field and value in the entity according to a pre-stored mapping relation; and generating a table from each field and number in the entity in a preset mode.
Specifically, the result is inquired from the database according to the authority role and is packaged into a self-defined entity ExcelEntity, and then the spring aop self-defined annotation is utilized to obtain the Chinese description of the ExcelEntity field, which is used as the column header of the report. And generating an excel file by using the POI, and acquiring each field and value of excelEntiy by using reflection.
Optionally, the data export method provided in the embodiment of the present application further includes: determining a form control module for an API interface for interacting with a front end; the interface method of the table port is displayed.
Specifically, an API interface excelController for interacting with the front end is defined, and an interface method exportExcel is declared.
Further, optionally, the data export method provided in the embodiment of the present application further includes: when the form port is called, the input parameters are obtained, wherein whether the user logs in is checked, whether the user has the authority access is checked under the condition that the user logs in, and after the user information is checked to pass, the user information is input into the interface method, and the form is returned.
Specifically, the front end calls the interface export excel, only necessary parameters are needed to be transmitted, and user information does not need to be transmitted. The background can firstly verify whether the user logs in, and if the user does not log in, the background can jump to a login page; and then, whether the URL is authorized to be accessed is checked, and after the check is passed, the user information is automatically transmitted into the method, and the result is returned.
Optionally, the data export method provided in the embodiment of the present application further includes: and determining a factory class, wherein the factory class is used for creating the behavior instance according to the user role of the login user.
Specifically, in order to mask the specific process in the process of creating an object instance, so as to improve the flexibility of creating an instance, and to make the user not need to care about the details and complicated process of constructing an object, a factory class common factory needs to be defined, and the main responsibility of the factory class common factory is to create an appropriate behavior instance according to the identity role of a login user.
In addition, it should be noted that if the demand changes, a new role needs to be added: the distributor only needs to add a common interface implementation class, the front-end code has no change, and the background does not need to change the existing code. Thereby reducing the traffic code requirements.
In summary, fig. 2 is a schematic flow chart of another data exporting method according to an embodiment of the present invention, and as shown in fig. 2, the data exporting method provided in the embodiment of the present application is as follows:
s1, calling an interface;
for example, user information is queried.
S2, if it is logged in, executing step S3, if not, executing step S4;
s3, judging the role of the user;
s4, jumping to login, and returning to S1;
s5, inquiring from the database, obtaining the content needed to be exported corresponding to the user role, and packaging to the entity;
s6, converting the spring aop entity field into Chinese description;
and S7, calling the user role implementation class and exporting the form.
The front end in the data export method provided by the embodiment of the application does not need to pay attention to the role and the service logic of the user; the original code is not required to be changed for the subsequent new user role, and only the implementation class is required to be added; dynamically acquiring Chinese description of an entity field; therefore, the polymorphism of the interfaces is realized, namely, one interface can dynamically adapt to the service logic according to different user roles, and the front-end and back-end decoupling is realized.
Example 2
According to another aspect of the embodiments of the present invention, there is also provided a data deriving device, and fig. 3 is a schematic diagram of a data deriving device according to an embodiment of the present invention, as shown in fig. 3, including: an obtaining module 32, configured to obtain the derived content according to the user role; the encapsulation module 34 is configured to encapsulate the derived content to obtain an entity; and the export module 36 is configured to convert the entity into a data format to be exported, so as to obtain a table.
Optionally, the obtaining module 32 includes: the system comprises a creating unit, a generating unit and a processing unit, wherein the creating unit is used for creating an implementation class of a universal interface according to a user role, and the implementation class is used for storing all fields of a table; an obtaining unit configured to obtain the derived content according to the implementation class.
Further, optionally, the creating unit includes: the first creating subunit is used for acquiring the action behavior of each user role; the obtaining subunit is used for obtaining the public behavior of the user role according to the action behavior; the storage subunit is used for storing the public behaviors into the universal interface; and the second creating subunit is used for creating the class of the universal interface according to the user role and determining the class as the implementation class.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units may be a logical division, and in actual implementation, there may be another division, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (7)

1. A method of data derivation, comprising:
obtaining derived content according to the user role;
packaging the export content to obtain an entity;
converting the entity into a data format to be exported to obtain a table;
obtaining the derived content according to the user role comprises: creating an implementation class of a universal interface according to the user role, wherein the implementation class is used for storing all fields of the table; acquiring the export content according to the implementation class;
creating the implementation class of the universal interface according to the user role comprises the following steps: acquiring action behaviors of each user role; acquiring the public behavior of the user role according to the action behavior; storing the common behavior in the generic interface; and creating the class of the universal interface according to the user role, and determining the class as the implementation class.
2. The data export method of claim 1, wherein converting the entity into a data format to be exported results in a table comprising:
obtaining Chinese description in the entity through self-defined annotation;
and generating the table according to the Chinese description.
3. The data derivation method of claim 2, wherein obtaining chinese descriptions in the entity through custom annotations comprises:
acquiring each field and value in the entity according to a pre-stored mapping relation;
and generating the table by each field and number in the entity in a preset mode.
4. The data derivation method of claim 1, further comprising:
determining a form control module for an API interface for interacting with a front end;
the interface method of the table port is displayed.
5. The data derivation method of claim 4, further comprising:
and when the form port is called, acquiring input parameters, wherein whether a user logs in is checked, whether the user has authority access is checked under the condition that the user logs in, and after the user information is checked to pass, the user information is input into the interface method and returned to the form.
6. The data derivation method of claim 1, further comprising:
and determining a factory class, wherein the factory class is used for creating a behavior instance according to the user role of the login user.
7. A data derivation apparatus, comprising:
the acquisition module is used for acquiring the export content according to the user role;
the encapsulation module is used for encapsulating the export content to obtain an entity;
the export module is used for converting the entity into a data format to be exported to obtain a table;
the acquisition module comprises: the creating unit is used for creating an implementation class of a universal interface according to the user role, wherein the implementation class is used for storing all fields of the table; an obtaining unit, configured to obtain the export content according to the implementation class;
the creating unit includes: the first creating subunit is used for acquiring the action behavior of each user role; the obtaining subunit is used for obtaining the public behavior of the user role according to the action behavior; a storage subunit, configured to store the common behavior in the universal interface; and the second creating subunit is used for creating the class of the universal interface according to the user role and determining the class as the implementation class.
CN201910111470.8A 2019-02-12 2019-02-12 Data export method and device Active CN111552505B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910111470.8A CN111552505B (en) 2019-02-12 2019-02-12 Data export method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910111470.8A CN111552505B (en) 2019-02-12 2019-02-12 Data export method and device

Publications (2)

Publication Number Publication Date
CN111552505A CN111552505A (en) 2020-08-18
CN111552505B true CN111552505B (en) 2021-07-23

Family

ID=72002857

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910111470.8A Active CN111552505B (en) 2019-02-12 2019-02-12 Data export method and device

Country Status (1)

Country Link
CN (1) CN111552505B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CA2506222A1 (en) * 2004-05-07 2005-11-07 Fwo Newcorp, Inc. System and method for integrating disparate data sources
CN105589840A (en) * 2015-12-15 2016-05-18 重庆腾帆科技有限公司 Universal EXCEL/PDF report form exporting assembly
CN108628890A (en) * 2017-03-21 2018-10-09 北京京东尚科信息技术有限公司 A kind of data export method and system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CA2506222A1 (en) * 2004-05-07 2005-11-07 Fwo Newcorp, Inc. System and method for integrating disparate data sources
CN105589840A (en) * 2015-12-15 2016-05-18 重庆腾帆科技有限公司 Universal EXCEL/PDF report form exporting assembly
CN108628890A (en) * 2017-03-21 2018-10-09 北京京东尚科信息技术有限公司 A kind of data export method and system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
Spring+SpringMVc+Mybatis实现数据库查询;丶小颜;《CSDN博客 https://blog.csdn.net/Steriles_/article/details/81358553》;20180802;全文 *

Also Published As

Publication number Publication date
CN111552505A (en) 2020-08-18

Similar Documents

Publication Publication Date Title
CN107798038B (en) Data response method and data response equipment
CN110601880B (en) Cloud platform, service processing method, command interface and computer equipment
CN105913316B (en) Rule configuration method and device
CN109670081B (en) Method and device for processing service request
CN110597511B (en) Page automatic generation method, system, terminal equipment and storage medium
CN109639723A (en) A kind of micro services access method and server based on ERP system
CN109871289A (en) A kind of remote procedure call service creation method and device
CN107870989A (en) webpage generating method and terminal device
CN105389184B (en) The configuration method and device of Product Interface information
CN114064690A (en) Data processing method and device
CN105610819A (en) Method and apparatus for providing service for inquiring server information
CN112187933B (en) Method and system for monitoring services in multi-architecture cloud platform
CN104820604A (en) Browser applied to POS terminal
CN105471968A (en) Data exchange method, data exchange system and data platform server
CN106998314B (en) Account interaction method and device
CN106843818B (en) Business model generation method and device
CN101576922B (en) Access system and access method
CN105930713A (en) Method and terminal for generating identifying codes
CN111552505B (en) Data export method and device
CN103051480B (en) The storage means of a kind of DN and DN storage device
CN103425793A (en) Method for accessing database by means of database storage layer used in instant communication system
CN108845995B (en) Data processing method, data processing apparatus, storage medium, and electronic apparatus
CN111159226A (en) Index query method and system
CN114124766B (en) Test method and device based on simulation data
CN105550250A (en) Access log processing method and apparatus

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
GR01 Patent grant
GR01 Patent grant