mybatis公共代码提取
1.sql区
<!-- 根据搜索条件获取数据 --> <sql id="condition_sql"> <if test="accountNo != null and accountNo != ''"> and account_no = #{accountNo,jdbcType=VARCHAR}</if> <if test="userNo != null and userNo != ''"> and user_no = #{userNo,jdbcType=VARCHAR}</if> <if test="beginDate != null and endDate != null and endDate !='' and beginDate !=''"> and create_time_ between #{beginDate} AND CONCAT(#{endDate},' 23:59:59') </if> <if test="requestNo != null and requestNo !='' "> and request_no = #{requestNo}</if> <if test="bankTrxNo != null and bankTrxNo !='' "> and bank_trx_no = #{bankTrxNo}</if> <if test="accountNo != null and accountNo !='' "> and account_no = #{accountNo}</if> <if test="isAllowSett != null and isAllowSett !=''"> and is_allow_sett = #{isAllowSett}</if> <if test="isCompleteSett != null and isCompleteSett != ''"> and is_complete_sett = #{isCompleteSett}</if> <if test="trxType != null and trxType !=''"> and trx_type_ =#{trxType} </if> <if test="fundDirection != null and fundDirection !=''"> and fund_direction = #{fundDirection}</if> </sql>
2.mybatis引用
<select id="listBy" parameterType="java.util.Map" resultMap="BaseResultMap"> select * from <include refid="table_name" /> <where> <include refid="condition_sql" />//一般在where条件引用 </where> order by create_time desc </select>
浙公网安备 33010602011771号