CN110580144A - general query method realized by adding query operator to page control - Google Patents
general query method realized by adding query operator to page control Download PDFInfo
- Publication number
- CN110580144A CN110580144A CN201810571405.9A CN201810571405A CN110580144A CN 110580144 A CN110580144 A CN 110580144A CN 201810571405 A CN201810571405 A CN 201810571405A CN 110580144 A CN110580144 A CN 110580144A
- Authority
- CN
- China
- Prior art keywords
- query
- data
- class
- receiving
- page
- 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.)
- Withdrawn
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/20—Software design
- G06F8/24—Object-oriented
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention relates to the technical field of SSM frameworks and Bootstraptable front ends, in particular to a general query method realized by adding query operators to page controls. The method comprises the following steps: firstly, creating a query page, adding controls and buttons required by query, and adding query operators and other attributes to each control; compiling form data and URL in a form submitting event, packaging the form data and the URL into parameters, and transmitting the parameters to a background; creating a receiving parameter class and a filter class, and adding a filter set attribute and a data compiling method in the receiving parameter class; acquiring query data by receiving parameters at the background, and transmitting the query data to a data layer for processing through a series of methods; fifthly, a universal query method is realized in a data layer for analysis; and sixthly, returning the query result to the foreground in a Json format. The present invention solves the problem of writing a large number of similar query statements each time a query function is developed.
Description
Technical Field
the invention relates to the technical field of SSM frameworks and Bootstraptable front ends, in particular to a general query method realized by adding query operators to page controls.
Background
when a complex system based on an SSM framework is used for data query, each function point may involve a large amount of data query, and if each query statement needs to be spliced and judged to be queried through a data layer, errors are easy to occur, workload is large, and time is wasted; to solve these problems, it is necessary to implement a general query function that can be implemented by adding a query operator to a foreground page.
Disclosure of Invention
the technical problem to be solved by the invention is to provide a universal query method realized by adding a query operator to a page control; the problem that a large number of similar query statements need to be written every time a query function is developed is solved.
The technical scheme for solving the technical problems is as follows:
Firstly, creating a query page, adding controls and buttons required by query, and adding query operators and other attributes to each control; compiling form data and URL in a form submitting event, packaging the form data and the URL into parameters, and transmitting the parameters to a background; creating a receiving parameter class and a filter class, and adding a filter set attribute and a data compiling method in the receiving parameter class; acquiring query data by receiving parameters at the background, and transmitting the query data to a data layer for processing through a series of methods; fifthly, a universal query method is realized in a data layer for analysis; and sixthly, returning the query result to the foreground in a Json format. Thereby solving the problem that a large number of similar query statements are written for each development of a query function.
The method specifically comprises the following steps:
step one, creating a query page, adding a query form in the page, adding controls required by query and form submitting buttons in the form, and simultaneously adding query operators, names, IDs and other attributes to each control;
step two, in a form event submitted by a button, traversing controls in the form according to the acquired form ID, adding names, values and query operators in the form into a Filter array in a key-value pair mode, storing the generated array and the reassembled URL into parameters of BootStrapTable, and finally querying by using a refresh method of the BootStrapTable;
Step three, creating a QueryParams receiving parameter class and a Filter class, adding a String type field attribute in the Filter class for receiving a transmitted Name, enumerating a type OpType attribute and receiving a query operator, and receiving a String type data attribute and receiving a transmitted Value; in the QueryParams class, a Filter class is used as an attribute in a List set form and is used for receiving a plurality of Filter contents transmitted from a foreground; adding some other attributes, such as order and sort attributes used for sorting, offset and limit attributes used for paging; then creating a filterToDBconditionals method, and converting the received data into List set data which can be identified by database languages;
Step four, receiving query data of a front end by using QueryParams at a control layer of a background, firstly realizing functions of adding paging and sequencing at an implementation layer, then obtaining a whereList data set by a filters ToDBConditions method, storing some query constraint conditions into the whereList, and finally transmitting the whereList to a data layer for processing;
Step five, establishing a method the same as that of the DAO layer in a configuration file of MyBatis of the data layer, traversing the received whereList data set, and splicing key and value in the set into different query formulas according to op query operators in the set;
And step six, packaging the inquired data by using a self-defined DataGrid class, analyzing the data into Json data and returning the Json data to the foreground Bootstraptable for display, wherein the data has an integral total quantity attribute and a List set type row object attribute.
The invention has the beneficial effects that: by adding query operators to the page and realizing a universal data query method of the data layer according to the characteristics of page data, the aim that each query function of a project can be developed quickly is achieved. The problem that a large number of similar query sentences need to be written every time a query function is developed is effectively solved.
Drawings
The invention is further described below with reference to the accompanying drawings:
FIG. 1 is a flow chart of the present invention.
Detailed Description
As shown in fig. 1, the present invention employs the following steps:
step one, creating a query page, adding a query form in the page, adding controls required by query and form submitting buttons in the form, and simultaneously adding query operators, names, IDs and other attributes to each control; such as:
<form action="" id="searchForm" >
<div class="form-group clearfix ">
< span class = "eName" > < label > start date: < label >
<input id="start" name="createDate"
data-op="GE" type="text" />
</span>
< span class = "eName" > < label > end date: < label >
<input id="start" name="createDate"
data-op="LE" type="text" />
</span>
< span class = "eName > < label > serial No.: < label >
< input id = "split no" name = "split no" data-op = "LK" type = "text" placeholder = "pipeline number" >)
</span>
<span class="eName>
< a href = "###" id = "btnSearch" class = "button bPrimary" > query </a >
</span>
</div>
</form>
Step two, in a form event submitted by a button, traversing controls in the form according to the acquired form ID, adding names, values and query operators in the form into a Filter array in a key-value pair mode, storing the generated array and the reassembled URL into parameters of BootStrapTable, and finally querying by using a refresh method of the BootStrapTable; such as:
//1) click button search
$("#btnSearch").click(function () {
tableSearch ("#table", "#searchForm");
});
//2) foreground search method implementation
function tableSearch(tableId, searchFormId, url) {
var params = $(tableId).bootstrapTable('getOptions');
if (url) {
params.url = url;
}
params.url = setUrlParam(params.url, "t", new Date().getTime());
params.queryParams = function (params) {
params.filters = getFiltersByForm(searchFormId);
return params;
}
// search Using the refresh method
$(tableId).bootstrapTable('refresh', params)
}
//3) parameter query encapsulation
function getFiltersByForm(searchFormId) {
var filters = new Array();
var j = 0;
$.each($("form" + searchFormId + " input,form" + searchFormId + " select,form" + searchFormId + " checked"), function (i, n) {
var field = $(n);
op = field.attr("data-op");
if (op) {
if (field[0].nodeName == "SELECT") {
……
} else {
if (field.val()) {
filters[j] = {field: field.attr("name"), data: field.val(), op: op};
j++;
}
}
}
});
return filters;
}
Step three, creating a QueryParams receiving parameter class and a Filter class, adding a String type field attribute in the Filter class for receiving a transmitted Name, enumerating a type OpType attribute and receiving a query operator, and receiving a String type data attribute and receiving a transmitted Value; in the QueryParams class, a Filter class is used as an attribute in a List set form and is used for receiving a plurality of Filter contents transmitted from a foreground; adding some other attributes, such as order and sort attributes used for sorting, offset and limit attributes used for paging; then creating a filterToDBconditionals method, and converting the received data into List set data which can be identified by database languages; such as:
//1) Filter class
public class Filter implements Serializable {
private String field;
private OpType op;
private String data;
……
}
//2) creating QueryParams receive parameter classes
public class QueryParams implements Serializable {
private String sort;
private String order;
private int offset;
private int limit = 10;
private Integer current;
private List<Filter> filters;
……
Method for preparing// filters ToDBConditionions
public List<Condition> filtersToDBConditionals() {
if (this.filters == null) {
return new ArrayList();
} else {
List<Condition> list = new ArrayList();
Iterator it = this.filters.iterator();while(it.hasNext()) {
Filter item = (Filter) it.next();
Condition model = new Condition();
model.setKey(item.getField());
model.setOp(item.getOp());
model.setOpStr(Condition.getSign(item.getOp()));
model.setValue(item.getOp() == OpType.LK "%" + item.getData() + "%" : item.getData());
list.add(model);
}
return list;
}
}
}
step four, receiving query data of a front end by using QueryParams at a control layer of a background, firstly realizing functions of adding paging and sequencing at an implementation layer, then obtaining a whereList data set by a filters ToDBConditions method, storing some query constraint conditions into the whereList, and finally transmitting the whereList to a data layer for processing;
//1) control layer reception
@RequestMapping("/listPaySummarysByPage.action")
public @ResponseBody DataGrid listByPage(@RequestBody QueryParams queryParams) {
return payService.listByPage (queryParams);
}
//2) implementing layer processing
public DataGrid listByPage(QueryParams queryParams) {
// Add paging function
PageHelper.offsetPage(queryParams.getOffset(), queryParams.getLimit());
if(StringUtil.isNotEmpty(queryParams.getSort()) && StringUtil.isNotEmpty(queryParams.getOrder())){
PageHelper.orderBy(queryParams.getSort() + " " + queryParams.getOrder());
}
v/conversion to query terms
List<Condition> whereList = queryParams.filtersToDBConditionals();
whereList.add(Condition.create("IFNULL(deleteFlag,'')", -1 , Condition.OpType.NE));
map.put("whereList", whereList);
List list = payDAO.listByPage (map);
PageInfo pageInfo = new PageInfo(list);
return new DataGrid(pageInfo.getTotal(), pageInfo.getList());
}
step five, establishing a method the same as that of the DAO layer in a configuration file of MyBatis of the data layer, traversing the received whereList data set, and splicing key and value in the set into different query formulas according to op query operators in the set; such as:
// DAO layer method
List listByPage(Map<String, Object> map);
// configuration file general inquiry method
<select id="listByPage" resultMap="BaseResultMap">
select * from productOrder where 1=1
<if test="whereList != null">
<foreach collection="whereList" item="item">
<choose>
<when test="item.opStr == 'in' ">
and ${item.key} in
……
</when>
……
</choose>
</foreach>
</if>
</select>
And step six, packaging the inquired data by using a self-defined DataGrid class, analyzing the data into Json data and returning the Json data to the foreground Bootstraptable for display, wherein the data has an integral total quantity attribute and a List set type row object attribute. Such as:
// DataGrid class
public class DataGrid implements Serializable {
private long total;
private List rows = new ArrayList();
public DataGrid() {
}
public DataGrid(long total, List rows) {
this.total = total;
this.rows = rows;
}
}。
Claims (2)
1. A universal query method realized by adding query operators to page controls is characterized in that: firstly, creating a query page, adding controls and buttons required by query, and adding query operators and other attributes to each control; compiling form data and URL in a form submitting event, packaging the form data and the URL into parameters, and transmitting the parameters to a background; creating a receiving parameter class and a filter class, and adding a filter set attribute and a data compiling method in the receiving parameter class; acquiring query data by receiving parameters at the background, and transmitting the query data to a data layer for processing through a series of methods; fifthly, a universal query method is realized in a data layer for analysis; sixthly, returning the query result to the foreground in a Json format; thereby solving the problem that a large number of similar query statements are written for each development of a query function.
2. The SSM framework and Bootstraptable front-end technology-based universal query method implemented by adding query operators to page controls according to claim 1, characterized in that: adding query operators to a front-end page, and realizing a universal query method in a data layer; the method specifically comprises the following steps:
Step one, creating a query page, adding a query form in the page, adding controls required by query and form submitting buttons in the form, and simultaneously adding query operators, names, IDs and other attributes to each control;
step two, in a form event submitted by a button, traversing controls in the form according to the acquired form ID, adding names, values and query operators in the form into a Filter array in a key-value pair mode, storing the generated array and the reassembled URL into parameters of BootStrapTable, and finally querying by using a refresh method of the BootStrapTable;
Step three, creating a QueryParams receiving parameter class and a Filter class, adding a String type field attribute in the Filter class for receiving a transmitted Name, enumerating a type OpType attribute and receiving a query operator, and receiving a String type data attribute and receiving a transmitted Value; in the QueryParams class, a Filter class is used as an attribute in a List set form and is used for receiving a plurality of Filter contents transmitted from a foreground; adding some other attributes, such as order and sort attributes used for sorting, offset and limit attributes used for paging; then creating a filterToDBconditionals method, and converting the received data into List set data which can be identified by database languages;
Step four, receiving query data of a front end by using QueryParams at a control layer of a background, firstly realizing functions of adding paging and sequencing at an implementation layer, then obtaining a whereList data set by a filters ToDBConditions method, storing some query constraint conditions into the whereList, and finally transmitting the whereList to a data layer for processing;
Step five, establishing a method the same as that of the DAO layer in a configuration file of MyBatis of the data layer, traversing the received whereList data set, and splicing key and value in the set into different query formulas according to op query operators in the set;
And step six, packaging the inquired data by using a self-defined DataGrid class, analyzing the data into Json data and returning the Json data to the foreground Bootstraptable for display, wherein the data has an integral total quantity attribute and a List set type row object attribute.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810571405.9A CN110580144A (en) | 2018-06-07 | 2018-06-07 | general query method realized by adding query operator to page control |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810571405.9A CN110580144A (en) | 2018-06-07 | 2018-06-07 | general query method realized by adding query operator to page control |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110580144A true CN110580144A (en) | 2019-12-17 |
Family
ID=68808969
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810571405.9A Withdrawn CN110580144A (en) | 2018-06-07 | 2018-06-07 | general query method realized by adding query operator to page control |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110580144A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111737282A (en) * | 2020-07-23 | 2020-10-02 | 福建天晴在线互动科技有限公司 | Method and system for organizing database query conditions by receiving parameters at server |
CN111737283A (en) * | 2020-07-23 | 2020-10-02 | 福建天晴在线互动科技有限公司 | Method and system for front-end automatic organization of form to perform database query |
-
2018
- 2018-06-07 CN CN201810571405.9A patent/CN110580144A/en not_active Withdrawn
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111737282A (en) * | 2020-07-23 | 2020-10-02 | 福建天晴在线互动科技有限公司 | Method and system for organizing database query conditions by receiving parameters at server |
CN111737283A (en) * | 2020-07-23 | 2020-10-02 | 福建天晴在线互动科技有限公司 | Method and system for front-end automatic organization of form to perform database query |
CN111737283B (en) * | 2020-07-23 | 2022-07-26 | 福建天晴在线互动科技有限公司 | Method and system for front-end automatic organization of form to carry out database query |
CN111737282B (en) * | 2020-07-23 | 2022-07-26 | 福建天晴在线互动科技有限公司 | Method and system for organizing database query conditions by receiving parameters at server |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108920588B (en) | Knowledge graph updating method and system for man-machine interaction | |
US11947502B2 (en) | Concurrent enumeration of multiple hierarchies in a database environment | |
CN102135938B (en) | Software product testing method and system | |
CN109918370B (en) | WEB-based development method and system for configurable form application front end | |
US20160224594A1 (en) | Schema Definition Tool | |
US8117192B1 (en) | Computerized information system for creating patent data summaries and method therefor | |
WO1998030962A2 (en) | Method for content-based dynamic formatting for interoperation of computing and edi systems | |
US10296505B2 (en) | Framework for joining datasets | |
CN112364024B (en) | Control method and device for automatic comparison of table data in batches | |
CN106062751A (en) | Managing data profiling operations related to data type | |
CN104778236A (en) | ETL (Extract-Transform-Load) realization method and system based on metadata | |
CN109902117A (en) | Operation system analysis method and device | |
CN103678550A (en) | Mass data real-time query method based on dynamic index structure | |
CN111090417A (en) | Binary file analysis method, device, equipment and medium | |
CN105975489A (en) | Metadata-based online SQL code completion method | |
CN106687955A (en) | Simplifying invocation of import procedures to transfer data from data sources to data targets | |
CN114218218A (en) | Data processing method, device and equipment based on data warehouse and storage medium | |
CN106502720A (en) | A kind of data processing method and device | |
CN109388659B (en) | Data storage method, device and computer readable storage medium | |
CN104346331A (en) | Retrieval method and system for XML database | |
CN110580144A (en) | general query method realized by adding query operator to page control | |
CN106445645A (en) | Method and device for executing distributed computation tasks | |
CN106406985B (en) | Distributed computing framework and distributed computing method | |
CN106055629A (en) | Single well information management system | |
CN109933589B (en) | Data structure conversion method for data summarization based on ElasticSearch aggregation operation result |
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 | ||
WW01 | Invention patent application withdrawn after publication | ||
WW01 | Invention patent application withdrawn after publication |
Application publication date: 20191217 |