|
|
|
|
@ -2,11 +2,14 @@ package cn.axzo.tyr.server.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.axzo.basics.common.BeanMapper;
|
|
|
|
|
import cn.axzo.basics.common.util.AssertUtil;
|
|
|
|
|
import cn.axzo.basics.profiles.api.UserProfileServiceApi;
|
|
|
|
|
import cn.axzo.basics.profiles.dto.basic.PersonProfileDto;
|
|
|
|
|
import cn.axzo.framework.auth.domain.TerminalInfo;
|
|
|
|
|
import cn.axzo.framework.domain.page.PageResp;
|
|
|
|
|
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.PermissionRelationOperateLogSceneEnum;
|
|
|
|
|
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;
|
|
|
|
|
@ -17,15 +20,19 @@ import cn.axzo.tyr.client.model.req.ProductSaveReq;
|
|
|
|
|
import cn.axzo.tyr.client.model.req.UpdateProductStatusReq;
|
|
|
|
|
import cn.axzo.tyr.client.model.res.GovernmentTerminalResp;
|
|
|
|
|
import cn.axzo.tyr.client.model.res.WorkspaceProductResp;
|
|
|
|
|
import cn.axzo.tyr.server.model.RelationOperateLogProductBindResourceDO;
|
|
|
|
|
import cn.axzo.tyr.server.model.RelationOperateLogResourceBindElementDO;
|
|
|
|
|
import cn.axzo.tyr.server.repository.dao.SaasFeatureResourceDao;
|
|
|
|
|
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.SaasPgroupPermissionRelationOperateLog;
|
|
|
|
|
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;
|
|
|
|
|
import cn.axzo.tyr.server.service.SaasFeatureResourceService;
|
|
|
|
|
import cn.axzo.tyr.server.service.*;
|
|
|
|
|
import cn.axzo.tyr.server.util.RpcInternalUtil;
|
|
|
|
|
import cn.azxo.framework.common.constatns.Constants;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
|
|
|
|
@ -34,6 +41,7 @@ import com.google.common.collect.Sets;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
import org.slf4j.MDC;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
@ -56,6 +64,9 @@ public class ProductServiceImpl implements ProductService {
|
|
|
|
|
private final ProductFeatureRelationService productFeatureRelationService;
|
|
|
|
|
private final SaasFeatureResourceService saasFeatureResourceService;
|
|
|
|
|
private final SaasBasicDictService saasBasicDictService;
|
|
|
|
|
private final UserProfileServiceApi userProfileServiceApi;
|
|
|
|
|
private final SaasPgroupPermissionRelationOperateLogService saasPgroupPermissionRelationOperateLogService;
|
|
|
|
|
private final SaasFeatureResourceDao saasFeatureResourceDao;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ApiResult<List<ProductVO>> list(ProductSearchListReq req) {
|
|
|
|
|
@ -227,9 +238,15 @@ public class ProductServiceImpl implements ProductService {
|
|
|
|
|
}
|
|
|
|
|
// 保存商品权限信息
|
|
|
|
|
if (WorkspaceTypeCodeEnum.GOVERNMENT.getCode().equals(productModule.getDictWorkspaceTypeCode())) {
|
|
|
|
|
saveGovernmentFeatureResource(productModule.getId(), productModule.getDictWorkspaceTypeId(), productModule.getDictWorkspaceTypeCode(), req.getFeatureScope().getGovernmentFeatureResourceIds());
|
|
|
|
|
saveGovernmentFeatureResource(productModule.getId(), productModule.getDictWorkspaceTypeId(), productModule.getDictWorkspaceTypeCode(), req.getFeatureScope().getGovernmentFeatureResourceIds(), req);
|
|
|
|
|
} else {
|
|
|
|
|
saveNonGaFeatureResource(productModule.getId(), req.getFeatureScope().getRelations());
|
|
|
|
|
// 保存操作日志
|
|
|
|
|
try {
|
|
|
|
|
saveOperateLog4NonGaProduct(req, productModule.getId());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.warn("save operate log error", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ApiResult.ok(productModule.getId());
|
|
|
|
|
}
|
|
|
|
|
@ -347,7 +364,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
|
|
/**
|
|
|
|
|
* 保存政务端产品功能权限
|
|
|
|
|
*/
|
|
|
|
|
private void saveGovernmentFeatureResource(Long productId, Long dictWorkspaceTypeId, String dictWorkspaceTypeCode, List<Long> rootFeatureIds) {
|
|
|
|
|
private void saveGovernmentFeatureResource(Long productId, Long dictWorkspaceTypeId, String dictWorkspaceTypeCode, List<Long> rootFeatureIds, ProductSaveReq request) {
|
|
|
|
|
List<SaasFeatureResource> saasFeatureResources = saasFeatureResourceService.listByParentIdAndTerminalAndIds(null, null, rootFeatureIds);
|
|
|
|
|
AssertUtil.notEmpty(saasFeatureResources, "功能范围选择端不能为空");
|
|
|
|
|
saasFeatureResources.forEach(e -> {
|
|
|
|
|
@ -365,6 +382,13 @@ public class ProductServiceImpl implements ProductService {
|
|
|
|
|
req.getFeatureIds().addAll(featureIds);
|
|
|
|
|
req.setFeatureRelationType(ProductModuleFeatureRelationTypeEnum.FEATURE_RESOURCE.getCode());
|
|
|
|
|
productFeatureRelationService.updateFeatureResourceRelation(Collections.singletonList(req), ProductModuleFeatureRelationTypeEnum.FEATURE_RESOURCE.getCode());
|
|
|
|
|
|
|
|
|
|
// 保存操作日志
|
|
|
|
|
try {
|
|
|
|
|
saveOperateLog4GovernmentProduct(request, productId, frs);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.warn("save operate log error", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -458,4 +482,51 @@ public class ProductServiceImpl implements ProductService {
|
|
|
|
|
.build()).collect(Collectors.toList()) : Collections.emptyList())
|
|
|
|
|
.build()).orElse(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void saveOperateLog4GovernmentProduct(ProductSaveReq req, Long productId, List<SaasFeatureResource> featureResources) {
|
|
|
|
|
List<PersonProfileDto> personProfileDtos = RpcInternalUtil.rpcListProcessor(() -> userProfileServiceApi.getPersonProfiles(Lists.newArrayList(req.getOperator())), "查询用户信息", req.getOperator()).getData();
|
|
|
|
|
PersonProfileDto operator = CollectionUtils.isEmpty(personProfileDtos) ? null : personProfileDtos.get(0);
|
|
|
|
|
|
|
|
|
|
RelationOperateLogProductBindResourceDO operateAfter = RelationOperateLogProductBindResourceDO.builder()
|
|
|
|
|
.productId(productId)
|
|
|
|
|
.uniCodes(CollectionUtils.emptyIfNull(featureResources).stream().map(SaasFeatureResource::getUniCode).collect(Collectors.toList()))
|
|
|
|
|
.build();
|
|
|
|
|
SaasPgroupPermissionRelationOperateLog operateLog = SaasPgroupPermissionRelationOperateLog.builder()
|
|
|
|
|
.tableName(SaasPgroupPermissionRelationOperateLogServiceImpl.TABLE_NAME_PRODUCT)
|
|
|
|
|
.scene(PermissionRelationOperateLogSceneEnum.OMS_PRODUCT_BIND_FEATURE_RESOURCE.getValue())
|
|
|
|
|
.createBy(req.getOperator())
|
|
|
|
|
.createByName(Objects.isNull(operator) ? "" : operator.getRealName())
|
|
|
|
|
.traceId(MDC.get(Constants.CTX_LOG_ID_MDC))
|
|
|
|
|
.requestData(JSONObject.toJSONString(req))
|
|
|
|
|
.operateData(JSONObject.toJSONString(Lists.newArrayList(operateAfter)))
|
|
|
|
|
.createByRole(JSONObject.toJSONString(saasPgroupPermissionRelationOperateLogService.getPersonBasicRoles(req.getOperator())))
|
|
|
|
|
.build();
|
|
|
|
|
saasPgroupPermissionRelationOperateLogService.batchSave(Lists.newArrayList(operateLog));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void saveOperateLog4NonGaProduct(ProductSaveReq req, Long productId) {
|
|
|
|
|
List<PersonProfileDto> personProfileDtos = RpcInternalUtil.rpcListProcessor(() -> userProfileServiceApi.getPersonProfiles(Lists.newArrayList(req.getOperator())), "查询用户信息", req.getOperator()).getData();
|
|
|
|
|
PersonProfileDto operator = CollectionUtils.isEmpty(personProfileDtos) ? null : personProfileDtos.get(0);
|
|
|
|
|
List<SaasFeatureResource> featureResources = Lists.newArrayList();
|
|
|
|
|
if (CollectionUtils.isNotEmpty(req.getFeatureScope().getRelations())) {
|
|
|
|
|
Set<Long> allFeatureResourceIds = req.getFeatureScope().getRelations().stream().map(ProductSaveReq.ProductFeatureRelation::getFeatureIds).filter(CollectionUtils::isNotEmpty).flatMap(Set::stream).collect(Collectors.toSet());
|
|
|
|
|
featureResources = saasFeatureResourceDao.lambdaQuery().in(BaseEntity::getId, allFeatureResourceIds).list();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RelationOperateLogProductBindResourceDO operateAfter = RelationOperateLogProductBindResourceDO.builder()
|
|
|
|
|
.productId(productId)
|
|
|
|
|
.uniCodes(featureResources.stream().map(SaasFeatureResource::getUniCode).collect(Collectors.toList()))
|
|
|
|
|
.build();
|
|
|
|
|
SaasPgroupPermissionRelationOperateLog operateLog = SaasPgroupPermissionRelationOperateLog.builder()
|
|
|
|
|
.tableName(SaasPgroupPermissionRelationOperateLogServiceImpl.TABLE_NAME_PRODUCT)
|
|
|
|
|
.scene(PermissionRelationOperateLogSceneEnum.OMS_PRODUCT_BIND_FEATURE_RESOURCE.getValue())
|
|
|
|
|
.createBy(req.getOperator())
|
|
|
|
|
.createByName(Objects.isNull(operator) ? "" : operator.getRealName())
|
|
|
|
|
.traceId(MDC.get(Constants.CTX_LOG_ID_MDC))
|
|
|
|
|
.requestData(JSONObject.toJSONString(req))
|
|
|
|
|
.operateData(JSONObject.toJSONString(Lists.newArrayList(operateAfter)))
|
|
|
|
|
.createByRole(JSONObject.toJSONString(saasPgroupPermissionRelationOperateLogService.getPersonBasicRoles(req.getOperator())))
|
|
|
|
|
.build();
|
|
|
|
|
saasPgroupPermissionRelationOperateLogService.batchSave(Lists.newArrayList(operateLog));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|