feat(system): 新增代理租户查询下属租户分页接口
This commit is contained in:
@@ -124,4 +124,16 @@ public class TenantController {
|
||||
BeanUtils.toBean(list, TenantRespVO.class));
|
||||
}
|
||||
|
||||
|
||||
// 以下是控制代理租户的租户查询
|
||||
// ----------------------------------------------------------------------------------
|
||||
|
||||
@GetMapping("/page_self")
|
||||
@Operation(summary = "代理获得自己下属租户分页")
|
||||
@PreAuthorize("@ss.hasPermission('system:tenant:query-self')")
|
||||
public CommonResult<PageResult<TenantRespVO>> getSelfTenantPage(@Valid TenantPageReqVO pageVO) {
|
||||
PageResult<TenantDO> pageResult = tenantService.getSelfTenantPage(pageVO);
|
||||
return success(BeanUtils.toBean(pageResult, TenantRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,4 +47,7 @@ public class TenantPageReqVO extends PageParam {
|
||||
|
||||
@Schema
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "父租户Id")
|
||||
private Long parentId;
|
||||
}
|
||||
|
||||
@@ -64,4 +64,6 @@ public class TenantRespVO {
|
||||
@Schema(description = "备注", example = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "上级租户 Id", example = "1024")
|
||||
private Long parentId;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,17 @@ public class TenantDO extends BaseDO {
|
||||
/**
|
||||
* 账号数量
|
||||
*/
|
||||
|
||||
private Integer accountCount;
|
||||
|
||||
/**
|
||||
* 上级租户 Id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
||||
private String remark;
|
||||
}
|
||||
|
||||
@@ -63,4 +63,18 @@ public interface TenantMapper extends BaseMapperX<TenantDO> {
|
||||
}
|
||||
|
||||
|
||||
default PageResult<TenantDO> selectSelfPage(TenantPageReqVO reqVO){
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<TenantDO>()
|
||||
.eq(TenantDO::getParentId, reqVO.getParentId())
|
||||
.likeIfPresent(TenantDO::getName, reqVO.getName())
|
||||
.likeIfPresent(TenantDO::getContactName, reqVO.getContactName())
|
||||
.likeIfPresent(TenantDO::getContactMobile, reqVO.getContactMobile())
|
||||
.eqIfPresent(TenantDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(TenantDO::getCreateTime, reqVO.getCreateTime())
|
||||
.betweenIfPresent(TenantDO::getAiExpireTime, reqVO.getAiExpireTime())
|
||||
.betweenIfPresent(TenantDO::getExpireTime, reqVO.getExpireTime())
|
||||
.betweenIfPresent(TenantDO::getBrotherExpireTime, reqVO.getBrotherExpireTime())
|
||||
.likeIfPresent(TenantDO::getRemark, reqVO.getRemark())
|
||||
.orderByDesc(TenantDO::getId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,4 +135,5 @@ public interface TenantService {
|
||||
*/
|
||||
void validTenant(Long id);
|
||||
|
||||
PageResult<TenantDO> getSelfTenantPage(@Valid TenantPageReqVO pageVO);
|
||||
}
|
||||
|
||||
@@ -95,6 +95,13 @@ public class TenantServiceImpl implements TenantService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<TenantDO> getSelfTenantPage(TenantPageReqVO pageVO) {
|
||||
Long tenantId = TenantContextHolder.getTenantId();
|
||||
pageVO.setParentId(tenantId);
|
||||
return tenantMapper.selectSelfPage(pageVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换
|
||||
@DataPermission(enable = false) // 参见 https://gitee.com/zhijiantianya/ruoyi-vue-pro/pulls/1154 说明
|
||||
@@ -108,6 +115,8 @@ public class TenantServiceImpl implements TenantService {
|
||||
|
||||
// 创建租户
|
||||
TenantDO tenant = BeanUtils.toBean(createReqVO, TenantDO.class);
|
||||
Long tenantId = TenantContextHolder.getTenantId();
|
||||
tenant.setParentId(tenantId);
|
||||
tenantMapper.insert(tenant);
|
||||
// 创建租户的管理员
|
||||
TenantUtils.execute(tenant.getId(), () -> {
|
||||
|
||||
Reference in New Issue
Block a user