feat(REQ-2545): 产品管理相关接口修改
This commit is contained in:
parent
bdddb409be
commit
58362775ae
@ -2,14 +2,7 @@ package cn.axzo.tyr.client.feign;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiPageResult;
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.model.product.ProductAddReq;
|
||||
import cn.axzo.tyr.client.model.product.ProductFeatureRelationSearchReq;
|
||||
import cn.axzo.tyr.client.model.product.ProductFeatureRelationUpdateReq;
|
||||
import cn.axzo.tyr.client.model.product.ProductFeatureRelationVO;
|
||||
import cn.axzo.tyr.client.model.product.ProductSearchListReq;
|
||||
import cn.axzo.tyr.client.model.product.ProductSearchPageReq;
|
||||
import cn.axzo.tyr.client.model.product.ProductUpdateReq;
|
||||
import cn.axzo.tyr.client.model.product.ProductVO;
|
||||
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.GovernmentTerminalResp;
|
||||
@ -155,4 +148,10 @@ public interface ProductApi {
|
||||
*/
|
||||
@GetMapping("api/auth/product/getWorkspaceProduct")
|
||||
ApiResult<WorkspaceProductResp> getWorkspaceProduct(@RequestParam @NotNull(message = "workspaceType不能为空") String workspaceType);
|
||||
|
||||
/**
|
||||
* 获取指定ID的产品详细信息
|
||||
*/
|
||||
@PostMapping("api/auth/product/getDetail")
|
||||
ApiResult<ProductVO> getDetail(@Validated @RequestBody ProductDetailReq req);
|
||||
}
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
package cn.axzo.tyr.client.model.product;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author likunpeng
|
||||
* @version 1.0
|
||||
* @date 2024/6/20
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ProductDetailReq {
|
||||
|
||||
/**
|
||||
* 产品ID
|
||||
*/
|
||||
@NotNull(message = "产品ID不能为空")
|
||||
@Min(value = 1, message = "")
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* 是否查询功能权限点
|
||||
*/
|
||||
@Builder.Default
|
||||
private Boolean queryFeatureScope = Boolean.FALSE;
|
||||
}
|
||||
@ -40,4 +40,9 @@ public class ProductFeatureRelationVO {
|
||||
* 权限点 ID
|
||||
*/
|
||||
private Long featureId;
|
||||
|
||||
/**
|
||||
* 关联类型(0:saas_feature,1:saas_feature_resource)
|
||||
*/
|
||||
private Integer type;
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 产品模型
|
||||
@ -144,6 +145,16 @@ public class ProductVO {
|
||||
*/
|
||||
private List<FeatureScope> featureScopes;
|
||||
|
||||
/**
|
||||
* 新老产品标记,前端确认查询权限树的接口。0:旧权限,1:新权限树
|
||||
*/
|
||||
private Integer relationType;
|
||||
|
||||
/**
|
||||
* 功能范围(非政务产品)
|
||||
*/
|
||||
private List<ProductFeatureRelation> relations;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@ -209,4 +220,26 @@ public class ProductVO {
|
||||
*/
|
||||
private String featureResourceName;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class ProductFeatureRelation {
|
||||
|
||||
/**
|
||||
* 单位类型
|
||||
*/
|
||||
private Long dictCodeId;
|
||||
|
||||
/**
|
||||
* 总数
|
||||
*/
|
||||
private Integer totalCount;
|
||||
|
||||
/**
|
||||
* 勾选的最末级 feature 的 ID 集合
|
||||
*/
|
||||
private List<Long> featureIds;
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author likunpeng
|
||||
@ -163,5 +164,26 @@ public class ProductSaveReq {
|
||||
* 政务端featureResourceId
|
||||
*/
|
||||
private List<Long> governmentFeatureResourceIds;
|
||||
|
||||
/**
|
||||
* 产品与功能点的关联关系
|
||||
*/
|
||||
private List<ProductFeatureRelation> relations;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class ProductFeatureRelation {
|
||||
/**
|
||||
* 单位类型
|
||||
*/
|
||||
private Long dictCodeId;
|
||||
|
||||
/**
|
||||
* 勾选的最末级 feature 的 ID 集合
|
||||
*/
|
||||
private Set<Long> featureIds;
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,6 +307,7 @@ public class PrivateController {
|
||||
return tyrSaasAuthService.authPermission(request);
|
||||
}
|
||||
|
||||
/** 刷新表saas_pgroup_permission_relation的type字段 **/
|
||||
@PostMapping("/api/private/pgroupPermissionRelation/refresh")
|
||||
public ApiResult<Void> refreshPgroupPermissionRelation(@Validated @RequestBody RefreshPgroupPermissionRelationParam request) {
|
||||
List<Integer> workspaceTypes = Lists.newArrayList(3,6);
|
||||
|
||||
@ -3,14 +3,7 @@ package cn.axzo.tyr.server.controller.product;
|
||||
import cn.axzo.framework.domain.web.result.ApiPageResult;
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.feign.ProductApi;
|
||||
import cn.axzo.tyr.client.model.product.ProductAddReq;
|
||||
import cn.axzo.tyr.client.model.product.ProductFeatureRelationSearchReq;
|
||||
import cn.axzo.tyr.client.model.product.ProductFeatureRelationUpdateReq;
|
||||
import cn.axzo.tyr.client.model.product.ProductFeatureRelationVO;
|
||||
import cn.axzo.tyr.client.model.product.ProductSearchListReq;
|
||||
import cn.axzo.tyr.client.model.product.ProductSearchPageReq;
|
||||
import cn.axzo.tyr.client.model.product.ProductUpdateReq;
|
||||
import cn.axzo.tyr.client.model.product.ProductVO;
|
||||
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.GovernmentTerminalResp;
|
||||
@ -72,7 +65,7 @@ public class ProductController implements ProductApi {
|
||||
*/
|
||||
@Override
|
||||
public ApiResult<ProductVO> getById(Long id) {
|
||||
return productService.getById(id);
|
||||
return productService.getById(id, Boolean.FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -159,6 +152,7 @@ public class ProductController implements ProductApi {
|
||||
*/
|
||||
@Override
|
||||
public ApiResult<Long> saveOrUpdate(ProductSaveReq req) {
|
||||
permissionCacheService.markTempDisable(PermissionCacheKey.builder().disableAll(true).build());
|
||||
return productService.saveOrUpdate(req);
|
||||
}
|
||||
|
||||
@ -183,4 +177,9 @@ public class ProductController implements ProductApi {
|
||||
public ApiResult<WorkspaceProductResp> getWorkspaceProduct(String workspaceType) {
|
||||
return productService.getWorkspaceProduct(workspaceType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<ProductVO> getDetail(ProductDetailReq req) {
|
||||
return productService.getById(req.getProductId(), req.getQueryFeatureScope());
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ import cn.axzo.tyr.server.repository.mapper.SaasBasicDictMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@ -33,7 +34,8 @@ public class SaasBasicDictDao extends ServiceImpl<SaasBasicDictMapper, SaasBasic
|
||||
queryChainWrapper.eq(Objects.nonNull(req.getParentId()), SaasBasicDict::getParentId, req.getParentId())
|
||||
.eq(Objects.nonNull(req.getWorkspaceType()), SaasBasicDict::getWorkspaceType, req.getWorkspaceType())
|
||||
.eq(Objects.nonNull(req.getType()), SaasBasicDict::getType, req.getType())
|
||||
.in(Objects.nonNull(req.getCodes()), SaasBasicDict::getCode, req.getCodes())
|
||||
.in(CollectionUtils.isNotEmpty(req.getCodes()), SaasBasicDict::getCode, req.getCodes())
|
||||
.in(CollectionUtils.isNotEmpty(req.getIds()), SaasBasicDict::getId, req.getIds())
|
||||
.eq(Objects.nonNull(req.getStatus()), SaasBasicDict::getStatus, req.getStatus())
|
||||
.eq(Objects.nonNull(req.getLevel()), SaasBasicDict::getLevel, req.getLevel())
|
||||
.like(Objects.nonNull(req.getName()), SaasBasicDict::getName, req.getName());
|
||||
|
||||
@ -47,6 +47,17 @@ public class SaasProductModuleFeatureRelation extends BaseEntity<SaasProductModu
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 功能资源类型 默认为0
|
||||
* @see cn.axzo.tyr.client.common.enums.FeatureResourceType
|
||||
*/
|
||||
private Integer featureType;
|
||||
|
||||
/**
|
||||
* 端
|
||||
*/
|
||||
private String terminal;
|
||||
|
||||
|
||||
/**
|
||||
* 获取主键值
|
||||
|
||||
@ -22,6 +22,8 @@ public interface ProductFeatureRelationService {
|
||||
|
||||
ApiResult<Boolean> updateFeatureRelation(List<ProductFeatureRelationUpdateReq> req);
|
||||
|
||||
void updateFeatureResourceRelation(List<ProductFeatureRelationUpdateReq> req);
|
||||
|
||||
ApiResult<List<ProductFeatureRelationVO>> featureListByProduct(List<Long> productIds);
|
||||
|
||||
/**
|
||||
@ -37,4 +39,12 @@ public interface ProductFeatureRelationService {
|
||||
boolean refreshFeature(Integer workspaceType, Long productId);
|
||||
|
||||
void removeByProductId(Long productId);
|
||||
|
||||
/**
|
||||
* 新增、编辑产品时做新老产品判断时使用
|
||||
*
|
||||
* @param productId
|
||||
* @return
|
||||
*/
|
||||
SaasProductModuleFeatureRelation getOneByProductId(Long productId);
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ public interface ProductService {
|
||||
|
||||
ApiPageResult<ProductVO> page(ProductSearchPageReq req);
|
||||
|
||||
ApiResult<ProductVO> getById(Long id);
|
||||
ApiResult<ProductVO> getById(Long id, Boolean queryFeatureScope);
|
||||
|
||||
ApiResult<ProductVO> add(ProductAddReq req);
|
||||
|
||||
|
||||
@ -14,8 +14,10 @@ import cn.axzo.tyr.client.model.product.ProductFeatureRelationUpdateReq;
|
||||
import cn.axzo.tyr.client.model.product.ProductFeatureRelationVO;
|
||||
import cn.axzo.tyr.server.repository.dao.ProductModuleDao;
|
||||
import cn.axzo.tyr.server.repository.dao.SaasFeatureDao;
|
||||
import cn.axzo.tyr.server.repository.dao.SaasFeatureResourceDao;
|
||||
import cn.axzo.tyr.server.repository.entity.ProductFeatureQuery;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasFeature;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasFeatureResource;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasProductModuleFeatureRelation;
|
||||
import cn.axzo.tyr.server.repository.dao.SaasProductModuleFeatureRelationDao;
|
||||
import cn.axzo.tyr.server.service.ProductFeatureRelationService;
|
||||
@ -64,7 +66,8 @@ public class ProductFeatureRelationServiceImpl implements ProductFeatureRelation
|
||||
private final SaasProductModuleFeatureRelationDao saasProductModuleFeatureRelationDao;
|
||||
private final ServicePkgClient servicePkgClient;
|
||||
private final SaasFeatureDao saasFeatureDao;
|
||||
private final ProductModuleDao productModuleDao;
|
||||
private final ProductModuleDao productModuleDao;
|
||||
private final SaasFeatureResourceDao saasFeatureResourceDao;
|
||||
|
||||
@Override
|
||||
public ApiResult<List<ProductFeatureRelationVO>> featureList(ProductFeatureRelationSearchReq req) {
|
||||
@ -98,6 +101,43 @@ public class ProductFeatureRelationServiceImpl implements ProductFeatureRelation
|
||||
return ApiResult.ok(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateFeatureResourceRelation(List<ProductFeatureRelationUpdateReq> req) {
|
||||
List<Long> productIds = req.stream().map(ProductFeatureRelationUpdateReq::getProductModuleId).distinct().collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(productIds)) {
|
||||
saasProductModuleFeatureRelationDao.remove(new LambdaQueryWrapper<SaasProductModuleFeatureRelation>()
|
||||
.in(SaasProductModuleFeatureRelation::getProductModuleId, productIds));
|
||||
}
|
||||
|
||||
Set<Long> allFeatureResourceIds = req.stream().map(ProductFeatureRelationUpdateReq::getFeatureIds)
|
||||
.filter(CollectionUtil::isNotEmpty).flatMap(List::stream).collect(Collectors.toSet());
|
||||
if (CollectionUtil.isEmpty(allFeatureResourceIds)) {
|
||||
log.warn("product has no featureResourceIds to bind.");
|
||||
return;
|
||||
}
|
||||
Map<Long, SaasFeatureResource> resourceMap = saasFeatureResourceDao.lambdaQuery()
|
||||
.in(BaseEntity::getId, allFeatureResourceIds)
|
||||
.list().stream().collect(Collectors.toMap(BaseEntity::getId, Function.identity(), (v1, v2) -> v1));
|
||||
|
||||
List<SaasProductModuleFeatureRelation> saveList = new ArrayList<>();
|
||||
req.forEach(i -> i.getFeatureIds().forEach(featureId -> {
|
||||
SaasFeatureResource saasFeatureResource = resourceMap.get(featureId);
|
||||
SaasProductModuleFeatureRelation relation = new SaasProductModuleFeatureRelation();
|
||||
relation.setProductModuleId(i.getProductModuleId());
|
||||
relation.setDictCodeId(i.getDictCodeId());
|
||||
relation.setDictCode(i.getDictCode());
|
||||
relation.setFeatureId(featureId);
|
||||
relation.setType(Objects.isNull(i.getFeatureRelationType()) ? 0 : i.getFeatureRelationType());
|
||||
if (Objects.nonNull(saasFeatureResource)) {
|
||||
relation.setFeatureType(saasFeatureResource.getFeatureType());
|
||||
relation.setTerminal(saasFeatureResource.getTerminal());
|
||||
}
|
||||
saveList.add(relation);
|
||||
}));
|
||||
saasProductModuleFeatureRelationDao.saveBatch(saveList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<List<ProductFeatureRelationVO>> featureListByProduct(List<Long> productIds) {
|
||||
if (CollectionUtil.isEmpty(productIds)) {
|
||||
@ -235,4 +275,14 @@ public class ProductFeatureRelationServiceImpl implements ProductFeatureRelation
|
||||
public void removeByProductId(Long productId) {
|
||||
saasProductModuleFeatureRelationDao.removeByProductId(Collections.singletonList(productId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SaasProductModuleFeatureRelation getOneByProductId(Long productId) {
|
||||
List<SaasProductModuleFeatureRelation> list = saasProductModuleFeatureRelationDao.lambdaQuery()
|
||||
.eq(SaasProductModuleFeatureRelation::getProductModuleId, productId)
|
||||
.orderByDesc(BaseEntity::getId)
|
||||
.last("LIMIT 1")
|
||||
.list();
|
||||
return org.apache.commons.collections4.CollectionUtils.isEmpty(list) ? null : list.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import cn.axzo.framework.domain.web.result.ApiPageResult;
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.pokonyan.config.mybatisplus.BaseEntity;
|
||||
import cn.axzo.tyr.client.common.enums.ProductModuleFeatureRelationTypeEnum;
|
||||
import cn.axzo.tyr.client.model.dict.request.BasicDictQueryReq;
|
||||
import cn.axzo.tyr.client.model.dict.response.BasicDictNodeResp;
|
||||
import cn.axzo.tyr.client.model.enums.ProductModuleCategoryEnum;
|
||||
import cn.axzo.tyr.client.model.enums.WorkspaceTypeCodeEnum;
|
||||
@ -19,6 +20,7 @@ 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;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasProductModuleFeatureRelation;
|
||||
import cn.axzo.tyr.server.service.ProductFeatureRelationService;
|
||||
import cn.axzo.tyr.server.service.ProductService;
|
||||
import cn.axzo.tyr.server.service.SaasBasicDictService;
|
||||
@ -27,16 +29,17 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -65,7 +68,7 @@ public class ProductServiceImpl implements ProductService {
|
||||
.eq(Objects.nonNull(req.getAuthType()),ProductModule::getAuthType,req.getAuthType())
|
||||
.eq(ProductModule::getIsDelete, 0);
|
||||
StringBuilder condition = new StringBuilder();
|
||||
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(req.getOuTypes())) {
|
||||
if (CollectionUtils.isNotEmpty(req.getOuTypes())) {
|
||||
condition = new StringBuilder();
|
||||
for (Integer value : req.getOuTypes()) {
|
||||
condition.append(" FIND_IN_SET('" + value + "', ou_type) OR");
|
||||
@ -104,13 +107,13 @@ public class ProductServiceImpl implements ProductService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<ProductVO> getById(Long id) {
|
||||
public ApiResult<ProductVO> getById(Long id, Boolean queryFeatureScope) {
|
||||
ProductModule byId = productModuleDao.getById(id);
|
||||
ProductVO productVO = BeanMapper.copyBean(byId, ProductVO.class);
|
||||
productVO.setOuTypes(byId.parseOuType());
|
||||
productVO.setProductCategoryDesc(ProductModuleCategoryEnum.getDescByCode(productVO.getCategory()));
|
||||
productVO.setDictWorkspaceTypeDesc(WorkspaceTypeCodeEnum.getDescByCode(productVO.getDictWorkspaceTypeCode()));
|
||||
productVO.setSkus(org.apache.commons.collections.CollectionUtils.isEmpty(byId.getSkus()) ? Collections.emptyList()
|
||||
productVO.setSkus(CollectionUtils.isEmpty(byId.getSkus()) ? Collections.emptyList()
|
||||
: byId.getSkus().stream().map(e -> ProductVO.Sku.builder()
|
||||
.skuName(e.getSkuName())
|
||||
.model(e.getModel())
|
||||
@ -122,8 +125,19 @@ public class ProductServiceImpl implements ProductService {
|
||||
.videos(byId.getMaterial().getVideos())
|
||||
.detailImages(byId.getMaterial().getDetailImages())
|
||||
.build());
|
||||
if (WorkspaceTypeCodeEnum.GOVERNMENT.getCode().equals(productVO.getDictWorkspaceTypeCode())) {
|
||||
fillFeatureScope(productVO);
|
||||
if (Boolean.TRUE.equals(queryFeatureScope)) {
|
||||
if (WorkspaceTypeCodeEnum.GOVERNMENT.getCode().equals(productVO.getDictWorkspaceTypeCode())) {
|
||||
fillFeatureScope(productVO);
|
||||
} else {
|
||||
fillNonGaFeatureRelation(productVO);
|
||||
}
|
||||
} else {
|
||||
ProductFeatureRelationSearchReq req = new ProductFeatureRelationSearchReq();
|
||||
req.setProductModuleId(id);
|
||||
ApiResult<List<ProductFeatureRelationVO>> result = productFeatureRelationService.featureList(req);
|
||||
if (CollectionUtils.isNotEmpty(result.getData())) {
|
||||
productVO.setRelationType(result.getData().get(0).getType());
|
||||
}
|
||||
}
|
||||
return ApiResult.ok(productVO);
|
||||
}
|
||||
@ -216,6 +230,8 @@ public class ProductServiceImpl implements ProductService {
|
||||
// 保存商品权限信息
|
||||
if (WorkspaceTypeCodeEnum.GOVERNMENT.getCode().equals(productModule.getDictWorkspaceTypeCode())) {
|
||||
saveGovernmentFeatureResource(productModule.getId(), productModule.getDictWorkspaceTypeId(), productModule.getDictWorkspaceTypeCode(), req.getFeatureScope().getGovernmentFeatureResourceIds());
|
||||
} else {
|
||||
saveNonGaFeatureResource(productModule.getId(), req.getFeatureScope().getRelations());
|
||||
}
|
||||
return ApiResult.ok(productModule.getId());
|
||||
}
|
||||
@ -287,16 +303,18 @@ public class ProductServiceImpl implements ProductService {
|
||||
ProductModuleCategoryEnum productModuleCategoryEnum = ProductModuleCategoryEnum.getByCode(req.getProductCategory());
|
||||
AssertUtil.notNull(productModuleCategoryEnum, "产品类型有误");
|
||||
|
||||
// if (WorkspaceTypeCodeEnum.GENERAL_ENT.equals(workspaceTypeCodeEnum) || WorkspaceTypeCodeEnum.GENERAL_PROJECT.equals(workspaceTypeCodeEnum)) {
|
||||
// AssertUtil.notNull(req.getMaxPersonCount(), "人数上限不能为空");
|
||||
// AssertUtil.notNull(req.getPrice(), "价格不能为空");
|
||||
// if (ProductModuleCategoryEnum.PRODUCT_VERSION.getCode().equals(req.getProductCategory())) {
|
||||
// AssertUtil.notNull(req.getVersion(), "版本升级序列不能为空");
|
||||
// }
|
||||
// }
|
||||
if (WorkspaceTypeCodeEnum.GOVERNMENT.equals(workspaceTypeCodeEnum)) {
|
||||
AssertUtil.isTrue(Objects.nonNull(req.getFeatureScope())
|
||||
&& org.apache.commons.collections4.CollectionUtils.isNotEmpty(req.getFeatureScope().getGovernmentFeatureResourceIds()), "功能范围选择有误");
|
||||
&& CollectionUtils.isNotEmpty(req.getFeatureScope().getGovernmentFeatureResourceIds()), "功能范围选择有误");
|
||||
} else {
|
||||
if (Objects.isNull(req.getId())) {
|
||||
AssertUtil.isTrue(Objects.nonNull(req.getFeatureScope())
|
||||
&& CollectionUtils.isNotEmpty(req.getFeatureScope().getRelations()), "产品的功能范围选择有误");
|
||||
} else {
|
||||
SaasProductModuleFeatureRelation oneRelation = productFeatureRelationService.getOneByProductId(req.getId());
|
||||
AssertUtil.isTrue(Objects.isNull(oneRelation)
|
||||
|| ProductModuleFeatureRelationTypeEnum.FEATURE_RESOURCE.getCode().equals(oneRelation.getType()), "请在老的产品管理菜单编辑产品权限。");
|
||||
}
|
||||
}
|
||||
productModule.setProductName(req.getProductName());
|
||||
productModule.setIcon(req.getIcon());
|
||||
@ -309,7 +327,7 @@ public class ProductServiceImpl implements ProductService {
|
||||
productModule.setMaxPersonCount(req.getMaxPersonCount());
|
||||
productModule.setMaxWorkspaceCount(req.getMaxWorkspaceCount());
|
||||
productModule.setPrice(req.getPrice());
|
||||
productModule.setSkus(org.apache.commons.collections.CollectionUtils.isEmpty(req.getSkus()) ? Lists.newArrayList()
|
||||
productModule.setSkus(CollectionUtils.isEmpty(req.getSkus()) ? Lists.newArrayList()
|
||||
: req.getSkus().stream().map(e -> ProductModule.Sku.builder()
|
||||
.skuName(e.getSkuName())
|
||||
.model(e.getModel())
|
||||
@ -339,7 +357,7 @@ public class ProductServiceImpl implements ProductService {
|
||||
req.setDictCodeId(dictWorkspaceTypeId);
|
||||
req.setDictCode(dictWorkspaceTypeCode);
|
||||
req.setProductModuleId(productId);
|
||||
Set<Long> featureIds = org.apache.commons.collections.CollectionUtils.isEmpty(frs) ? Sets.newHashSet()
|
||||
Set<Long> featureIds = CollectionUtils.isEmpty(frs) ? Sets.newHashSet()
|
||||
: frs.stream().map(BaseEntity::getId).collect(Collectors.toSet());
|
||||
featureIds.addAll(rootFeatureIds);
|
||||
req.getFeatureIds().addAll(featureIds);
|
||||
@ -347,15 +365,44 @@ public class ProductServiceImpl implements ProductService {
|
||||
productFeatureRelationService.updateFeatureRelation(Collections.singletonList(req));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存非政务端产品功能权限
|
||||
*/
|
||||
private void saveNonGaFeatureResource(Long productId, List<ProductSaveReq.ProductFeatureRelation> relations) {
|
||||
List<Long> dictCodeIds = Lists.newArrayList();
|
||||
for (ProductSaveReq.ProductFeatureRelation relation : relations) {
|
||||
AssertUtil.notNull(relation.getDictCodeId(), "功能范围选择的字典ID不能未空。");
|
||||
dictCodeIds.add(relation.getDictCodeId());
|
||||
}
|
||||
|
||||
Map<Long, BasicDictNodeResp> nodeMap = saasBasicDictService.getBasicDictNodeList(BasicDictQueryReq.builder().ids(dictCodeIds).build())
|
||||
.stream().collect(Collectors.toMap(BasicDictNodeResp::getId, Function.identity(), (v1, v2) -> v1));
|
||||
|
||||
List<ProductFeatureRelationUpdateReq> reqs = Lists.newArrayList();
|
||||
for (ProductSaveReq.ProductFeatureRelation relation : relations) {
|
||||
ProductFeatureRelationUpdateReq req = new ProductFeatureRelationUpdateReq();
|
||||
req.setDictCodeId(relation.getDictCodeId());
|
||||
req.setDictCode(nodeMap.getOrDefault(relation.getDictCodeId(), new BasicDictNodeResp()).getCode());
|
||||
req.setProductModuleId(productId);
|
||||
if (CollectionUtils.isNotEmpty(relation.getFeatureIds())) {
|
||||
req.getFeatureIds().addAll(relation.getFeatureIds());
|
||||
}
|
||||
req.setFeatureRelationType(ProductModuleFeatureRelationTypeEnum.FEATURE_RESOURCE.getCode());
|
||||
reqs.add(req);
|
||||
}
|
||||
productFeatureRelationService.updateFeatureResourceRelation(reqs);
|
||||
}
|
||||
|
||||
private void fillFeatureScope(ProductVO product) {
|
||||
ProductFeatureRelationSearchReq req = new ProductFeatureRelationSearchReq();
|
||||
req.setProductModuleId(product.getId());
|
||||
req.setDictCodeId(product.getDictWorkspaceTypeId());
|
||||
req.setDictCode(product.getDictWorkspaceTypeCode());
|
||||
ApiResult<List<ProductFeatureRelationVO>> result = productFeatureRelationService.featureList(req);
|
||||
if (org.apache.commons.collections.CollectionUtils.isEmpty(result.getData())) {
|
||||
if (CollectionUtils.isEmpty(result.getData())) {
|
||||
return;
|
||||
}
|
||||
product.setRelationType(result.getData().get(0).getType());
|
||||
List<Long> featureIds = result.getData().stream().map(ProductFeatureRelationVO::getFeatureId).collect(Collectors.toList());
|
||||
List<SaasFeatureResource> featureResources = saasFeatureResourceService.listByParentIdAndTerminalAndIds(0L, TerminalInfo.NT_PC_GA_GENERAL, featureIds);
|
||||
if (CollectionUtil.isNotEmpty(featureResources)) {
|
||||
@ -366,6 +413,28 @@ public class ProductServiceImpl implements ProductService {
|
||||
}
|
||||
}
|
||||
|
||||
private void fillNonGaFeatureRelation(ProductVO product) {
|
||||
ProductFeatureRelationSearchReq req = new ProductFeatureRelationSearchReq();
|
||||
req.setProductModuleId(product.getId());
|
||||
ApiResult<List<ProductFeatureRelationVO>> result = productFeatureRelationService.featureList(req);
|
||||
if (CollectionUtils.isEmpty(result.getData())) {
|
||||
return;
|
||||
}
|
||||
product.setRelationType(result.getData().get(0).getType());
|
||||
|
||||
Map<Long, List<ProductFeatureRelationVO>> relationMap = result.getData().stream().collect(Collectors.groupingBy(ProductFeatureRelationVO::getDictCodeId));
|
||||
List<ProductVO.ProductFeatureRelation> relations = Lists.newArrayList();
|
||||
relationMap.forEach((k, v) -> {
|
||||
ProductVO.ProductFeatureRelation pr = ProductVO.ProductFeatureRelation.builder()
|
||||
.dictCodeId(k)
|
||||
.totalCount(v.size())
|
||||
.featureIds(v.stream().map(ProductFeatureRelationVO::getFeatureId).collect(Collectors.toList()))
|
||||
.build();
|
||||
relations.add(pr);
|
||||
});
|
||||
product.setRelations(relations);
|
||||
}
|
||||
|
||||
private WorkspaceProductResp.Product buildRespProduct(ProductModule pm) {
|
||||
return Optional.ofNullable(pm).map(e -> WorkspaceProductResp.Product.builder()
|
||||
.productId(e.getId())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user