refactor(mapper): 优化 BigBrotherMapper 查询结构与条件拼接
This commit is contained in:
@@ -37,97 +37,86 @@
|
|||||||
|
|
||||||
|
|
||||||
<select id="selectPageWithXML" resultType="cn.iocoder.yudao.module.tkdata.dal.dataobject.bigbrother.BigBrotherDO">
|
<select id="selectPageWithXML" resultType="cn.iocoder.yudao.module.tkdata.dal.dataobject.bigbrother.BigBrotherDO">
|
||||||
select sbr.id, sbr.display_id, sbr.user_id_str,sbr.nickname,sbr.level,sbr.hostcoins,
|
select
|
||||||
sbr.follower_count, sbr.following_count, sbr.region, sbr.historic_high_coins, sbr.total_gift_coins,
|
sbr.id, sbr.display_id, sbr.user_id_str, sbr.nickname, sbr.level, sbr.hostcoins,
|
||||||
sbr.host_display_id,sbr.create_time, sbr.is_assigned,sbr.fans_level from
|
sbr.follower_count, sbr.following_count, sbr.region, sbr.historic_high_coins, sbr.total_gift_coins,
|
||||||
server_big_brother sbr left join server_country_info ci ON sbr.region = ci.country_name
|
sbr.host_display_id, sbr.create_time, sbr.is_assigned, sbr.fans_level
|
||||||
where sbr.tenant_id=#{dto.tenantId}
|
from server_big_brother sbr
|
||||||
|
|
||||||
|
<if test="dto.region != null and dto.region != ''">
|
||||||
|
left join server_country_info ci ON sbr.region = ci.country_name
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<where>
|
||||||
|
and sbr.tenant_id = #{dto.tenantId}
|
||||||
and sbr.deleted = 0
|
and sbr.deleted = 0
|
||||||
<!-- 大哥所属国家筛选 -->
|
|
||||||
<if test="dto.region!= '' and dto.region != null">
|
<if test="dto.region != null and dto.region != ''">
|
||||||
and ci.country_group_name =#{dto.region,jdbcType=VARCHAR}
|
and ci.country_group_name = #{dto.region,jdbcType=VARCHAR}
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<if test="dto.countryName != null and dto.countryName != ''">
|
<if test="dto.countryName != null and dto.countryName != ''">
|
||||||
and sbr.region = #{dto.countryName}
|
and sbr.region = #{dto.countryName}
|
||||||
</if>
|
</if>
|
||||||
<!-- 大哥入库时间筛选 -->
|
|
||||||
<if test="dto.createTimeStart != null and dto.createTimeEnd != null">
|
<if test="dto.createTimeStart != null and dto.createTimeEnd != null">
|
||||||
and sbr.create_time BETWEEN #{dto.createTimeStart,jdbcType=TIMESTAMP} and #{dto.createTimeEnd,jdbcType=TIMESTAMP}
|
and sbr.create_time BETWEEN #{dto.createTimeStart} and #{dto.createTimeEnd}
|
||||||
</if>
|
</if>
|
||||||
<!-- 大哥 Id 模糊搜索 -->
|
|
||||||
<if test="dto.displayId != null and dto.displayId != '' ">
|
<if test="dto.displayId != null and dto.displayId != ''">
|
||||||
and sbr.display_id like concat(#{dto.displayId,jdbcType=VARCHAR},'%')
|
and sbr.display_id like concat(#{dto.displayId}, '%')
|
||||||
</if>
|
</if>
|
||||||
<!-- 大哥打赏的历史最高金币筛选 -->
|
|
||||||
<if test="dto.historicHighCoinsMin != null and dto.historicHighCoinsMin == null ">
|
<if test="dto.historicHighCoinsMin != null">
|
||||||
and sbr.historic_high_coins >=#{dto.historicHighCoinsMin,jdbcType=INTEGER}
|
and sbr.historic_high_coins >= #{dto.historicHighCoinsMin}
|
||||||
</if>
|
</if>
|
||||||
<if test="dto.historicHighCoinsMax != null and dto.historicHighCoinsMax == null ">
|
<if test="dto.historicHighCoinsMax != null">
|
||||||
and sbr.historic_high_coins <=#{dto.historicHighCoinsMax,jdbcType=INTEGER}
|
and sbr.historic_high_coins <= #{dto.historicHighCoinsMax}
|
||||||
</if>
|
</if>
|
||||||
<if test="dto.historicHighCoinsMin != null and dto.historicHighCoinsMax != null " >
|
|
||||||
and sbr.historic_high_coins between #{dto.historicHighCoinsMin,jdbcType=INTEGER} and #{dto.historicHighCoinsMax,jdbcType=INTEGER}
|
<if test="dto.totalGiftCoinsMin != null">
|
||||||
|
and sbr.total_gift_coins >= #{dto.totalGiftCoinsMin}
|
||||||
</if>
|
</if>
|
||||||
<!-- 大哥打赏总金币筛选 -->
|
<if test="dto.totalGiftCoinsMax != null">
|
||||||
<if test="dto.totalGiftCoinsMin != null and dto.totalGiftCoinsMax == null ">
|
and sbr.total_gift_coins <= #{dto.totalGiftCoinsMax}
|
||||||
and sbr.total_gift_coins >=#{dto.totalGiftCoinsMin,jdbcType=INTEGER}
|
|
||||||
</if>
|
</if>
|
||||||
<if test="dto.totalGiftCoinsMax != null and dto.totalGiftCoinsMin == null ">
|
|
||||||
and sbr.total_gift_coins <=#{dto.totalGiftCoinsMax,jdbcType=INTEGER}
|
<if test="dto.levelMin != null">
|
||||||
|
and sbr.level >= #{dto.levelMin}
|
||||||
</if>
|
</if>
|
||||||
<if test="dto.totalGiftCoinsMin != null and dto.totalGiftCoinsMax != null " >
|
<if test="dto.levelMax != null">
|
||||||
and sbr.total_gift_coins between #{dto.totalGiftCoinsMin,jdbcType=INTEGER} and #{dto.totalGiftCoinsMax,jdbcType=INTEGER}
|
and sbr.level <= #{dto.levelMax}
|
||||||
</if>
|
</if>
|
||||||
<!-- 大哥等级筛选 -->
|
|
||||||
<if test="dto.levelMin != null and dto.levelMax == null ">
|
<if test="dto.fansLevelMin != null">
|
||||||
and sbr.level >=#{dto.levelMin,jdbcType=INTEGER}
|
and sbr.fans_level >= #{dto.fansLevelMin}
|
||||||
</if>
|
</if>
|
||||||
<if test="dto.levelMax != null and dto.levelMin == null ">
|
<if test="dto.fansLevelMax != null">
|
||||||
and sbr.level <=#{dto.levelMax,jdbcType=INTEGER}
|
and sbr.fans_level <= #{dto.fansLevelMax}
|
||||||
</if>
|
</if>
|
||||||
<if test="dto.levelMin != null and dto.levelMax != null " >
|
|
||||||
and sbr.level between #{dto.levelMin,jdbcType=INTEGER} and #{dto.levelMax,jdbcType=INTEGER}
|
|
||||||
</if>
|
|
||||||
<!-- 粉丝团等级筛选 -->
|
|
||||||
<if test="dto.fansLevelMin != null and dto.fansLevelMax == null ">
|
|
||||||
and sbr.fans_level >=#{dto.fansLevelMin,jdbcType=INTEGER}
|
|
||||||
</if>
|
|
||||||
<if test="dto.fansLevelMax != null and dto.fansLevelMin == null ">
|
|
||||||
and sbr.fans_level <=#{dto.fansLevelMax,jdbcType=INTEGER}
|
|
||||||
</if>
|
|
||||||
<if test="dto.fansLevelMin != null and dto.fansLevelMax != null " >
|
|
||||||
and sbr.fans_level between #{dto.fansLevelMin,jdbcType=INTEGER} and #{dto.fansLevelMax,jdbcType=INTEGER}
|
|
||||||
</if>
|
|
||||||
|
|
||||||
<if test="dto.isAssigned != null">
|
<if test="dto.isAssigned != null">
|
||||||
and sbr.is_assigned =#{dto.isAssigned}
|
and sbr.is_assigned = #{dto.isAssigned}
|
||||||
</if>
|
</if>
|
||||||
group by sbr.display_id
|
</where>
|
||||||
order by
|
|
||||||
<!-- 排序类型 -->
|
<choose>
|
||||||
<choose>
|
<when test="dto.sortName == 'createTime' and dto.sort != null">
|
||||||
<!-- 传空和默认的情况下按照时间降序排序 -->
|
order by sbr.create_time ${dto.sort}
|
||||||
<when test="dto.sortName == '' or dto.sortName == null">
|
</when>
|
||||||
sbr.create_time desc,sbr.id desc
|
<when test="dto.sortName == 'level' and dto.sort != null">
|
||||||
</when>
|
order by sbr.level ${dto.sort}
|
||||||
<!-- sortNmae 有值的情况下排序 -->
|
</when>
|
||||||
<when test="dto.sortName != null and dto.sort != null ">
|
<when test="dto.sortName == 'hostsCoins' and dto.sort != null">
|
||||||
<if test="dto.sortName == 'createTime' and dto.sort != null">
|
order by sbr.hostcoins ${dto.sort}
|
||||||
sbr.create_time ${dto.sort}
|
</when>
|
||||||
</if>
|
<when test="dto.sortName == 'totalGiftCoins' and dto.sort != null">
|
||||||
<!-- 大哥等级排序 -->
|
order by sbr.total_gift_coins ${dto.sort}
|
||||||
<if test="dto.sortName == 'level' and dto.sort != null">
|
</when>
|
||||||
sbr.level ${dto.sort}
|
|
||||||
</if>
|
<otherwise>
|
||||||
<!-- 大哥打赏金币排序 -->
|
order by sbr.create_time desc, sbr.id desc
|
||||||
<if test="dto.sortName == 'hostsCoins' and dto.sort != null">
|
</otherwise>
|
||||||
sbr.hostcoins ${dto.sort}
|
</choose>
|
||||||
</if>
|
|
||||||
<!-- 大哥打赏总金币排序 -->
|
|
||||||
<if test="dto.sortName == 'totalGiftCoins' and dto.sort != null">
|
|
||||||
sbr.total_gift_coins ${dto.sort}
|
|
||||||
</if>
|
|
||||||
</when>
|
|
||||||
</choose>
|
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user