feat(tenant-balance): 实现查询下级租户余额分页接口
This commit is contained in:
@@ -52,5 +52,11 @@
|
|||||||
<version>2025.11-SNAPSHOT</version>
|
<version>2025.11-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.yolo</groupId>
|
||||||
|
<artifactId>yolo-module-system</artifactId>
|
||||||
|
<version>2025.11-SNAPSHOT</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.yolo.keyboard.service.tenantbalance;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.yolo.keyboard.dal.dataobject.tenantbalancetransaction.TenantBalanceTransactionDO;
|
import com.yolo.keyboard.dal.dataobject.tenantbalancetransaction.TenantBalanceTransactionDO;
|
||||||
import com.yolo.keyboard.dal.mysql.tenantbalancetransaction.TenantBalanceTransactionMapper;
|
import com.yolo.keyboard.dal.mysql.tenantbalancetransaction.TenantBalanceTransactionMapper;
|
||||||
|
import com.yolo.keyboard.framework.common.util.collection.CollectionUtils;
|
||||||
|
import com.yolo.keyboard.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import com.yolo.keyboard.framework.tenant.core.context.TenantContextHolder;
|
import com.yolo.keyboard.framework.tenant.core.context.TenantContextHolder;
|
||||||
import com.yolo.keyboard.utils.BizNoGenerator;
|
import com.yolo.keyboard.utils.BizNoGenerator;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -19,6 +21,8 @@ import com.yolo.keyboard.framework.common.pojo.PageParam;
|
|||||||
import com.yolo.keyboard.framework.common.util.object.BeanUtils;
|
import com.yolo.keyboard.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
import com.yolo.keyboard.dal.mysql.tenantbalance.TenantBalanceMapper;
|
import com.yolo.keyboard.dal.mysql.tenantbalance.TenantBalanceMapper;
|
||||||
|
import com.yolo.keyboard.module.system.dal.dataobject.tenant.TenantDO;
|
||||||
|
import com.yolo.keyboard.module.system.dal.mysql.tenant.TenantMapper;
|
||||||
|
|
||||||
import static com.yolo.keyboard.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.yolo.keyboard.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static com.yolo.keyboard.framework.common.util.collection.CollectionUtils.convertList;
|
import static com.yolo.keyboard.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
@@ -40,6 +44,9 @@ public class TenantBalanceServiceImpl implements TenantBalanceService {
|
|||||||
@Resource
|
@Resource
|
||||||
private TenantBalanceTransactionMapper tenantBalanceTransactionMapper;
|
private TenantBalanceTransactionMapper tenantBalanceTransactionMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TenantMapper tenantMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createTenantBalance(TenantBalanceSaveReqVO createReqVO) {
|
public Long createTenantBalance(TenantBalanceSaveReqVO createReqVO) {
|
||||||
// 插入
|
// 插入
|
||||||
@@ -125,12 +132,32 @@ public class TenantBalanceServiceImpl implements TenantBalanceService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TenantBalanceDO getSelfBalance() {
|
public TenantBalanceDO getSelfBalance() {
|
||||||
return null;
|
Long tenantId = TenantContextHolder.getRequiredTenantId();
|
||||||
|
return tenantBalanceMapper.selectById(tenantId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<TenantBalanceRespVO> getSelfSubordinateTenantBalancePage(TenantBalancePageReqVO pageReqVO) {
|
public PageResult<TenantBalanceRespVO> getSelfSubordinateTenantBalancePage(TenantBalancePageReqVO pageReqVO) {
|
||||||
return null;
|
// 1. 获取当前租户ID
|
||||||
|
Long currentTenantId = TenantContextHolder.getRequiredTenantId();
|
||||||
|
|
||||||
|
// 2. 查询当前租户的下级租户列表
|
||||||
|
List<TenantDO> subordinateTenants = tenantMapper.selectList(TenantDO::getParentId, currentTenantId);
|
||||||
|
|
||||||
|
// 3. 提取下级租户的ID列表
|
||||||
|
List<Long> tenantIds = CollectionUtils.convertList(subordinateTenants, TenantDO::getId);
|
||||||
|
|
||||||
|
// 4. 如果没有下级租户,则直接返回空的分页结果
|
||||||
|
if (CollUtil.isEmpty(tenantIds)) {
|
||||||
|
return PageResult.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. 根据下级租户ID列表查询对应的余额信息,并进行分页
|
||||||
|
PageResult<TenantBalanceDO> pageResult = tenantBalanceMapper.selectPage(pageReqVO,
|
||||||
|
new LambdaQueryWrapperX<TenantBalanceDO>().in(TenantBalanceDO::getId, tenantIds));
|
||||||
|
|
||||||
|
// 6. 将查询结果转换为响应VO并返回
|
||||||
|
return BeanUtils.toBean(pageResult, TenantBalanceRespVO.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user