Search in sources :

Example 6 with TenantInfo

use of com.alibaba.nacos.config.server.model.TenantInfo in project nacos by alibaba.

the class NamespaceController method getNamespace.

/**
 * get namespace all info by namespace id.
 *
 * @param namespaceId namespaceId
 * @return namespace all info
 */
@GetMapping(params = "show=all")
public NamespaceAllInfo getNamespace(@RequestParam("namespaceId") String namespaceId) {
    // TODO 获取用kp
    if (StringUtils.isBlank(namespaceId)) {
        return new NamespaceAllInfo(namespaceId, DEFAULT_NAMESPACE_SHOW_NAME, DEFAULT_QUOTA, persistService.configInfoCount(DEFAULT_TENANT), NamespaceTypeEnum.GLOBAL.getType(), DEFAULT_NAMESPACE_DESCRIPTION);
    } else {
        TenantInfo tenantInfo = persistService.findTenantByKp(DEFAULT_KP, namespaceId);
        int configCount = persistService.configInfoCount(namespaceId);
        return new NamespaceAllInfo(namespaceId, tenantInfo.getTenantName(), DEFAULT_QUOTA, configCount, NamespaceTypeEnum.CUSTOM.getType(), tenantInfo.getTenantDesc());
    }
}
Also used : NamespaceAllInfo(com.alibaba.nacos.console.model.NamespaceAllInfo) TenantInfo(com.alibaba.nacos.config.server.model.TenantInfo) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 7 with TenantInfo

use of com.alibaba.nacos.config.server.model.TenantInfo in project nacos by alibaba.

the class NamespaceController method getNamespaces.

/**
 * Get namespace list.
 *
 * @return namespace list
 */
@GetMapping
public RestResult<List<Namespace>> getNamespaces() {
    // TODO 获取用kp
    List<TenantInfo> tenantInfos = persistService.findTenantByKp(DEFAULT_KP);
    Namespace namespace0 = new Namespace("", DEFAULT_NAMESPACE, DEFAULT_QUOTA, persistService.configInfoCount(DEFAULT_TENANT), NamespaceTypeEnum.GLOBAL.getType());
    List<Namespace> namespaces = new ArrayList<>();
    namespaces.add(namespace0);
    for (TenantInfo tenantInfo : tenantInfos) {
        int configCount = persistService.configInfoCount(tenantInfo.getTenantId());
        Namespace namespaceTmp = new Namespace(tenantInfo.getTenantId(), tenantInfo.getTenantName(), DEFAULT_QUOTA, configCount, NamespaceTypeEnum.CUSTOM.getType());
        namespaces.add(namespaceTmp);
    }
    return RestResultUtils.success(namespaces);
}
Also used : ArrayList(java.util.ArrayList) TenantInfo(com.alibaba.nacos.config.server.model.TenantInfo) Namespace(com.alibaba.nacos.console.model.Namespace) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 8 with TenantInfo

use of com.alibaba.nacos.config.server.model.TenantInfo in project XHuiCloud by sindaZeng.

the class NamespaceController method getNamespaces.

/**
 * Get namespace list.
 * @param request request
 * @param response response
 * @return namespace list
 */
@GetMapping
public RestResult<List<Namespace>> getNamespaces(HttpServletRequest request, HttpServletResponse response) {
    // TODO 获取用kp
    List<TenantInfo> tenantInfos = persistService.findTenantByKp(DEFAULT_KP);
    Namespace namespace0 = new Namespace("", DEFAULT_NAMESPACE, DEFAULT_QUOTA, persistService.configInfoCount(DEFAULT_TENANT), NamespaceTypeEnum.GLOBAL.getType());
    List<Namespace> namespaces = new ArrayList<Namespace>();
    namespaces.add(namespace0);
    for (TenantInfo tenantInfo : tenantInfos) {
        int configCount = persistService.configInfoCount(tenantInfo.getTenantId());
        Namespace namespaceTmp = new Namespace(tenantInfo.getTenantId(), tenantInfo.getTenantName(), DEFAULT_QUOTA, configCount, NamespaceTypeEnum.CUSTOM.getType());
        namespaces.add(namespaceTmp);
    }
    return RestResultUtils.success(namespaces);
}
Also used : ArrayList(java.util.ArrayList) TenantInfo(com.alibaba.nacos.config.server.model.TenantInfo) Namespace(com.alibaba.nacos.model.Namespace)

Aggregations

TenantInfo (com.alibaba.nacos.config.server.model.TenantInfo)8 GetMapping (org.springframework.web.bind.annotation.GetMapping)6 ArrayList (java.util.ArrayList)4 Namespace (com.alibaba.nacos.console.model.Namespace)3 NamespaceAllInfo (com.alibaba.nacos.console.model.NamespaceAllInfo)3 Namespace (com.alibaba.nacos.model.Namespace)1 NamespaceAllInfo (com.alibaba.nacos.model.NamespaceAllInfo)1