Files
vvDataAdmin/tkdata-model-server/src/main/resources/mapper/employeebigbrother/EmployeeBigBrotherMapper.xml

275 lines
15 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.tkdata.dal.mysql.employeebigbrother.EmployeeBigBrotherMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<resultMap id="BaseResultMap" type="cn.iocoder.yudao.module.tkdata.dal.dataobject.employeebigbrother.EmployeeBigBrotherDO">
<!--@mbg.generated-->
<!--@Table server_big_brother-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="display_id" jdbcType="VARCHAR" property="displayId" />
<result column="user_id_str" jdbcType="VARCHAR" property="userIdStr" />
<result column="nickname" jdbcType="VARCHAR" property="nickname" />
<result column="level" jdbcType="INTEGER" property="level" />
<result column="hostcoins" jdbcType="INTEGER" property="hostcoins" />
<result column="follower_count" jdbcType="INTEGER" property="followerCount" />
<result column="following_count" jdbcType="INTEGER" property="followingCount" />
<result column="region" jdbcType="VARCHAR" property="region" />
<result column="historic_high_coins" jdbcType="INTEGER" property="historicHighCoins" />
<result column="total_gift_coins" jdbcType="INTEGER" property="totalGiftCoins" />
<result column="host_display_id" jdbcType="VARCHAR" property="hostDisplayId" />
<result column="user_id" jdbcType="BIGINT" property="userId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="creator" jdbcType="BIGINT" property="creator" />
<result column="updater" jdbcType="VARCHAR" property="updater" />
<result column="deleted" jdbcType="BOOLEAN" property="deleted" />
<result column="operation_status" jdbcType="BOOLEAN" property="operationStatus"/>
<result column="fans_level" jdbcType="INTEGER" property="fansLevel"/>
</resultMap>
<select id="selectPagewithSelf"
resultType="cn.iocoder.yudao.module.tkdata.dal.dataobject.employeebigbrother.EmployeeBigBrotherDO">
select sbr.id, sbr.display_id, sbr.user_id_str,sbr.nickname,sbr.level,sbr.hostcoins,
sbr.follower_count, sbr.following_count, sbr.region, sbr.historic_high_coins, sbr.total_gift_coins,
sbr.host_display_id,sbr.create_time, sbr.user_id, sbr.operation_status,sbr.fans_level from
server_employee_big_brother sbr left join server_country_info ci ON sbr.region = ci.country_name
where sbr.tenant_id=#{dto.tenantId}
and sbr.deleted = 0
and sbr.user_id = #{dto.userId,jdbcType=VARCHAR}
<!-- 大哥所属国家筛选 -->
<if test="dto.region!= '' and dto.region != null">
and ci.country_group_name =#{dto.region,jdbcType=VARCHAR}
</if>
<if test="dto.countryName != null and dto.countryName != ''">
and sbr.region = #{dto.countryName}
</if>
<!-- 大哥入库时间筛选 -->
<if test="dto.createTimeStart != null and dto.createTimeEnd != null">
and sbr.create_time BETWEEN #{dto.createTimeStart,jdbcType=TIMESTAMP} and #{dto.createTimeEnd,jdbcType=TIMESTAMP}
</if>
<!-- 大哥 Id 模糊搜索 -->
<if test="dto.displayId != null and dto.displayId != '' ">
and sbr.display_id like concat(#{dto.displayId,jdbcType=VARCHAR},'%')
</if>
<!-- 大哥打赏的历史最高金币筛选 -->
<if test="dto.historicHighCoinsMin != null and dto.historicHighCoinsMin == null ">
and sbr.historic_high_coins >=#{dto.historicHighCoinsMin,jdbcType=INTEGER}
</if>
<if test="dto.historicHighCoinsMax != null and dto.historicHighCoinsMax == null ">
and sbr.historic_high_coins &lt;=#{dto.historicHighCoinsMax,jdbcType=INTEGER}
</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>
<!-- 大哥打赏总金币筛选 -->
<if test="dto.totalGiftCoinsMin != null and dto.totalGiftCoinsMax == null ">
and sbr.total_gift_coins >=#{dto.totalGiftCoinsMin,jdbcType=INTEGER}
</if>
<if test="dto.totalGiftCoinsMax != null and dto.totalGiftCoinsMin == null ">
and sbr.total_gift_coins &lt;=#{dto.totalGiftCoinsMax,jdbcType=INTEGER}
</if>
<if test="dto.totalGiftCoinsMin != null and dto.totalGiftCoinsMax != null " >
and sbr.total_gift_coins between #{dto.totalGiftCoinsMin,jdbcType=INTEGER} and #{dto.totalGiftCoinsMax,jdbcType=INTEGER}
</if>
<!-- 大哥等级筛选 -->
<if test="dto.levelMin != null and dto.levelMax == null ">
and sbr.level >=#{dto.levelMin,jdbcType=INTEGER}
</if>
<if test="dto.levelMax != null and dto.levelMin == null ">
and sbr.level &lt;=#{dto.levelMax,jdbcType=INTEGER}
</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 &lt;=#{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.operationStatus != null">
and sbr.operation_status =#{dto.operationStatus}
</if>
group by sbr.display_id
order by
<!-- 排序类型 -->
<choose>
<!-- 传空和默认的情况下按照时间降序排序 -->
<when test="dto.sortName == '' or dto.sortName == null">
sbr.create_time desc,sbr.id desc
</when>
<!-- sortNmae 有值的情况下排序 -->
<when test="dto.sortName != null and dto.sort != null ">
<if test="dto.sortName == 'createTime' and dto.sort != null">
sbr.create_time ${dto.sort}
</if>
<!-- 大哥等级排序 -->
<if test="dto.sortName == 'level' and dto.sort != null">
sbr.level ${dto.sort}
</if>
<!-- 大哥打赏金币排序 -->
<if test="dto.sortName == 'hostsCoins' and dto.sort != null">
sbr.hostcoins ${dto.sort}
</if>
<!-- 大哥打赏总金币排序 -->
<if test="dto.sortName == 'totalGiftCoins' and dto.sort != null">
sbr.total_gift_coins ${dto.sort}
</if>
</when>
</choose>
</select>
<select id="selectPage"
resultType="cn.iocoder.yudao.module.tkdata.dal.dataobject.employeebigbrother.EmployeeBigBrotherDO">
select sbr.id, sbr.display_id, sbr.user_id_str,sbr.nickname,sbr.level,sbr.hostcoins,
sbr.follower_count, sbr.following_count, sbr.region, sbr.historic_high_coins, sbr.total_gift_coins,
sbr.host_display_id,sbr.create_time, sbr.user_id, sbr.operation_status,sbr.fans_level from
server_employee_big_brother sbr left join server_country_info ci ON sbr.region = ci.country_name
where sbr.tenant_id=#{dto.tenantId}
<if test="dto.isDelete == 1">
and deleted = 1
</if>
<if test="dto.isDelete == 0">
and deleted = 0
</if>
<if test="dto.isDelete == 3">
and (deleted = 0
or deleted = 1)
</if>
<if test="dto.userId != null" >
and sbr.user_id = #{dto.userId,jdbcType=VARCHAR}
</if>
<!-- 大哥所属国家筛选 -->
<if test="dto.region!= '' and dto.region != null">
and ci.country_group_name =#{dto.region,jdbcType=VARCHAR}
</if>
<if test="dto.countryName != null and dto.countryName != ''">
and sbr.region = #{dto.countryName}
</if>
<!-- 大哥入库时间筛选 -->
<if test="dto.createTimeStart != null and dto.createTimeEnd != null">
and sbr.create_time BETWEEN #{dto.createTimeStart,jdbcType=TIMESTAMP} and #{dto.createTimeEnd,jdbcType=TIMESTAMP}
</if>
<!-- 大哥 Id 模糊搜索 -->
<if test="dto.displayId != null and dto.displayId != '' ">
and sbr.display_id like concat(#{dto.displayId,jdbcType=VARCHAR},'%')
</if>
<!-- 大哥打赏金币筛选 -->
<if test="dto.hostcoinsMin != null and dto.hostcoinsMax == null ">
and sbr.hostcoins >=#{dto.hostcoinsMin,jdbcType=INTEGER}
</if>
<if test="dto.hostcoinsMax != null and dto.hostcoinsMin == null ">
and sbr.hostcoins &lt;=#{dto.hostcoinsMax,jdbcType=INTEGER}
</if>
<if test="dto.hostcoinsMin != null and dto.hostcoinsMax != null " >
and sbr.hostcoins between #{dto.hostcoinsMin,jdbcType=INTEGER} and #{dto.hostcoinsMax,jdbcType=INTEGER}
</if>
<!-- 大哥打赏的历史最高金币筛选 -->
<if test="dto.historicHighCoinsMin != null and dto.historicHighCoinsMin == null ">
and sbr.historic_high_coins >=#{dto.historicHighCoinsMin,jdbcType=INTEGER}
</if>
<if test="dto.historicHighCoinsMax != null and dto.historicHighCoinsMax == null ">
and sbr.historic_high_coins &lt;=#{dto.historicHighCoinsMax,jdbcType=INTEGER}
</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>
<!-- 大哥等级筛选 -->
<if test="dto.levelMin != null and dto.levelMax == null ">
and sbr.level >=#{dto.levelMin,jdbcType=INTEGER}
</if>
<if test="dto.levelMax != null and dto.levelMin == null ">
and sbr.level &lt;=#{dto.levelMax,jdbcType=INTEGER}
</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 &lt;=#{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.operationStatus != null">
and sbr.operation_status =#{dto.operationStatus}
</if>
group by sbr.display_id
order by
<!-- 排序类型 -->
<choose>
<!-- 传空和默认的情况下按照时间降序排序 -->
<when test="dto.sortName == '' or dto.sortName == null">
sbr.create_time desc,sbr.id desc
</when>
<!-- sortNmae 有值的情况下排序 -->
<when test="dto.sortName != null and dto.sort != null ">
<if test="dto.sortName == 'createTime' and dto.sort != null">
sbr.create_time ${dto.sort}
</if>
<!-- 大哥等级排序 -->
<if test="dto.sortName == 'level' and dto.sort != null">
sbr.level ${dto.sort}
</if>
<!-- 大哥打赏金币排序 -->
<if test="dto.sortName == 'hostsCoins' and dto.sort != null">
sbr.hostcoins ${dto.sort}
</if>
<!-- 大哥打赏总金币排序 -->
<if test="dto.sortName == 'totalGiftCoins' and dto.sort != null">
sbr.total_gift_coins ${dto.sort}
</if>
</when>
</choose>
</select>
<select id="selectEmployeeBrotherCompleteBarChart"
resultType="cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo.CompletedRateVO">
SELECT
user_id AS userId,
COUNT(DISTINCT
CASE WHEN operation_status = 1 THEN display_id END) AS finishedNum
FROM server_employee_big_brother
WHERE deleted = 0
AND operation_status = 1
<!-- 日期范围:今天或过去 7 天(含今天) -->
AND update_time >= DATE_SUB(CURDATE(), INTERVAL #{days,jdbcType=INTEGER} - 1 DAY)
<if test="list != null and list.size() > 0">
AND user_id IN
<foreach collection="list" item="user_id" open="(" separator="," close=")">
#{user_id}
</foreach>
</if>
GROUP BY user_id
</select>
<select id="selectEmployeeBrotherWithOperationStatus"
resultType="cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo.CompletedRateVO">
SELECT
user_id AS userId,
SUM(CASE WHEN operation_status = 1 THEN 1 ELSE 0 END) AS finishedNum,
SUM(CASE WHEN operation_status = 0 THEN 1 ELSE 0 END) AS unfinishedNum,
COUNT(*) AS totalNum
FROM server_employee_big_brother
WHERE deleted = 0
<if test="userId != null">
AND user_id = #{userId}
</if>
GROUP BY user_id
</select>
</mapper>