[Marco Hasor] Herramienta de interfaz sin código Dataway El motor de consulta de agregación DataQL utiliza Mybatis para implementar el ejemplo de consulta de paginación y el análisis de problemas (para la base de datos GreenPlum)

Este artículo ha participado en el evento "Ceremonia de creación de recién llegados" para comenzar juntos el camino de la creación de oro.

Para el uso de Hasor Framework Dataway, consulte la configuración y resolución de problemas de SpringBoot Integration Hasor [herramienta de interfaz sin código de Dataway] que compartí anteriormente . Aquí hay un registro de los problemas encontrados con DataQL.

1. Ejemplos y explicaciones

El DataQL de la interfaz es el siguiente: Preguntas y explicaciones 1: [El dialecto de la base de datos GreenPlum debe usar postgresql] El análisis y solución de errores del ejecutor del motor de consulta de agregación compartido anterior de DataQL explica por qué, puede echar un vistazo si está interesado.

// SQL 执行器切换为分页模式及首页页面设置
hint FRAGMENT_SQL_QUERY_BY_PAGE = true
hint FRAGMENT_SQL_QUERY_BY_PAGE_NUMBER_OFFSET = 1
hint FRAGMENT_SQL_PAGE_DIALECT = "postgresql"

// 统一转驼峰
// 问题及说明2:通过下边的查询SQL测试得出结论,转驼峰的规则是,全部字母小写下划线后的字母大写,特别要注意的是【这里的驼峰只针对数据查询的字段,分页字段默认是驼峰的,下面附上测试】。
// default、upper、lower、hump
hint FRAGMENT_SQL_COLUMN_CASE = "hump" 

// 定义查询SQL
// 问题及说明3:对mybatis的支持并不完善,支持的标签有<select> <insert> <delete> <update> <if> 和<foreach>相关,<where>标签测试是不支持的。
// 问题及说明4:Date类型数据的查询,需要使用 TO_CHAR 函数,否则是毫秒值。
var dataSetFun = @@mybatis(keyword,futurestartdate) <%
    <select>
        SELECT
	        firstrecommendfield AS first_recommend_field,
	        secondrecommendfield AS second_REcommend_Field,
            TO_CHAR(futurestartdate, 'yyyy-MM-dd') AS future_start_date
        FROM
	        yz_test_match
        WHERE futurestartdate is not null
        <if test="keyword != null and keyword != ''">
           AND firstrecommendfield like concat('%','${keyword}','%') 
        </if>    
        <if test="futurestartdate != null and futurestartdate != ''">
           AND futurestartdate = '${futurestartdate}'
        </if>  
        ORDER BY futurestartdate
    </select>
%>
 
// 创建分页查询对象
// 问题及说明5:参数的传递规则,顺序很重要,从左到右是SQL内的参数顺序。
var pageQuery =  dataSetFun(${keyword},${futurestartdate},${pageSize},${pageNumber});
// 设置分页信息
run pageQuery.setPageInfo({
    "pageSize"    : #{pageSize}, 
    "currentPage" : #{pageNumber}
});
// 执行分页查询
var pageData = pageQuery.data();
// 查询分页信息
var pageInfo = pageQuery.pageInfo();
// 返回结果封装
// 问题及说明6:结果会封装到之前的value内。
return {
  "pageData" : pageData,
  "pageInfo" : pageInfo
};
复制代码

Los parámetros son los siguientes: Los parámetros aquí no necesitan prestar atención al orden.

{
  "keyword": "",
  "futurestartdate": "2021-04-18",
  "pageSize": 1,
  "pageNumber": 1
}
复制代码

Resultados de la:

{
  "success": true,
  "message": "OK",
  "location": null,
  "code": 0,
  "lifeCycleTime": 220,
  "executionTime": 214,
  "value": {
    "pageData": [
      {
        "firstRecommendField": "豫A5VT98",
        "secondRecommendField": "460020603684395",
        "futureStartDate": "2021-04-18"
      }
    ],
    "pageInfo": {
      "enable": true,
      "pageSize": 1,
      "totalCount": 5175,
      "totalPage": 5175,
      "currentPage": 1,
      "recordPosition": 0
    }
  }
}
复制代码

2. Pruebe la configuración FRAGMENT_SQL_COLUMN_CASE

Solo publique las configuraciones modificadas:

hint FRAGMENT_SQL_COLUMN_CASE = "upper" 
复制代码

Resultado: podemos ver que los campos de pageData están todos en mayúscula, y los campos de pageInfo todavía están en mayúsculas y minúsculas.

{
  "success": true,
  "message": "OK",
  "location": null,
  "code": 0,
  "lifeCycleTime": 206,
  "executionTime": 199,
  "value": {
    "pageData": {
      "FIRST_RECOMMEND_FIELD": "豫A5VT98",
      "SECOND_RECOMMEND_FIELD": "460020603684395",
      "FUTURE_START_DATE": "2021-04-18"
    },
    "pageInfo": {
      "enable": true,
      "pageSize": 1,
      "totalCount": 5175,
      "totalPage": 5175,
      "currentPage": 1,
      "recordPosition": 0
    }
  }
}
复制代码

Supongo que te gusta

Origin juejin.im/post/7085355968661291045
Recomendado
Clasificación