feat(tenant): 新增获取当前登录租户信息接口
This commit is contained in:
@@ -11,6 +11,7 @@ import com.yolo.keyboard.framework.tenant.core.aop.TenantIgnore;
|
|||||||
import com.yolo.keyboard.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO;
|
import com.yolo.keyboard.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO;
|
||||||
import com.yolo.keyboard.module.system.controller.admin.tenant.vo.tenant.TenantRespVO;
|
import com.yolo.keyboard.module.system.controller.admin.tenant.vo.tenant.TenantRespVO;
|
||||||
import com.yolo.keyboard.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO;
|
import com.yolo.keyboard.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO;
|
||||||
|
import com.yolo.keyboard.module.system.controller.admin.tenant.vo.tenant.TenantInfoRespVO;
|
||||||
import com.yolo.keyboard.module.system.dal.dataobject.tenant.TenantDO;
|
import com.yolo.keyboard.module.system.dal.dataobject.tenant.TenantDO;
|
||||||
import com.yolo.keyboard.module.system.service.tenant.TenantService;
|
import com.yolo.keyboard.module.system.service.tenant.TenantService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@@ -113,6 +114,13 @@ public class TenantController {
|
|||||||
return success(BeanUtils.toBean(tenant, TenantRespVO.class));
|
return success(BeanUtils.toBean(tenant, TenantRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/current")
|
||||||
|
@Operation(summary = "获得当前登录租户信息")
|
||||||
|
public CommonResult<TenantInfoRespVO> getCurrentTenant() {
|
||||||
|
TenantDO tenant = tenantService.getCurrentTenant();
|
||||||
|
return success(BeanUtils.toBean(tenant, TenantInfoRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得租户分页")
|
@Operation(summary = "获得租户分页")
|
||||||
@PreAuthorize("@ss.hasPermission('system:tenant:query')")
|
@PreAuthorize("@ss.hasPermission('system:tenant:query')")
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.yolo.keyboard.module.system.controller.admin.tenant.vo.tenant;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 当前租户信息 Response VO")
|
||||||
|
@Data
|
||||||
|
public class TenantInfoRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "租户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "上级租户编号", example = "1")
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
@Schema(description = "代理级别", example = "1")
|
||||||
|
private Integer tenantLevel;
|
||||||
|
|
||||||
|
@Schema(description = "分润比例", example = "0.3")
|
||||||
|
private BigDecimal profitShareRatio;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -142,4 +142,11 @@ public interface TenantService {
|
|||||||
*/
|
*/
|
||||||
void validTenant(Long id);
|
void validTenant(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前登录租户信息
|
||||||
|
*
|
||||||
|
* @return 当前租户
|
||||||
|
*/
|
||||||
|
TenantDO getCurrentTenant();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -352,4 +352,10 @@ public class TenantServiceImpl implements TenantService {
|
|||||||
return tenantProperties == null || Boolean.FALSE.equals(tenantProperties.getEnable());
|
return tenantProperties == null || Boolean.FALSE.equals(tenantProperties.getEnable());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TenantDO getCurrentTenant() {
|
||||||
|
Long tenantId = TenantContextHolder.getRequiredTenantId();
|
||||||
|
return getTenant(tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user