refactor(system): 租户积分分页查询改为XML连表并返回VO
This commit is contained in:
@@ -8,7 +8,6 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import javax.validation.*;
|
import javax.validation.*;
|
||||||
import javax.servlet.http.*;
|
import javax.servlet.http.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -83,9 +82,9 @@ public class TenantPointsController {
|
|||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得租户积分记录分页")
|
@Operation(summary = "获得租户积分记录分页")
|
||||||
@PreAuthorize("@ss.hasPermission('system:tenant-points:query')")
|
@PreAuthorize("@ss.hasPermission('system:tenant-points:query')")
|
||||||
public CommonResult<PageResult<TenantPointsRespVO>> getTenantPointsPage(@Valid TenantPointsPageReqVO pageReqVO) {
|
public CommonResult<PageResult<TenantPointsPageRespVO>> getTenantPointsPage(@Valid TenantPointsPageReqVO pageReqVO) {
|
||||||
PageResult<TenantPointsDO> pageResult = tenantPointsService.getTenantPointsPage(pageReqVO);
|
PageResult<TenantPointsPageRespVO> tenantPointsPage = tenantPointsService.getTenantPointsPage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, TenantPointsRespVO.class));
|
return success(tenantPointsPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/export-excel")
|
@GetMapping("/export-excel")
|
||||||
@@ -95,10 +94,12 @@ public class TenantPointsController {
|
|||||||
public void exportTenantPointsExcel(@Valid TenantPointsPageReqVO pageReqVO,
|
public void exportTenantPointsExcel(@Valid TenantPointsPageReqVO pageReqVO,
|
||||||
HttpServletResponse response) throws IOException {
|
HttpServletResponse response) throws IOException {
|
||||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
List<TenantPointsDO> list = tenantPointsService.getTenantPointsPage(pageReqVO).getList();
|
|
||||||
|
List<TenantPointsPageRespVO> list = tenantPointsService.getTenantPointsPage(pageReqVO).getList();
|
||||||
|
|
||||||
// 导出 Excel
|
// 导出 Excel
|
||||||
ExcelUtils.write(response, "租户积分记录.xls", "数据", TenantPointsRespVO.class,
|
ExcelUtils.write(response, "租户积分记录.xls", "数据", TenantPointsPageRespVO.class,
|
||||||
BeanUtils.toBean(list, TenantPointsRespVO.class));
|
BeanUtils.toBean(list, TenantPointsPageRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/transaction-history/page")
|
@GetMapping("/transaction-history/page")
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ public class TenantPointsPageReqVO extends PageParam {
|
|||||||
private Long targetTenantId;
|
private Long targetTenantId;
|
||||||
|
|
||||||
@Schema(description = "创建时间")
|
@Schema(description = "创建时间")
|
||||||
private LocalDateTime createdAt;
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createdAt;
|
||||||
|
|
||||||
|
@Schema(description = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.controller.admin.tenantpoints.vo;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 租户积分记录 Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class TenantPointsPageRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "16587")
|
||||||
|
@ExcelProperty("主键")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "本次变动点数,正加负减", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("本次变动点数,正加负减")
|
||||||
|
private Integer points;
|
||||||
|
|
||||||
|
@Schema(description = "变动后余额快照(冗余)")
|
||||||
|
@ExcelProperty("变动后余额快照(冗余)")
|
||||||
|
private Integer balance;
|
||||||
|
|
||||||
|
@Schema(description = "变动类型,", example = "转账")
|
||||||
|
@ExcelProperty("变动类型,")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
@Schema(description = "变动描述", example = "转账金额 100")
|
||||||
|
@ExcelProperty("变动描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Schema(description = "订单 Id/业务单号", example = "84")
|
||||||
|
@ExcelProperty("订单 Id/业务单号")
|
||||||
|
private Long orderId;
|
||||||
|
|
||||||
|
@Schema(description = "业务流水号(转账、订单等唯一标识)")
|
||||||
|
@ExcelProperty("业务流水号(转账、订单等唯一标识)")
|
||||||
|
private String bizNo;
|
||||||
|
|
||||||
|
@Schema(description = "操作人 Id", example = "8171")
|
||||||
|
@ExcelProperty("操作人 Id")
|
||||||
|
private Long operatorId;
|
||||||
|
|
||||||
|
@Schema(description = "目标租户 Id(转账使用)", example = "18731")
|
||||||
|
@ExcelProperty("目标租户 Id(转账使用)")
|
||||||
|
private Long targetTenantId;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
|
||||||
|
@Schema(description = "租户名称", example = "租户 A")
|
||||||
|
@ExcelProperty("租户名称")
|
||||||
|
private String tenantName;
|
||||||
|
}
|
||||||
@@ -7,8 +7,10 @@ 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.system.dal.dataobject.tenantpoints.TenantPointsDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.tenantpoints.TenantPointsDO;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.tenantpoints.vo.*;
|
import cn.iocoder.yudao.module.system.controller.admin.tenantpoints.vo.*;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 租户积分记录 Mapper
|
* 租户积分记录 Mapper
|
||||||
@@ -53,4 +55,7 @@ public interface TenantPointsMapper extends BaseMapperX<TenantPointsDO> {
|
|||||||
.orderByDesc(TenantPointsDO::getId));
|
.orderByDesc(TenantPointsDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IPage<TenantPointsPageRespVO> selectPageWithXML(@Param("iPage") IPage<TenantPointsPageRespVO> iPage, @Param("pageReqVO") TenantPointsPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
IPage<TenantPointsPageRespVO> selectPageWithTenantIdXML(@Param("iPage")IPage<TenantPointsPageRespVO> iPage,@Param("pageReqVO") TenantPointsPageReqVO pageReqVO,@Param("tenantId") Long tenantId);
|
||||||
}
|
}
|
||||||
@@ -57,7 +57,7 @@ public interface TenantPointsService {
|
|||||||
* @param pageReqVO 分页查询
|
* @param pageReqVO 分页查询
|
||||||
* @return 租户积分记录分页
|
* @return 租户积分记录分页
|
||||||
*/
|
*/
|
||||||
PageResult<TenantPointsDO> getTenantPointsPage(TenantPointsPageReqVO pageReqVO);
|
PageResult<TenantPointsPageRespVO> getTenantPointsPage(TenantPointsPageReqVO pageReqVO);
|
||||||
|
|
||||||
PageResult<TenantPointsDO> getTenantTransactionHistoryPointsPage(PageParam pageReqVO, Long tenantId);
|
PageResult<TenantPointsDO> getTenantTransactionHistoryPointsPage(PageParam pageReqVO, Long tenantId);
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,11 @@ package cn.iocoder.yudao.module.system.service.tenantpoints;
|
|||||||
|
|
||||||
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.framework.tenant.core.context.TenantContextHolder;
|
||||||
|
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;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.tenantpoints.vo.*;
|
import cn.iocoder.yudao.module.system.controller.admin.tenantpoints.vo.*;
|
||||||
@@ -18,7 +19,6 @@ import cn.iocoder.yudao.module.system.dal.mysql.tenantpoints.TenantPointsMapper;
|
|||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.diffList;
|
|
||||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,12 +86,18 @@ public class TenantPointsServiceImpl implements TenantPointsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<TenantPointsDO> getTenantPointsPage(TenantPointsPageReqVO pageReqVO) {
|
public PageResult<TenantPointsPageRespVO> getTenantPointsPage(TenantPointsPageReqVO pageReqVO) {
|
||||||
Long tenantId = TenantContextHolder.getTenantId();
|
Long tenantId = TenantContextHolder.getTenantId();
|
||||||
|
|
||||||
if (tenantId == 1) {
|
if (tenantId == 1) {
|
||||||
return tenantPointsMapper.selectPage(pageReqVO);
|
IPage<TenantPointsPageRespVO> iPage = new Page<>(pageReqVO.getPageNo(),pageReqVO.getPageSize());
|
||||||
|
IPage<TenantPointsPageRespVO> tenantPointsPageRespVOIPage = tenantPointsMapper.selectPageWithXML(iPage, pageReqVO);
|
||||||
|
return new PageResult<>(tenantPointsPageRespVOIPage.getRecords(),tenantPointsPageRespVOIPage.getTotal());
|
||||||
}
|
}
|
||||||
return tenantPointsMapper.selectPageWithTenantId(pageReqVO,tenantId);
|
|
||||||
|
IPage<TenantPointsPageRespVO> iPage = new Page<>(pageReqVO.getPageNo(),pageReqVO.getPageSize());
|
||||||
|
IPage<TenantPointsPageRespVO> tenantPointsPageRespVOIPage = tenantPointsMapper.selectPageWithTenantIdXML(iPage,pageReqVO,tenantId);
|
||||||
|
return new PageResult<>(tenantPointsPageRespVOIPage.getRecords(),tenantPointsPageRespVOIPage.getTotal());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,4 +9,70 @@
|
|||||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectPageWithXML"
|
||||||
|
resultType="cn.iocoder.yudao.module.system.controller.admin.tenantpoints.vo.TenantPointsPageRespVO">
|
||||||
|
select stp.*,st.name as tenantName
|
||||||
|
from system_tenant_points stp
|
||||||
|
left join system_tenant st
|
||||||
|
on st.id = stp.tenant_id
|
||||||
|
<where>
|
||||||
|
<if test="pageReqVO.bizNo != null">
|
||||||
|
and stp.biz_no = #{pageReqVO.bizNo}
|
||||||
|
</if>
|
||||||
|
<if test="pageReqVO.remark != null">
|
||||||
|
and stp.remark like concat('%', #{pageReqVO.remark}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="pageReqVO.orderId != null">
|
||||||
|
and stp.operator_id = #{pageReqVO.orderId}
|
||||||
|
</if>
|
||||||
|
<if test="pageReqVO.targetTenantId != null">
|
||||||
|
and stp.target_tenant_id = #{pageReqVO.targetTenantId}
|
||||||
|
</if>
|
||||||
|
<if test="pageReqVO.operatorId != null">
|
||||||
|
and stp.operator_id = #{pageReqVO.operatorId}
|
||||||
|
</if>
|
||||||
|
<if test="pageReqVO.type != null">
|
||||||
|
and stp.type = #{pageReqVO.type}
|
||||||
|
</if>
|
||||||
|
<if test="pageReqVO.createdAt != null">
|
||||||
|
and stp.created_at between #{pageReqVO.createdAt[0]} and #{pageReqVO.createdAt[1]}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by stp.created_at desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectPageWithTenantIdXML"
|
||||||
|
resultType="cn.iocoder.yudao.module.system.controller.admin.tenantpoints.vo.TenantPointsPageRespVO">
|
||||||
|
select stp.*,st.name as tenantName
|
||||||
|
from system_tenant_points stp
|
||||||
|
left join system_tenant st
|
||||||
|
on st.id = stp.tenant_id
|
||||||
|
<where>
|
||||||
|
stp.tenant_id = #{tenantId}
|
||||||
|
|
||||||
|
<if test="pageReqVO.bizNo != null">
|
||||||
|
and stp.biz_no = #{pageReqVO.bizNo}
|
||||||
|
</if>
|
||||||
|
<if test="pageReqVO.remark != null">
|
||||||
|
and stp.remark like concat('%', #{pageReqVO.remark}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="pageReqVO.orderId != null">
|
||||||
|
and stp.operator_id = #{pageReqVO.orderId}
|
||||||
|
</if>
|
||||||
|
<if test="pageReqVO.targetTenantId != null">
|
||||||
|
and stp.target_tenant_id = #{pageReqVO.targetTenantId}
|
||||||
|
</if>
|
||||||
|
<if test="pageReqVO.operatorId != null">
|
||||||
|
and stp.operator_id = #{pageReqVO.operatorId}
|
||||||
|
</if>
|
||||||
|
<if test="pageReqVO.type != null">
|
||||||
|
and stp.type = #{pageReqVO.type}
|
||||||
|
</if>
|
||||||
|
<if test="pageReqVO.createdAt != null">
|
||||||
|
and stp.created_at between #{pageReqVO.createdAt[0]} and #{pageReqVO.createdAt[1]}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by stp.created_at desc
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user