部分sql语句

参考
http://blog.csdn.net/luqin1988/article/details/7831927

方式1、修改

<select id="getExchangeRecordsInPeriod" resultMap="exchangeRecordVOResultMap">
SELECT ter.*, tu.nick_name FROM t_exchange_record ter left join t_user
tu on ter.fk_anchor = tu.fk_origin_user
WHERE
1=1
<if test="userId > 0">
and fk_anchor = #{userId}
</if>
<if test="status >= 0">
and state = #{status}
</if>
<if test="start != null and end != null">
and create_date between #{start} and #{end}
</if>
order by create_date desc
limit #{offset}, #{limit}
</select>

<!-- count -->
<select id="countExchangesInPeriod" resultType="int">
SELECT count(1)
FROM t_exchange_record
WHERE 1=1
<if test="userId > 0">
and fk_anchor = #{userId}
</if>
<if test="status >= 0">
and state = #{status}
</if>
<if test="start != null and end != null">
and create_date between #{start} and #{end}
</if>
</select>


方式2

<sql id="anchorViewForPage">
and a.fk_manager_id in <foreach item="item" index="index" collection="search.managerList" open="(" separator="," close=")">#{item}</foreach>

<if test="search.nickName !=''">
and t.nick_name like CONCAT('%',#{search.nickName},'%')
</if>
<if test="search.managerId > -1">
and a.fk_manager_id = #{search.managerId}
</if>
<if test="search.userStatus>-1">
AND t.user_status = #{search.userStatus}
</if>
<if test="search.anchorType>-1">
AND a.fk_anchor_type = #{search.anchorType}
</if>
<if test="search.proxy>-1">
AND a.fk_proxy_code = #{search.proxy}
</if>
<if test="search.roomId>-1">
AND room.pk_room = #{search.roomId}
</if>
<if test="search.bank > -1">
<choose>
<when test="search.bank == 1">
AND ( a.bank IS NULL
OR a.bank = ""
OR a.deposit_bank IS NULL
OR a.deposit_bank = ""
OR a.deposit_bank_address IS NULL
OR a.deposit_bank_address = ""
OR a.bank_card_number IS NULL
OR a.id_number IS NULL
OR a.bank_account_holder IS NULL)
</when>
<when test="search.bank == 0">
AND ( a.bank IS NOT NULL
AND a.bank != ""
AND a.deposit_bank IS NOT NULL
AND a.deposit_bank != ""
AND a.deposit_bank_address IS NOT NULL
AND a.deposit_bank_address != ""
AND a.bank_card_number IS NOT NULL
AND a.id_number IS NOT NULL
AND a.bank_account_holder IS NOT NULL
AND a.bank_account_holder != "")
</when>
</choose>
</if>
</sql>

<select id="getAnchorViewListByPage" resultMap="ddshowUserWithAnchorDetail">
<![CDATA[
SELECT a.*,
t.nick_name as nick_name,
t.email,
t.mobile,
t.fk_origin_user,
t.user_status
FROM t_user AS t
LEFT JOIN t_anchor_detail AS a ON t.fk_origin_user = a.fk_user
left join t_room room on t.fk_origin_user=room.fk_user
WHERE t.is_anchor = 1
]]>
<include refid="anchorViewForPage"/>
group by room.fk_user LIMIT #{offset},#{limit}
</select>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值