zoukankan      html  css  js  c++  java
  • jeecg 模糊查询

    1、前言

    jeecg 考虑到默认模糊查询的话,会增加系统压力,导致查询慢,本来系统就挺那啥的...

    2、方式一之实体赋值

    实体重新赋值查询,用 * %% * 实现,我们知道 sql 中通常使用 % 去模糊查询的,jeecg 中 datagrid 方法里判断实体属性是否为空,不为空则重新赋值即可。

    至于 是不是用 % ,使用几个 % 根据自己情况选择,比如: "*" + xxx + "*" 、"*%" + xxx + "*"

    3、方式二之cq实现

    将值赋值给 CriteriaQuery 

    复制代码
        @RequestMapping(params = "datagrid")
        public void datagrid(BaseDevice device, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {   
            
            String devicecode = device.getDevicecode();
            String devicename = device.getDevicename();
            String status = device.getStatus();
            
            CriteriaQuery cq = new CriteriaQuery(BaseDevice.class,dataGrid);
            if(StringUtils.isNotEmpty(devicecode)){
                cq.add(Restrictions.sqlRestriction("devicecode like '%" + devicecode + "%'"));
            }
            if(StringUtils.isNotEmpty(devicename)){
                cq.add(Restrictions.sqlRestriction("devicename like '%" + devicename + "%'"));
            }
            if(StringUtils.isNotEmpty(status)){
                cq.add(Restrictions.sqlRestriction("status like '%" + status + "%'"));
            }
            
            this.systemService.getDataGridReturn(cq, true);
            TagUtil.datagrid(response, dataGrid);
        }
    复制代码

    4、其他方式

    https://my.oschina.net/u/2538398/blog/757841

  • 相关阅读:
    WindowsServer 2016激活
    selenium浏览器复用与原理分析
    react脚手架: 配置代理
    网络请求方式
    Java: Excel导入导出
    react 组件通信方式
    react: reactrouterdom
    react: 高阶函数及函数柯里化
    react: 事件处理
    react: 生命周期
  • 原文地址:https://www.cnblogs.com/Jeely/p/11996484.html
Copyright © 2011-2022 走看看