欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Mybatis-plus:${ew.sqlselect}用法說明

 更新時(shí)間:2022年06月22日 09:33:50   作者:Xuan少  
這篇文章主要介紹了Mybatis-plus:${ew.sqlselect}用法說明,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

Mybatis-plus:${ew.sqlselect}

上篇文章是通過動(dòng)態(tài)注入的方式去篩選查詢條件,這次我們用mybatis-plus自帶的${ew.sqlselect}來篩選。

也就是Constants源碼里的這個(gè)屬性

使用步驟

1.在xml文件里引入

    <!--表數(shù)據(jù)list-->
    <select id="tableList" resultType="java.util.LinkedHashMap">
        SELECT
            ${ew.sqlSelect} // 這里拼接select后面的語句
        FROM
            ${table_name} //如果是單表的話,這里可以寫死
        ${ew.customSqlSegment}
    </select>

2.mapper文件

 //表數(shù)據(jù)list
 IPage<LinkedHashMap<String,Object>> tableList(@Param("table_name") String table_name,
                                                  Page page,
                                                  @Param(Constants.WRAPPER) QueryWrapper queryWrapper);

3.用法

     String responseField = "*"; //先把拿到的值設(shè)為*,如果responsefield.equals或者為null,就使用默認(rèn)值,這樣就可以查詢所有條件
        if (nativeWebRequest.getParameter("response_field") != null && !nativeWebRequest.getParameter("response_field").equals("")) {
            responseField = nativeWebRequest.getParameter("response_field");
        }
        if (responseField.length() != 0 && !"".equals(responseField)) {
            queryWrapper.select(responseField);
        }

不加入responsefield字段,或者responsefield字段為空時(shí),查詢所有的值

加入responsefield字段后,查詢對應(yīng)的值

Mybatis-plus ${ew.sqlSegment}踩坑

使用${ew.sqlSegment} 如果是連表查詢且查詢條件是連表的字段則需在service層拼接查詢條件時(shí)字段前指定別名

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。 

相關(guān)文章

最新評論