feat(REQ-2186): 查询租户产品信息
This commit is contained in:
parent
b10219a962
commit
fd2866cc77
@ -13,6 +13,7 @@ import cn.axzo.tyr.client.model.product.ProductVO;
|
||||
import cn.axzo.tyr.client.model.req.ProductSaveReq;
|
||||
import cn.axzo.tyr.client.model.req.UpdateProductStatusReq;
|
||||
import cn.axzo.tyr.client.model.res.ChiefTerminalResp;
|
||||
import cn.axzo.tyr.client.model.res.WorkspaceProductResp;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
@ -145,4 +146,13 @@ public interface ProductApi {
|
||||
*/
|
||||
@GetMapping("api/auth/product/getChiefTerminal")
|
||||
ApiResult<List<ChiefTerminalResp>> getChiefTerminal(@RequestParam @NotNull(message = "terminal不能为空") String terminal);
|
||||
|
||||
/**
|
||||
* 根据租户类型查询产品信息(新增租户、开通管理)
|
||||
*
|
||||
* @param workspaceType 租户类型
|
||||
* @return 租户产品信息
|
||||
*/
|
||||
@GetMapping("api/auth/product/getWorkspaceProduct")
|
||||
ApiResult<WorkspaceProductResp> getWorkspaceProduct(@RequestParam @NotNull(message = "workspaceType不能为空") String workspaceType);
|
||||
}
|
||||
|
||||
@ -2,10 +2,12 @@ package cn.axzo.tyr.client.model.enums;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.EnumValue;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
@ -57,4 +59,6 @@ public enum ProductModuleCategoryEnum {
|
||||
public static String getDescByCode(String code) {
|
||||
return Optional.ofNullable(getByCode(code)).map(ProductModuleCategoryEnum::getDesc).orElse(null);
|
||||
}
|
||||
|
||||
public static List<String> ALL_CATEGORY_CODE = Lists.newArrayList(PRODUCT_VERSION.getCode(), ADD_VALUE_SERVICE.getCode(), GENERAL_SERVICE.getCode(), HARD_WARE.getCode());
|
||||
}
|
||||
|
||||
@ -0,0 +1,83 @@
|
||||
package cn.axzo.tyr.client.model.res;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author likunpeng
|
||||
* @version 1.0
|
||||
* @date 2024/4/28
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WorkspaceProductResp {
|
||||
|
||||
/**
|
||||
* 产品版本产品
|
||||
*/
|
||||
private List<Product> productVersions;
|
||||
|
||||
/**
|
||||
* 增值服务产品
|
||||
*/
|
||||
private List<Product> addValueServices;
|
||||
|
||||
/**
|
||||
* 通用服务产品
|
||||
*/
|
||||
private List<Product> generalServices;
|
||||
|
||||
/**
|
||||
* 硬件服务产品
|
||||
*/
|
||||
private List<Product> hardware;
|
||||
|
||||
/**
|
||||
* 政务产品
|
||||
*/
|
||||
private List<Product> chiefProduct;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class Product {
|
||||
|
||||
/**
|
||||
* 产品ID
|
||||
*/
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* 产品名称
|
||||
*/
|
||||
private String productName;
|
||||
|
||||
/**
|
||||
* 人数上限 <企业、项目产品>
|
||||
*/
|
||||
private Integer maxPersonCount;
|
||||
|
||||
/**
|
||||
* 最大项目数 <企业产品>
|
||||
*/
|
||||
private Integer maxWorkspaceCount;
|
||||
}
|
||||
|
||||
public static WorkspaceProductResp init() {
|
||||
return WorkspaceProductResp.builder()
|
||||
.productVersions(Lists.newArrayList())
|
||||
.addValueServices(Lists.newArrayList())
|
||||
.generalServices(Lists.newArrayList())
|
||||
.hardware(Lists.newArrayList())
|
||||
.chiefProduct(Lists.newArrayList())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@ -14,6 +14,7 @@ import cn.axzo.tyr.client.model.product.ProductVO;
|
||||
import cn.axzo.tyr.client.model.req.ProductSaveReq;
|
||||
import cn.axzo.tyr.client.model.req.UpdateProductStatusReq;
|
||||
import cn.axzo.tyr.client.model.res.ChiefTerminalResp;
|
||||
import cn.axzo.tyr.client.model.res.WorkspaceProductResp;
|
||||
import cn.axzo.tyr.server.model.PermissionCacheKey;
|
||||
import cn.axzo.tyr.server.service.PermissionCacheService;
|
||||
import cn.axzo.tyr.server.service.ProductFeatureRelationService;
|
||||
@ -171,4 +172,15 @@ public class ProductController implements ProductApi {
|
||||
public ApiResult<List<ChiefTerminalResp>> getChiefTerminal(String terminal) {
|
||||
return productService.getChiefTerminal(terminal);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据租户类型查询产品信息(新增租户、开通管理)
|
||||
*
|
||||
* @param workspaceType 租户类型
|
||||
* @return 租户产品信息
|
||||
*/
|
||||
@Override
|
||||
public ApiResult<WorkspaceProductResp> getWorkspaceProduct(String workspaceType) {
|
||||
return productService.getWorkspaceProduct(workspaceType);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ import cn.axzo.tyr.client.model.product.ProductVO;
|
||||
import cn.axzo.tyr.client.model.req.ProductSaveReq;
|
||||
import cn.axzo.tyr.client.model.req.UpdateProductStatusReq;
|
||||
import cn.axzo.tyr.client.model.res.ChiefTerminalResp;
|
||||
import cn.axzo.tyr.client.model.res.WorkspaceProductResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -38,4 +39,6 @@ public interface ProductService {
|
||||
ApiResult<Long> saveOrUpdate(ProductSaveReq req);
|
||||
|
||||
ApiResult<List<ChiefTerminalResp>> getChiefTerminal(String terminal);
|
||||
|
||||
ApiResult<WorkspaceProductResp> getWorkspaceProduct(String workspaceType);
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ import cn.axzo.tyr.client.model.product.*;
|
||||
import cn.axzo.tyr.client.model.req.ProductSaveReq;
|
||||
import cn.axzo.tyr.client.model.req.UpdateProductStatusReq;
|
||||
import cn.axzo.tyr.client.model.res.ChiefTerminalResp;
|
||||
import cn.axzo.tyr.client.model.res.WorkspaceProductResp;
|
||||
import cn.axzo.tyr.server.repository.entity.ProductModule;
|
||||
import cn.axzo.tyr.server.repository.dao.ProductModuleDao;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasFeatureResource;
|
||||
@ -229,6 +230,65 @@ public class ProductServiceImpl implements ProductService {
|
||||
return ApiResult.ok(resps);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<WorkspaceProductResp> getWorkspaceProduct(String workspaceType) {
|
||||
List<ProductModule> productModules = productModuleDao.lambdaQuery()
|
||||
.eq(ProductModule::getStatus, 1)
|
||||
.eq(Objects.nonNull(workspaceType), ProductModule::getDictWorkspaceTypeCode, workspaceType)
|
||||
.in(ProductModule::getCategory, ProductModuleCategoryEnum.ALL_CATEGORY_CODE)
|
||||
.list();
|
||||
if (CollectionUtil.isEmpty(productModules)) {
|
||||
return ApiResult.ok(WorkspaceProductResp.builder().build());
|
||||
}
|
||||
|
||||
WorkspaceProductResp resp = WorkspaceProductResp.init();
|
||||
Map<String, List<ProductModule>> categoryMap = productModules.stream().collect(Collectors.groupingBy(ProductModule::getCategory));
|
||||
categoryMap.forEach((k,v) -> {
|
||||
// 政务产品
|
||||
if (WorkspaceTypeCodeEnum.CHIEF.getCode().equals(workspaceType)) {
|
||||
resp.getChiefProduct().addAll(v.stream().map(e -> WorkspaceProductResp.Product.builder()
|
||||
.productId(e.getId())
|
||||
.productName(e.getProductName())
|
||||
.build()).collect(Collectors.toList()));
|
||||
} else {
|
||||
if (ProductModuleCategoryEnum.PRODUCT_VERSION.getCode().equals(k)) {
|
||||
resp.getProductVersions().addAll(v.stream().map(e -> WorkspaceProductResp.Product.builder()
|
||||
.productId(e.getId())
|
||||
.productName(e.getProductName())
|
||||
.maxPersonCount(e.getMaxPersonCount())
|
||||
.maxWorkspaceCount(e.getMaxWorkspaceCount())
|
||||
.build()).collect(Collectors.toList()));
|
||||
}
|
||||
if (ProductModuleCategoryEnum.ADD_VALUE_SERVICE.getCode().equals(k)) {
|
||||
resp.getAddValueServices().addAll(v.stream().map(e -> WorkspaceProductResp.Product.builder()
|
||||
.productId(e.getId())
|
||||
.productName(e.getProductName())
|
||||
.maxPersonCount(e.getMaxPersonCount())
|
||||
.maxWorkspaceCount(e.getMaxWorkspaceCount())
|
||||
.build()).collect(Collectors.toList()));
|
||||
}
|
||||
if (ProductModuleCategoryEnum.GENERAL_SERVICE.getCode().equals(k)) {
|
||||
resp.getGeneralServices().addAll(v.stream().map(e -> WorkspaceProductResp.Product.builder()
|
||||
.productId(e.getId())
|
||||
.productName(e.getProductName())
|
||||
.maxPersonCount(e.getMaxPersonCount())
|
||||
.maxWorkspaceCount(e.getMaxWorkspaceCount())
|
||||
.build()).collect(Collectors.toList()));
|
||||
}
|
||||
if (ProductModuleCategoryEnum.HARD_WARE.getCode().equals(k)) {
|
||||
resp.getHardware().addAll(v.stream().map(e -> WorkspaceProductResp.Product.builder()
|
||||
.productId(e.getId())
|
||||
.productName(e.getProductName())
|
||||
.maxPersonCount(e.getMaxPersonCount())
|
||||
.maxWorkspaceCount(e.getMaxWorkspaceCount())
|
||||
.build()).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return ApiResult.ok(resp);
|
||||
}
|
||||
|
||||
private void validAndFillEntity(ProductSaveReq req, ProductModule productModule) {
|
||||
BasicDictNodeResp basicDictNodeResp = saasBasicDictService.getById(req.getDictWorkspaceTypeId());
|
||||
AssertUtil.notNull(basicDictNodeResp, "租户类型有误");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user