mybatis-plus - Based on mysql paging query with statistics, and the use of fuzzy query

    <!--
        // 查询报销次数  - state=3 成功的
        // 宠物数量 - nickname 不为空的,不包括临时宠物
        // 缴费次数 - wallet_type 流水表,支出的
    -->
    <select id="findPage" resultType="com.ws.ldy.modules.pets.model.vo.PetsUserVO">
        select
        u.*
        ,(SELECT count( t1.id) FROM t_pets_declare t1 WHERE t1.user_id = u.id and t1.state = 3 ) as declareNum
        ,(SELECT count( t1.id) FROM t_pets_pet_info t1 WHERE t1.user_id = u.id and t1.nickname != '' ) as petsNum
        ,(SELECT count( t1.id) FROM t_pets_wallet_flow t1 WHERE t1.user_id = u.id and t1.wallet_type = 2) as payNum
        from t_pets_user u
        where 1=1
        <if test="fullName !=null and fullName != ''">
           and u.full_name like concat('%',#{
    
    fullName},'%')
        </if>
        <if test="phone !=null and phone != ''">
            and u.phone like concat('%',#{
    
    phone},'%')
        </if>
        <if test="disable !=null and disable != ''">
            and u.disable = #{
    
    disable}
        </if>
    </select>
  • Personal open source project (universal background management system) –> https://gitee.com/wslxm/spring-boot-plus2 , you can check it out if you like

  • This is the end of this article. If you find it useful, please like or pay attention to it. We will continue to update more content from time to time... Thank you for watching!

Guess you like

Origin blog.csdn.net/qq_41463655/article/details/112178180