1.大哥筛选功能实现
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.tkdata.controller.admin.bigbrother.vo;
|
package cn.iocoder.yudao.module.tkdata.controller.admin.bigbrother.vo;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
@@ -49,8 +51,87 @@ public class BigBrotherPageReqVO extends PageParam {
|
|||||||
@Schema(description = "该数据所属的账号id", example = "30487")
|
@Schema(description = "该数据所属的账号id", example = "30487")
|
||||||
private String ownerId;
|
private String ownerId;
|
||||||
|
|
||||||
@Schema(description = "创建时间")
|
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
/**
|
||||||
private LocalDateTime[] createTime;
|
* 大哥的等级
|
||||||
|
*/
|
||||||
|
@Schema(description="大哥的等级最小值")
|
||||||
|
private Integer levelMin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 大哥的等级
|
||||||
|
*/
|
||||||
|
@Schema(description="大哥的等级最大值")
|
||||||
|
private Integer levelMax;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 大哥打赏的金币
|
||||||
|
*/
|
||||||
|
@Schema(description="大哥打赏的金币最小值")
|
||||||
|
private Integer hostcoinsMin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 大哥打赏的金币
|
||||||
|
*/
|
||||||
|
@Schema(description="大哥打赏的金币最大值")
|
||||||
|
private Integer hostcoinsMax;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 大哥打赏的历史最高金币
|
||||||
|
*/
|
||||||
|
@Schema(description="大哥打赏的历史最高金币最小值")
|
||||||
|
private Integer historicHighCoinsMin;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 大哥打赏的历史最高金币
|
||||||
|
*/
|
||||||
|
@Schema(description="大哥打赏的历史最高金币最大值")
|
||||||
|
private Integer historicHighCoinsMax;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 大哥历史打赏金币总和
|
||||||
|
*/
|
||||||
|
@Schema(description="大哥历史打赏金币总和")
|
||||||
|
private Integer totalGiftCoinsMin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 大哥历史打赏金币总和
|
||||||
|
*/
|
||||||
|
@Schema(description="大哥历史打赏金币总和")
|
||||||
|
private Integer totalGiftCoinsMax;
|
||||||
|
/**
|
||||||
|
* 租户 Id
|
||||||
|
*/
|
||||||
|
@Schema(description="租户 Id")
|
||||||
|
private Long tenantId;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据插入时间
|
||||||
|
*/
|
||||||
|
@Schema(description = "创建时间开始(yyyy-MM-dd)", example = "2023-01-01")
|
||||||
|
private Date createTimeStart;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据插入时间
|
||||||
|
*/
|
||||||
|
@Schema(description = "创建时间结束(yyyy-MM-dd)", example = "2023-01-01")
|
||||||
|
private Date createTimeEnd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序规则
|
||||||
|
*/
|
||||||
|
@Schema(description = "排序方式(asc/desc)", example = "desc")
|
||||||
|
private String sort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按照何种业务排序
|
||||||
|
*/
|
||||||
|
@Schema(description = "排序字段(historicHighCoins/totalGiftCoins/level等)", example = "hostsCoins")
|
||||||
|
private String sortName;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -76,5 +76,8 @@ public class BigBrotherDO extends BaseDO {
|
|||||||
*/
|
*/
|
||||||
private String ownerId;
|
private String ownerId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 该数据所属的租户id
|
||||||
|
*/
|
||||||
|
private Long tenantId;
|
||||||
}
|
}
|
||||||
@@ -6,8 +6,12 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.module.tkdata.controller.admin.bigbrother.vo.BigBrotherPageReqVO;
|
import cn.iocoder.yudao.module.tkdata.controller.admin.bigbrother.vo.BigBrotherPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo.EmployeeHostsPageReqVO;
|
||||||
import cn.iocoder.yudao.module.tkdata.dal.dataobject.bigbrother.BigBrotherDO;
|
import cn.iocoder.yudao.module.tkdata.dal.dataobject.bigbrother.BigBrotherDO;
|
||||||
|
import cn.iocoder.yudao.module.tkdata.dal.dataobject.employeehosts.EmployeeHostsDO;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 大哥数据 Mapper
|
* 大哥数据 Mapper
|
||||||
@@ -17,22 +21,24 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface BigBrotherMapper extends BaseMapperX<BigBrotherDO> {
|
public interface BigBrotherMapper extends BaseMapperX<BigBrotherDO> {
|
||||||
|
|
||||||
default PageResult<BigBrotherDO> selectPage(BigBrotherPageReqVO reqVO) {
|
// default PageResult<BigBrotherDO> selectPage(BigBrotherPageReqVO reqVO) {
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<BigBrotherDO>()
|
// return selectPage(reqVO, new LambdaQueryWrapperX<BigBrotherDO>()
|
||||||
.eqIfPresent(BigBrotherDO::getDisplayId, reqVO.getDisplayId())
|
// .eqIfPresent(BigBrotherDO::getDisplayId, reqVO.getDisplayId())
|
||||||
.eqIfPresent(BigBrotherDO::getUserIdStr, reqVO.getUserIdStr())
|
// .eqIfPresent(BigBrotherDO::getUserIdStr, reqVO.getUserIdStr())
|
||||||
.likeIfPresent(BigBrotherDO::getNickname, reqVO.getNickname())
|
// .likeIfPresent(BigBrotherDO::getNickname, reqVO.getNickname())
|
||||||
.eqIfPresent(BigBrotherDO::getLevel, reqVO.getLevel())
|
// .eqIfPresent(BigBrotherDO::getLevel, reqVO.getLevel())
|
||||||
.eqIfPresent(BigBrotherDO::getHostcoins, reqVO.getHostcoins())
|
// .eqIfPresent(BigBrotherDO::getHostcoins, reqVO.getHostcoins())
|
||||||
.eqIfPresent(BigBrotherDO::getFollowerCount, reqVO.getFollowerCount())
|
// .eqIfPresent(BigBrotherDO::getFollowerCount, reqVO.getFollowerCount())
|
||||||
.eqIfPresent(BigBrotherDO::getFollowingCount, reqVO.getFollowingCount())
|
// .eqIfPresent(BigBrotherDO::getFollowingCount, reqVO.getFollowingCount())
|
||||||
.eqIfPresent(BigBrotherDO::getRegion, reqVO.getRegion())
|
// .eqIfPresent(BigBrotherDO::getRegion, reqVO.getRegion())
|
||||||
.eqIfPresent(BigBrotherDO::getHistoricHighCoins, reqVO.getHistoricHighCoins())
|
// .eqIfPresent(BigBrotherDO::getHistoricHighCoins, reqVO.getHistoricHighCoins())
|
||||||
.eqIfPresent(BigBrotherDO::getTotalGiftCoins, reqVO.getTotalGiftCoins())
|
// .eqIfPresent(BigBrotherDO::getTotalGiftCoins, reqVO.getTotalGiftCoins())
|
||||||
.eqIfPresent(BigBrotherDO::getHostDisplayId, reqVO.getHostDisplayId())
|
// .eqIfPresent(BigBrotherDO::getHostDisplayId, reqVO.getHostDisplayId())
|
||||||
.eqIfPresent(BigBrotherDO::getOwnerId, reqVO.getOwnerId())
|
// .eqIfPresent(BigBrotherDO::getOwnerId, reqVO.getOwnerId())
|
||||||
.betweenIfPresent(BigBrotherDO::getCreateTime, reqVO.getCreateTime())
|
// .betweenIfPresent(BigBrotherDO::getCreateTime, reqVO.getCreateTime())
|
||||||
.orderByDesc(BigBrotherDO::getId));
|
// .orderByDesc(BigBrotherDO::getId));
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
IPage<BigBrotherDO> selectPageWithXML(IPage<BigBrotherDO> page, @Param("dto")BigBrotherPageReqVO reqDTO);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,14 @@
|
|||||||
package cn.iocoder.yudao.module.tkdata.service.bigbrother;
|
package cn.iocoder.yudao.module.tkdata.service.bigbrother;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||||
import cn.iocoder.yudao.module.tkdata.controller.admin.bigbrother.vo.BigBrotherPageReqVO;
|
import cn.iocoder.yudao.module.tkdata.controller.admin.bigbrother.vo.BigBrotherPageReqVO;
|
||||||
import cn.iocoder.yudao.module.tkdata.controller.admin.bigbrother.vo.BigBrotherSaveReqVO;
|
import cn.iocoder.yudao.module.tkdata.controller.admin.bigbrother.vo.BigBrotherSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.tkdata.dal.dataobject.bigbrother.BigBrotherDO;
|
import cn.iocoder.yudao.module.tkdata.dal.dataobject.bigbrother.BigBrotherDO;
|
||||||
|
import cn.iocoder.yudao.module.tkdata.dal.dataobject.employeehosts.EmployeeHostsDO;
|
||||||
import cn.iocoder.yudao.module.tkdata.dal.mysql.bigbrother.BigBrotherMapper;
|
import cn.iocoder.yudao.module.tkdata.dal.mysql.bigbrother.BigBrotherMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -89,7 +93,10 @@ public class BigBrotherServiceImpl implements BigBrotherService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<BigBrotherDO> getBigBrotherPage(BigBrotherPageReqVO pageReqVO) {
|
public PageResult<BigBrotherDO> getBigBrotherPage(BigBrotherPageReqVO pageReqVO) {
|
||||||
return bigBrotherMapper.selectPage(pageReqVO);
|
pageReqVO.setTenantId(TenantContextHolder.getTenantId());
|
||||||
|
IPage<BigBrotherDO> iPage = new Page<>(pageReqVO.getPageNo(),pageReqVO.getPageSize());
|
||||||
|
IPage<BigBrotherDO> bigBrotherDOIPage = bigBrotherMapper.selectPageWithXML(iPage, pageReqVO);
|
||||||
|
return new PageResult<>(bigBrotherDOIPage.getRecords(),bigBrotherDOIPage.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
<?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.bigbrother.BigBrotherMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<!--
|
||||||
|
一般情况下,尽可能使用 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.bigbrother.BigBrotherDO">
|
||||||
|
<!--@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="owner_id" jdbcType="VARCHAR" property="ownerId" />
|
||||||
|
<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="tenant_id" jdbcType="BIGINT" property="tenantId" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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,
|
||||||
|
sbr.follower_count, sbr.following_count, sbr.region, sbr.historic_high_coins, sbr.total_gift_coins,
|
||||||
|
sbr.host_display_id,sbr.create_time from
|
||||||
|
server_big_brother sbr left join server_country_info ci ON sbr.region = ci.country_name
|
||||||
|
where sbr.tenant_id=#{dto.tenantId}
|
||||||
|
<!-- 大哥所属国家筛选 -->
|
||||||
|
<if test="dto.region!= '' and dto.region != null">
|
||||||
|
and ci.country_group_name =#{dto.region,jdbcType=VARCHAR}
|
||||||
|
</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 dto.hostcoinsMax != '' ">
|
||||||
|
and sbr.hostcoins >=#{dto.hostcoinsMin,jdbcType=INTEGER}
|
||||||
|
</if>
|
||||||
|
<if test="dto.hostcoinsMax != null and dto.hostcoinsMin == null and dto.hostcoinsMin !='' ">
|
||||||
|
and sbr.hostcoins <=#{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.totalGiftCoinsMin != null and dto.totalGiftCoinsMax == null and dto.totalGiftCoinsMax != ''">
|
||||||
|
and sbr.total_gift_coins >=#{dto.totalGiftCoinsMin,jdbcType=INTEGER}
|
||||||
|
</if>
|
||||||
|
<if test="dto.totalGiftCoinsMax != null and dto.totalGiftCoinsMin == null and dto.totalGiftCoinsMin != '' ">
|
||||||
|
and sbr.total_gift_coins <=#{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 dto.levelMax != ''">
|
||||||
|
and sbr.level >=#{dto.levelMin,jdbcType=INTEGER}
|
||||||
|
</if>
|
||||||
|
<if test="dto.levelMax != null and dto.levelMin == null and dto.levelMin != '' ">
|
||||||
|
and sbr.level <=#{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>
|
||||||
|
group by sbr.display_id
|
||||||
|
order by
|
||||||
|
<!-- 排序类型 -->
|
||||||
|
<choose>
|
||||||
|
<!-- 传空和默认的情况下按照时间降序排序 -->
|
||||||
|
<when test="dto.sortName == '' or dto.sortName == null">
|
||||||
|
sbr.create_time 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>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user