Springboot mybatis注解方式(多条件查询,多参数传递)

1、修改

//条数更改和修改
@Update("update ss set " +
        "bt = #{bt} , tt = #{tt} , update_date = #{updateDate} WHERE id = #{id}")
void upDateByBalanceCountAndTotalCountAndUpdateDate(@Param("id") int id,  @Param("bt") int balanceCount,
                                                    @Param("tt") int tt,
                                                    @Param("updateDate") int updateDate);
解释:where条件比较多时最好写在一行   否则查询失败

2、  多条件查询

@Select(" <script> SELECT id,"      
        "p_t pT," +
        " WHERE " +
        "1+1"+
        " and s = #{pa.s}"+
        " <if test=\"#{pa.d} != null\">and uid = #{pa.d} </if> "+
        " <if test=\"#{pa.d} != null \">and brand_id = #{pa.d} </if> "+
        " <if test=\"#{pa.d1} != null \">and id limit #{pa.d1},#{pa.d2} </if> </script>")
List<CpMsgPayDetail> findByid1Andid3 (@Param("pa") Map<String, Object> pa);
解释:一定要加上脚本<script> 否则查询失败

猜你喜欢

转载自blog.csdn.net/AinUser/article/details/82500482