feat(web): 增加REST统一查询参数
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
package com.eshore.gringotts.web;
|
||||
|
||||
import com.eshore.gringotts.web.domain.base.controller.query.DetailQuery;
|
||||
import com.eshore.gringotts.web.domain.base.controller.query.ListQuery;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.eclipsecollections.EclipseCollectionsModule;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-12-03
|
||||
*/
|
||||
public class TestQueryParse {
|
||||
public static void main(String[] args) throws JsonProcessingException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.registerModule(new EclipseCollectionsModule());
|
||||
mapper.registerModule(new JavaTimeModule());
|
||||
// language=JSON
|
||||
System.out.println(mapper.readValue("{}", DetailQuery.class));
|
||||
// language=JSON
|
||||
System.out.println(mapper.readValue("{\n" +
|
||||
" \"query\": {\n" +
|
||||
" \"equal\": {\n" +
|
||||
" \"name\": \"lanyuanxiaoyao\"\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"}", DetailQuery.class));
|
||||
// language=JSON
|
||||
System.out.println(mapper.readValue("{\n" +
|
||||
" \"query\": {\n" +
|
||||
" \"equal\": {\n" +
|
||||
" \"name\": \"lanyuanxiaoyao\"\n" +
|
||||
" },\n" +
|
||||
" \"notEqual\": {\n" +
|
||||
" \"username\": \"lanyuanxiaoyao@qq.com\",\n" +
|
||||
" \"password\": \"mingland87\"\n" +
|
||||
" },\n" +
|
||||
" \"great\": {\n" +
|
||||
" \"age\": 12,\n" +
|
||||
" \"createTime\": \"2020-10-12 00:00:00\"\n" +
|
||||
" },\n" +
|
||||
" \"in\": {\n" +
|
||||
" \"age\": [\n" +
|
||||
" 15,\n" +
|
||||
" 18,\n" +
|
||||
" 20\n" +
|
||||
" ]\n" +
|
||||
" },\n" +
|
||||
" \"between\": {\n" +
|
||||
" \"createTime\": {\n" +
|
||||
" \"start\": \"2024-12-03 00:00:00\",\n" +
|
||||
" \"end\": \"2024-12-03 00:00:00\"\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"sort\": [\n" +
|
||||
" {\n" +
|
||||
" \"column\": \"createTime\",\n" +
|
||||
" \"direction\": \"ASC\"\n" +
|
||||
" }\n" +
|
||||
" ],\n" +
|
||||
" \"page\": {\n" +
|
||||
" \"size\": 10,\n" +
|
||||
" \"page\": 1\n" +
|
||||
" }\n" +
|
||||
"}", ListQuery.class));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user